![]() |
Forum Index : Microcontroller and PC projects : Error
Author | Message | ||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I have a micromite with OPTION AUTORUN ON Is there ANY way to restart the micromite if it crashes? Something like "IF ERROR THEN RUN" ? |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9589 |
If by "Crash" you mean it stops to the command-prompt with an error, then the WATCHDOG command would probably help you there. If by "Crash" you mean that the PIC32 core actually crashes - which means that the MMBASIC firmware crashes also and stops working - then you would PROBABLY need an external watchdog to force a reset. I am not sure if WATCHDOG actually interfaces to the watchdog in the PIC32, but it quite probably does - Geoff or Peter(matherp) will know this, and be able to say. If it DOES talk to the internal watchdog, and provided that runs seperate from the core, then WATCHDOG should still reset a crashed core, but that is possibly a big ask as I would expect if something bad enough to crash the core happens, then a software watchdog won't help you either. ![]() Perhaps you could clarify which one of those crashes you mean. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1000 |
Hi Lewis, The WATCHDOG command should help. See the extract from the manual below. Regards Gerry WATCHDOG timeout or WATCHDOG OFF Starts the watchdog timer which will automatically restart the processor when it has timed out. This can be used to recover from some event that disabled the running program (such as an endless loop or a programming or other error that halts a running program). This can be important in an unattended control situation. 'timeout' is the time in milliseconds (mS) before a restart is forced. This command should be placed in strategic locations in the running BASIC program to constantly reset the timer and therefore prevent it from counting Micromite User Manual Page 73 down to zero. If the timer count does reach zero (perhaps because the BASIC program has stopped running) the Micromite will be automatically restarted and the automatic variable MM.WATCHDOG will be set to true (ie, 1) indicating that an error occurred. On a normal startup MM.WATCHDOG will be set to false (ie, 0). At any time WATCHDOG OFF can be used to disable the watchdog timer (this is the default on a reset or power up). The timer is also turned off when the break character (normally CTRL-C) is used on the console to interrupt a running program. Latest F4 Latest H7 FotS |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
hanks I did search the manual but I was looking for error not watchdog If I understand what was said above, if the program stops with something similar to Error: device not found or something similar, if the watchdog is turned on then the program will wait a set number of seconds and then run again? What time would you set the watchdog to? The program I'm using has a timer that counts in seconds so I would "assume" if I put something like WATCHDOG 60 would tell the micromite to run the program again if it does stop on an error? Where would you recommend the command is put in the program? Or can you have it in several places? |
||||
BobD![]() Guru ![]() Joined: 07/12/2011 Location: AustraliaPosts: 935 |
|
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3282 |
No, The MMBasic WATCHDOG feature does not use the PIC32 hardware watchdog timer. This is because that timer's timeout must be set at compile time. If there is an exception (an internal PIC32 error) the processor will immediately restart and if autorun is on the BASIC program will restart - so the MMBasic WATCHDOG can be used to recover from all errors. Geoff Geoff Graham - http://geoffg.net |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thanks everyone |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9589 |
@ BobD - Nice explanation. ![]() @ Geoff - OK. Thanks. Was not sure. The common way to do the watchdog thing in days gone past, was with a 555 timer or similar circuit. We even developed one here on the forums a few years ago. Back in the 80's and 90's before the plethora of MCU's we have now, the main controller used to output a pulse on a pin, often referred to as a 'Heartbeat' or just 'Watchdog'. This pulse would continuously reset an external timer. Now, if the controller fell over for some reason, these heartbeat pulses would stop, and the external timer would time-out(normally about 5-10 seconds depending on design), and it would then pulse the RESET pin of the main controller, forcing it to restart. A very old idea, but still a very relevant one, and any modern system designer HAS to consider failure recovery if the system is important - such as security. Luckily for us, the MM WATCHDOG command makes this child's-play these days. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |