10ms 20ms 50ms 100ms 16F877A running at 20MHz I am using this now, but I am a little dubious, after the first cycle of 231, the outer loop overflows to 255, firing up the osciliscope. ; -------------------------------------------------------------------------- ---------------------------- ; Delay routines - 20 MHz xtal ; -------------------------------------------------------------------------- ---------------------------- Delay255 movlw 0xff ;delay 255mS goto d0 Delay100 movlw d'100' ;delay 100mS goto d0 Delay50 movlw d'50' ;delay 50mS goto d0 Delay20 movlw d'20' ;delay 20mS goto d0 Delay10 movlw d'10' ;delay 10mS goto d0 Delay1 movlw d'1' ;delay 1mS goto d0 Delay5 movlw 0x05 ;delay 5ms d0 movwf count1 d1 movlw 0xE7 ; E7 = 231 decimal movwf counta ; outer loop - delay 231 cycles movlw 0x04 ; delay - 4 loops movwf countb ; total loop = 199 x (4+1) = 995 ( 4MHz 199 decimal x 5 = 995 ) Delay_0 decfsz counta, f goto $+2 decfsz countb, f goto Delay_0 decfsz count1 ,f goto d1 -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu]On Behalf Of Jan-Erik Soderholm Sent: Wednesday, 5 January 2005 8:30 PM To: piclist@mit.edu Subject: RE: [PIC] 16F877A delay code > Can someone help me with some delay code for a uP running at 20 MHz ? > I have some code for 4MHz, is it just a matter of scalling by 5 ? Hi. How long delay ? How often should this delay "run" ? Generaly speaking, use timers for delays, not code. Regards, Jan-Erik -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist