So I’m positing a link to some code that does what you want, however, I worry that code like this may be a bit advanced for many student programmers. On the surface it’s pretty easy to use, under the hood this is probably some of the most complex ROBOTC code you will see.
I added the new functionality to the code I released last year to access the ROBOTC file system. The new functions allow you to store 32 user bytes in a page of flash at a high memory address. There are really only two functions that you need to use. Include the library at the top of your ROBOTC program.
All the source files will need to be in the same directory as your program as FlashLib.h includes other files.
To read the 32 user bytes, do the following.
// pointer to user parameters
// Read the user parameters
u = FlashUserRead();
The parameters can then be accessed in the “flash_user” structure as follows. The array index should be in the range 0 to 31, to access or store variables larger than one byte you will need to type cast.
int value1, value2;
value1 = u->data;
value2 = u->data;
To save the user bytes do the following.
FlashUserWrite( u );
you can check the return value to make sure the write was successful. Only 32 writes per cortex power cycle are allowed, this should be more than enough, most of the time you should only need to do one write.
if( FlashUserWrite( u ) )
displayLCDString(0, 0, "write ok ");
displayLCDString(0, 0, "write error ");
There is a small demo program included that shows how to use the above functions, it is called “flashUserDemo.c”. There is also an updated version on one of my LCD autonomous selection programs that I posted in this thread (the code for demo 2) ROBOTC LCD autonomous selection it’s called lcdAutonDemo_2_1.c
The github repo is here.