Hi, I am using the following code on a PIC16F877 @ 4MHz: bsf PORTB, 4 bsf PORTB, 1 ;--------------------- ; delay for at least 2ms movlw 0x95 movwf Dlay movlw 0x02 movwf Dlay + 1 decfsz Dlay goto $ - 1 decfsz Dlay + 1 goto $ - 3 bcf PORTB, 4 ; -------------------- I intended for 2ms to elapse between the execution of the dashed lines. My formula: 1us per instruction 3us per subtraction iteration 2000us / 3us = 667 cycles 667 - 6 (overhead instructions) = 0x295 When I measured this on an oscilloscope, the actual delay came to be 1.2 ms. If anything, it should be greater than 2 ms because I did not take the extra cycles that occur each borrow. Does each subtraction that does not borrow take 3us to complete? (1us for decfsz, 2us for goto) Thanks, -Mike -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads