Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:00 01 Aug 2025 Privacy Policy
Jump to

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 : Micromite - Save Data

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 06:24pm 27 Nov 2016
Copy link to clipboard 
Print this post

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 Zealand
Posts: 2442
Posted: 07:05pm 27 Nov 2016
Copy link to clipboard 
Print this post

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 :-)Edited by robert.rozee 2016-11-29
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 07:25pm 27 Nov 2016
Copy link to clipboard 
Print this post

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: Canada
Posts: 1132
Posted: 09:05pm 27 Nov 2016
Copy link to clipboard 
Print this post

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.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025