Code for accurate 1 second delay function
;======================= DELAY 1 SEC ================
DELAY_1S DELAY_1S:
MOV r7,#1 ;Value of R7=no. of second delay for 12Mhz(1.0003S ACCURATE)D1S0: MOV r6,#0ffh
D1S1: MOV r5,#245
D1S2: NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DJNZ r5,D1S2
DJNZ r6,D1S1
DJNZ r7,D1S0
RET
Note : You can chance the value of r7 to get different value of delay. The delay function can be use in many different processors / microcontrollers (ATMEL, PIC microchip, Dallas, NXN Philips...) . Also not that is function is code for 12Mhz frequency, for different frequency, different value of register will be need to calculate.
Discussion (0)
No approved comments yet. Start a thoughtful discussion.
Sign in to comment.