View Single Post
Old 07-11-2007, 11:41 PM   #3
dvkkt
Đệ tử 3 túi
 
dvkkt's Avatar
 
Tham gia ngày: Oct 2007
Nơi Cư Ngụ: TPHCM
Bài gửi: 55
:
Send a message via Yahoo to dvkkt
Nguyền văn như sau:
_ The actual implementation of a delay routine based on multi-byte counters presents some dificulties. If the timer register (TMR0) is used to keep track of timer beats, then detecting the end of the count poses a subtle problem. Intuitively, our program could detect timer overflow by reading the TMR0 and testing the zero flag in the STATUS register. Since the movf instruction affects the zero flag, one could be tempted to code:
wait
movf tmr0,w
btfss status,z
goto wait
_ But there is a problem: the timer ticks as each instruction executes. Since the goto instruction takes two machine cycles, it is possible that the timer overflows while the goto instruction is in progress; therefore the overflow condition would not be detected.
dvkkt vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn