Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Soft RESET for the MM?
Author | Message | ||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
Hi all. I was looking at possibly resetting the MM in the code. I can't see any command for that in the manual. Perhaps it can be done by poking a memory location? Other then that, I can use an I/O pin, pulled high with an external 10k or so, connected back to ~MCLR and pulse it low in the code to force a reset, but is there any way to do that in code with a simple command? Does not matter if not - I will just use the I/O pin method. I plan to have a "RESET" push button on the system, but I am not willing to put this directly on ~MCLR, as if the SD card is writing especially, resetting during a card write is not a good thing. So, I was going to have the "RESET" button connected to a normal I/O line and setup an interrupt for that line, so that if it is ever pressed, it will loop to a short bit of code which just closes any open files, then performs a soft-reset to restart the system. Smoke makes things work. When the smoke gets out, it stops! |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
Often a user reset button is connected to a non maskable interrupt to do the reset under software control. A tiny button hidden behind a small hole is the one that is connected to the reset line. Having both is good otherwise people just recycle power. You would need a small battery or a (super)cap to provide enough power and an input line to detect the power loss to safe important info when that happens. Microblocks. Build with logic. |
||||
Juri74 Senior Member Joined: 06/02/2012 Location: ItalyPosts: 162 |
Hello grogster, for a fast software reset try POKE 1,1,1 |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
Poke 1,1,1 crashes the system, it does not reboot it... Smoke makes things work. When the smoke gets out, it stops! |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
If you setup an interrupt on an i/o port then you could use this: [code] handleInterrupt: 'close files here if necessary CLS Print 'Restarting.....' RUN "YOURPROGRAM.BAS" IRETURN [/code] This will reboot the BASIC program. Microblocks. Build with logic. |
||||
Juri74 Senior Member Joined: 06/02/2012 Location: ItalyPosts: 162 |
i think i found a bug... surely pokeing here and there in memory will end in a crash, ofcourse! poke 1,1,1 is a proof of it.. but shouldn't be safe peeking memory? even theese critical memory locations? try PRINT PEEK(1,1) Juri |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
No, that is referring to an illegal address and the hardware in the PIC32 catches it and forces an exception (this is out of the control of MMBasic). Theoretically it is possible for MMBasic to validate the address before it attempts to use it but there are so many valid/invalid addresses in the PIC32's memory map that it would be too complex and error prone. Geoff Geoff Graham - http://geoffg.net |
||||
Dylan Regular Member Joined: 17/06/2013 Location: NetherlandsPosts: 81 |
I think I tried PEEK(1, 1) too - unless I was trying to peek 1fc/bfc the other month. Slow learner. |
||||
Print this page |