Commit a6eeaf07 authored by deroo's avatar deroo
Browse files

fix typos in README

parent f7eb2f00
......@@ -76,17 +76,26 @@ The array macro NANO33BLE_PUT_ARRAY_IN_FLASH must be inside a function, because
The array macro NANO33BLE_PUT_ARRAY_IN_FLASH does not initialize or otherwise modify the contents of the array. It just makes the sketch look in the correct place in flash memory when it encounters future references to the array.
The macro sequentially packs the arrays in from the top of the available flash memory, reaching down as far as it needs to go.
It does not check for any collisions with the sketch or bootloader, which start at the bottom of flash, but it'd have to be a pretty big array and/or sketch for a collision to occur.
It does not check for any collisions with the sketch or bootloader, which start at the bottom of flash, but it'd have to be a pretty big array and/or sketch for a collision to occur. Simply locating an array over the sketch or in the bootloader is not damaging, fortunately. The flashErasePage() function does check if the page number is too low, to prevent bricking of your Arduino.
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.
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, like this:
int page;
for (page=NANO33BLE_FLASH_LOWEST_PAGE;page<flashNumberOfPages;page++){
flashMode(FLASH_ERASE);
flashErasePage(page);
flashMode(FLASH_READONLY);
}
You do not necessarily want to always erase the flash memory on start up,
as doing so defeats the non-volatility property of flash.
Valid datatypes for arrays in flash using this library include structs and typedefs, in addition to the predefined C datatypes. Structs appear to default to multiples of flash words, so the programmer's attention to alignment issues does not appear to be neccessary.
Some limitations: the sizeof operator on any array in flash will always return 4 (=flashBytesPerWord). Also, C string functions like strcpy and strlen do not always work as one would expect to manipulate the arrays in flash, 'tho memcpy and strcpy do work to copy the contents out of flash, and memcpy does work to copy into flash if the number of bytes is a multple of flashBytesPerWord. I recommend using macros (ie. #define) or variables to declare the number of array elements as the sketch cannot easily figure out by itself how big a flash array has been declared after the declaration.
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>
declare arrays in flash using pointers:
\<datatype\> *\<arrayInFlash\> = ( \<datatype\> *)\<flashAddress\>;
where the flashAddress is the number of bytes into the flash memory.
This form of the statement does both tasks listed separately above:
it declares the array, defines its scope, and locates it.
......
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