Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/18/00 06:31
Read: times


 
#2247 - RE: Timeout,watchdog
> how a 'time-out' function can be
> addesd to a code?

The most obvious solution is to set up one of timers for 16-bit mode, load TLn/THn with required value, turn off corresponding "Timer Overflow" interrupt and watch for TFn flag becoming active. This would allow to implement a timeout of 0FFFFh machine cycles, that is, about 65 ms at 12 MHz.

Another, less accurate, solution would be to count loops where you wait for some event. For example, here you'll have timeout of 205600 cycles, or 205.6 ms at 12 MHz:

.........
clr TI
mov SBUF,A ; sending a byte
mov R1,#200
reload:
mov R0,#0 ; 2 cycles
wait:
jb TI,wait_done ; 2
djnz R0,wait ; 2; 4*256=1024
djnz R1,reload ; 2; 1028*200=205600
timeout:
..........
wait_done:
..........


> What is the difference with watchdog?

When watchdog timer times out, it resets the MCU automatically; and this is unavoidable.


List of 4 messages in thread
TopicAuthorDate
Timeout,watchdog            01/01/70 00:00      
RE: Timeout,watchdog            01/01/70 00:00      
RE: Timeout,watchdog            01/01/70 00:00      
RE: Timeout,watchdog            01/01/70 00:00      

Back to Subject List