cancel
Showing results for 
Search instead for 
Did you mean: 

Reseting to Handle a Hanging (dead) Program

partymarty6969
Associate II
Posted on March 03, 2005 at 04:04

Reseting to Handle a Hanging (dead) Program

5 REPLIES 5
jdaniel
Associate II
Posted on May 17, 2011 at 12:06

Marty,

When people say ''hard reset'' they generally mean something hardware based and not under software control. By the very nature of your problem, there's not much you can do in software if the program code is ''hung.'' People would quite often use a watchdog timer for this. That way, when the program hangs, the watchdog times out and does a ''hard reset'' itself.

As far as doing a soft reset, the watchdog is the ONLY good way to do it. There are far too many things to keep in mind if you want to reset manually. If you wanted to do it, however, all you really have to do is do two RETI's, set every SFR to its reset value, and then jump to code location 0x0000. This is not trivial to do without messing things up.

partymarty6969
Associate II
Posted on May 17, 2011 at 12:06

Hello,

I need some help and I'm not sure how to go about doing this, I would like to implement a hard reset (or something along those lines) so that if IAP works (set the status byte of the flash memory to valid) but the program code is corrupt and is left hanging (dead), I can use the hard reset (power off then on) to erase that status byte (so when system reboots it doesn’t run the corrupt program) and load the previous valid image of the program located in memory. Where would be a good place to store this status byte so that such a reset could work? If anyone has any ideas on how to implement such a thing I’m all ears 🙂

Also if during IAP the bootloader craps out and is left pending, what could I do to reset the microcontroller? I’m assuming this could be done by adding the watchdog to the bootloader but is there another way? Perhaps if the hard reset is implemented for the first case, I could use that.

Thanks

partymarty6969
Associate II
Posted on May 17, 2011 at 12:06

That’s what I mean, I’m trying to implement a hardware reset such as a switch that when it is pushed, it will power off the system and erase the status byte of the updated flash memory (perhaps all data memory) because the updated program is hanging (dead) and boot up the previous valid program. Any ideas on how to go about doing this? If I can’t, then I’ll use the watch dog reset but I’d really prefer to have some sort of a hardware reset.

Thanks for your help,

MartyQ

jdaniel
Associate II
Posted on May 17, 2011 at 12:06

Marty,

While anything is technically possible, this kind of mechanism would be a Bad Thing. Basically, you should just ensure that the application image is good BEFORE you mark it good. Afterwards, there's no way to automatically erase that section with the push of a button. By its very nature, if the uPSD is in reset, it can't do anything to erase the flash memory. Even the watchdog timer isn't going to save you in that respect.

partymarty6969
Associate II
Posted on May 17, 2011 at 12:06

Thanks for the help Phaze426