Commit ff45243f authored by deroo's avatar deroo
Browse files

update README for new declaration macros

parent a0df4406
......@@ -54,11 +54,27 @@ Or, compile and take the number of bytes
in "Sketch uses NNNN bytes (X%) of program storage space..."
and divide by 4096, rounding up.
Declare arrays in flash using pointers:<br>
datatype *arrayInFlash = (datatype *)flashAddress;<br>
Declare arrays in flash using a macro:<br>
NANO33BLE_FLASH( <datatype>, MarrayName>, <numberOfArrayElements> )<br>
such as
NANO33BLE_FLASH( int, arrayInFlash, 200 )
to create an array named "arrayInFlash" of 200 ints.
The order of the three arguments is meant to match the order of arguments for declaring an array in RAM, which is:<br>
<datatype> <arrayName>[<numberOfArrayElements>];<br>
int arrayInRAM[200];
to make a same-sized array of ints in RAM.
The macro sequentially packs the arrays in from the top of the available flash memory, reaching down as far as it needs to go.
The lowest flash page that is partially or fully occupied with your arrays is given by the macro NANO33BLE_FLASH_LOWEST_PAGE.
Thus, if you need to erase all the pages your sketch is using in order to initialize them, loop with a for loop from NANO33BLE_FLASH_LOWEST_PAGE to flashNumberOfPages, erasing each page as you go.
If you want more control over the details of the declarations in flash,
declare arrays in flash using pointers:<br>
<datatype> *<arrayInFlash> = (<datatype> *)<flashAddress>;<br>
where the flashAddress is the number of bytes into the flash memory.
for example,<br>
For example,<br>
int *intsInFlash = (int *)(flashNumberOfPages-2)*flashBytesPerPage;<br>
to use the last two flash pages as an array of ints.
Since the size of flash word is the same as sizeof(int) on the Nano 33 BLE,
......@@ -66,4 +82,4 @@ the maximum index is the number of words on two pages, or 2048.
Note: you have to keep track of which array is where,
and take care not to walk off the end of your array into another one.
Fortunately, past the end of the sketch, it's all available to use.
Fortunately, past the end of the sketch, it's all available to use.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment