Skip to content

Important notes on Library Usage

Prajwal Bhattaram edited this page Mar 8, 2018 · 2 revisions

Important notes on Library Usage

Address overflow

The library has Address overflow enabled by default - i.e. if the last address read/written from/to, in any function, is 0xFFFFF then, the next address read/written from/to is 0x00000. This can be disabled by uncommenting #define DISABLEOVERFLOW in SPIFlash.h.

Address overflow only works for Read / Write functions.

All Erase functions except eraseSection() erase only a set number of blocks/sectors irrespective of overflow.

Error checking

All write functions have Error checking turned on by default - i.e. every byte written to the flash memory will be checked against the data stored on the Arduino.

Users who require greater write speeds can disable this function by setting an optional last 'errorCheck' argument in any write function to NOERRCHK - For eg. call the function writeByte(address, *data_buffer, NOERRCHK) instead of writeByte(address, *data_buffer).

High speed mode

The library - by default - checks to see if the address being written to contains pre-existing data. If it finds pre-existing data, it throws the error 0x07 - PREVWRITTEN.

This prevents the write function from running as fast as it could.

If the user requires the library to operate at the highest speed possible, they must be sure that the user code:

  1. Makes sure that the flash memory chip does not contain any data.

  2. Erases the chip before writing to it.

  3. Keeps track of addressing and makes sure no two bytes of data are written to the same address.

And

  1. Tracks previously written sectors in their code and makes sure to erase them before writing new data to them.

Then, if #define HIGHSPEED is uncommented in SPIFlash.h before the user code is compiled and uploaded, the write functions will run as fast as the flash memory hardware will permit them to.

Please note that using a combination of the methods listed in High speed mode and Error checking will result in the highest possible write performance from the library. However, this will result in the highest probability of write errors as well.