??? 08/15/05 11:50 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#99408 - possible troubles Responding to: ???'s previous message |
hi,
Russell Bull said:
interrupt:
do whatever.... pop a pop a ;remove return address off the stack clr a push a push a ;push return address of 0x0000 onto the stack reti ;this will return to address 0x0000 If you'd done some reading, this would have been obvious! Remember jumping to address 0x0000 is not the same as doing a reset! Exactly! Moreover with such "technique" there are some hard-traced problems: - if an interrupt with this code has high priority level and occures during low-priority one is in progress then after recovering from program initialization you will lost low-level interrupts in the whole. It is because they are still blocked (need another reti). - this code jumps to address 0x0000 with interrupts enabled. This way is very dangerous because as a rule, program initialization code supposes that all interrupts are disabled during setup of variables. As Abhishek mentioned, enable the watchdog. To reboot the micro, just have your code sit in a dead loop and the watchdog will bail you out. Indeed, this is the best idea. Anyway in some cases this way may be rejected as well. For example, when you need with quick recover-back time (as I remember, fastest watchdog prescaler of AT89S8252 provides 16ms delay). Regards, Oleg |