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 : Quick RUN question....
Author | Message | ||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
As a nice quick way of resetting my system, I am thinking of just issuing RUN as a command in the listing. I have tested this at a very basic level, and seems to be working OK. In my testing code, the SD card is checked to see if it is open for writing, and if it is, this is closed first before issuing the RUN command. Is it safe to assume that the RUN command closes all ports, clears all buffers, strings, arrays, interrupts etc? Perhaps I don't need to close an open port, if the RUN command will do all this for me? Smoke makes things work. When the smoke gets out, it stops! |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3196 |
Yes, RUN resets everything (ie, clears all variables, arrays, loops and resets I/O pins, communication ports, etc). So does NEW. Geoff Graham - http://geoffg.net |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
Excellent - just what I wanted. Thanks for the reply. Smoke makes things work. When the smoke gets out, it stops! |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
I tried a few days ago to use "run" as a command in a programme to effect a programme reset and keep getting: Error: Invalid in a program How are you doing yours? ============ Reading between the lines, I gather you are using the MM hence the SD card reference. I have been trying to get it working on the uM. David M. |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3196 |
RUN inside a program does not work on the Micromite. But you can get the same effect with OPTION WATCHDOG 1 which will immediately trigger the watchdog timer and (assuming AUTORUN is on) will restart the program. Geoff Graham - http://geoffg.net |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
@ Geoff, Thanks Geoff, I had forgotten about watchdog. I'll go down that track. Perhaps a side note in the RUN command of the manual could steer the unwary in the right direction. Would it be too difficult to include RUN as a programme command? It would IMO make things easier? David M. |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3196 |
It would be very easy, in fact it would just consist of removing the code that checks for RUN in a running program. But I put that in because it would be illogical to run the same program within itself. This is a balancing act in logic. In another thread on the BS the subject is the logicality of allowing a variable name to be the same as a function name. One of the things that I try to do is not put artificial barriers in the way of the programmer, even if it is illogical. So on that basis I should remove the restriction on RUN inside a program. Thanks for triggering the thought experiment - I will make the change in the next version. Geoff Geoff Graham - http://geoffg.net |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
Hi folks. @ MOBI - YES, I am using the full-size colour Maximite for this RUN command. Basically, I am using it as a RESET kind of command, because it will save me having to close ports, empty strings and variables, and also allows the code to start again right from the beginning, so it won't hold onto any deeply hidden bug in a string or something! Probably not the most expert, professional or otherwise standard of coding practice, but hey - if it works.... BTW - I have not dropped the MicroMite, I just need to finish this Maximite code so that then I CAN concentrate fully on the new beast! Smoke makes things work. When the smoke gets out, it stops! |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
As I recall, Microsoft basic and apple basic etc, all allowed the RUN command within the programme. Although it would be nice to have on the uM, if AUTORUN mode is on, then inserting a WATCHDOG 1 command is just as good: e.g. if Keycode = 10 then: watchdog 1: endif
will work nicely as an escape key. (10 is the * key on the hex pad) The programme will restart with the watchdog off (reset). Nose wet. I'm patient or is that Impatient? What a difference an apostrophe makes. David M. |
||||
Print this page |