I am Currently developing with the TWR-KW24D512 evaluation board. I am trying to write to flash memory to save important variables that I collect when the code first starts. The reason for this is right now I am testing with low power modes that act as a reset when it wakes from low power mode. I don't want to have to run through the beginning of my code that initializes those variables because it is very time consuming.
Right now the variables are being saved to ram, but when the processor goes into low power mode, the ram gets reset and all of my variables are lost. My thought to fix this is to declare space in the flash and then save the variables there and then just retrieve them after the processor wakes from low power mode.
Would anyone know the best way to start saving variables to flash? Or would anyone be able to point me to a document that explains how to write to flash?
BeeStack projects with NVM module enabled will save all network data when Idle task is executed and same data is restored after wakeup. You will find a NVM driver in the project files form BeeKit (NVM_Interface, NV_Flash.c, etc.). You may use this driver as reference to save custom data in flash sectors, but any modification or custom implementation is application specific.