Re: AT89S8252 Ext Watchdog
Hi GrandAlf,
You can use the AT89S8252's provided feature of disable ALE signal as follows:
Code:
ALE_ONOFF EQU 8Eh ;SFR label declaration
ORL ALE_ONOFF,#01h ;Stop sending ALE (start of external monostable
;. cycle driven by ALE pin and first Watchdog cycle)
;.
;.
;.
;.replace this with your code
;.
;.
CLR EA
ANL ALE_ONOFF,#0FEh ;Start sending ALE pulses and retrigger monostable
NOP ;leave one cycle to be sure
ORL ALE_ONOFF,#01h ;Stop sending ALE pulses and allow monostable to run
SET EA
;.
;.
;.replace this with your code
;.
;.
;.
CLR EA
ANL ALE_ONOFF,#0FEh
NOP
ORL ALE_ONOFF,#01h
SET EA
;.
;.
;.
;.
The time spent between opcodes ORL and ANL (those reserved for your code) should
be less than the external monostable time constant (watchdog period).
You must insert the pair ANL NOP ORL at constant rate in your program in order to retrigger the external monostable.
If your program stuck somewhere and not being able to hit the point where ANL NOP ORL are inserted, the external monostable will reset the micro.
I had never tried, maybe the above code could work, I don't know.
But the most important thing depends upon what you are using the watchdog timer to guard against:
1. unexpected consequences of coding or
2. gamma ray particles passing through the chip die
If you choose first point then you should wonder how you can store the PC (program counter) address where you stuck and parsing your program for that address after recover.
If you are unable to find it, at least you should be happy that your microwave oven didn't burned the chicken due to program lock.
Regards,
Silvio