Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Time_0 equ 65535 - 9216 ;Delay for 10msec
mov My2SecDelay,#0 ;Initialize the 2 sec counter
mov TH0,#High Time_0 ;Load timer value
mov TL0,#Low Time_0
mov TMOD,#01H ;timer 0 mode 1
setb ET0 ;enable interrupt timer 0
setb EA
setb TR0 ;start timer 0
EndlessLoop:
;do all your endless coding here
jmp EndlessLoop
T0_ISR: mov th0,#High Time_0 ;Reload timer
mov tl0,#Low Time_0
push acc ;Save registers used in ISR
inc My2SecDelay ;increment delay counter
mov a,My2SecDelay
xrl a,#200
jnz No2Sec
mov My2SecDalay,#0 ;Reset 10msec counter
;do your 2 sec stuff here
No2Sec:
; do other timed stuff here
T0_ISR_End:
pop acc ;Restore registers
reti ;End ISR
aomran said:you can make a very acurrate delay in 8051 using its timer and its very easy.
Attached Complet C code contains delay function "accurate 50 ms delay" you can call it four times to have 2 second delay
if you need more help in 8051/52 i can send you a very useful book
aomran said:Note:- don't try to make delays using for loops or any loops tips, because it will not be accurate ever.
aomran said:make delays using timers, not loops,...