![]() |
Forum Index : Microcontroller and PC projects : Micromite - Save Data
Author | Message | ||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
Is it possible for a Micromite program to save user entered data? I was studying the v5.2 user's manual and I don't see anything obvious, unless a running program could perhaps save a library function containing the relevant data. So what am I trying to do? I want to write a small interpreter running in MMBasic. The user of the device would communicate with the program by serial port and enter a sequence of instructions, a 'program', although not (necessarily) written in BASIC. These instructions should be saved into flash and executed when appropriate, for example, on next power-up unless certain serial port activity occurs. The target chip initially is a '170, although later I might try a '470, depending on I/O requirements. An alternate method might be to save these instructions into an external non-volatile memory chip, likely a FRAM that others have had good success with. However, first I wanted to try to keep everything internal to the PIC32 chip if possible. Thoughts, ideas and suggestions? Thanks! Visit Vegipete's *Mite Library for cool programs. |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2442 |
there are existing commands for this: VAR SAVE var [, var]... VAR RESTORE VAR CLEAR these are limited to 2k (MX170) or 4k (MX470) of storage space. however, your posting did give me a couple of ideas: 1. what if saved variables were stored in flash at the end of the basic program? this would mean that the amount of space available would be limited only by free flash. the down side would be that editing a program would wipe the saved variables, unless... what if these saved variables, upon loading an mmbasic program into memory, were translated into lines of code at the end of the basic listing. for instance: FLASH foo$="abc" FLASH bar=1234 upon saving the program, the FLASH statements would be translated back into a block of saved variable data. this would have the added advantage that you could edit a program and change the current values of the saved variables. 2. alternatively... what if the statement: FLASH varname = value completely replaced the existing VAR SAVE, RESTORE and CLEAR commands? any variable declared with a FLASH statement would permanently reside in flash; reads would come from flash, writes would cause the block of flash containing the variable to be rewritten, with the one limitation that a variable (like a string) could not grow or shring in size. FLASH statements could appear anywhere in the code, but would need to occur befor the named variable was first accessed. the user would also need to be careful to not perform excessive writes to a variable declared as FLASH. cheers, rob :-) |
||||
paceman Guru ![]() Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Pete, if you start with the MX470/MM+ then you can use an SD card for the storage. Your 'program' would simply be written to it as a text file and APPENDED as your input progressed. Then read the file back to your 'interpreter' as you want. Greg |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
The VAR commands are an excellent starting point. Thank you! I didn't spot them, or perhaps appreciate their purpose, while browsing the user manual. An SD card is a good idea but may be too delicate for my purposes. I will keep it in mind though for testing. Grogster's Explore 64 will make a good platform for my experiments. Thanks! Visit Vegipete's *Mite Library for cool programs. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |