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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/03/01 17:38
Read: times


 
#15390 - RE: Implementation of watchdog timer
it is quite easy to use any normal timer to implement a watchdog timer.

here's the neo-pseudo-code as I used it on an AT89c51:

org 001bh
Timer_interrupt:
;timer regs overflow
;stop timer
;reset timer regs
;restart timer
jb wdt_bit, Hang
setb wdt_bit
reti

Hang:
mov sp,#030h
push r0
push r1
clr wdt_bit
;do graceful recovery stuff
reti

Start:
mov sp,#030h
mov dptr,#Main loop
mov r0,dpl
mov r1,dph
;intitalize timer

Main_loop:
-mov, add, subb
-operations
-stuff
-etc.
-etc.
clr wdt_bit
ljmp Main_loop

The timer checks for the status of a flag wdt_bit at regular set intervals.
It then restarts the device at Main_loop if it ever hangs.Hence the timer itself is not reset, but only a bit is, which is functionally simpler

It is important to note that in 8051 types,at every function call/ interrupt vector, the return address is pushed onto stack, and popped back into program counter on ret/reti. It is always pushed low-byte first ***.

You can use this simple property to implement a watchdog timer. The advantage of this method is that the timer can be used for other timing purposes where regular periods need to be generated as well, since the timer operation is never interrupted.

Kundi








List of 6 messages in thread
TopicAuthorDate
Implementation of watchdog timer            01/01/70 00:00      
RE: Implementation of watchdog timer            01/01/70 00:00      
RE: Implementation of watchdog timer            01/01/70 00:00      
RE: Implementation of watchdog timer            01/01/70 00:00      
RE: Implementation of watchdog timer            01/01/70 00:00      
RE: Implementation of watchdog timer            01/01/70 00:00      

Back to Subject List