Might be a silly question... Is there any EEPROM on the Nano 33 BLE ?
If so, how to use it ?
There is not, but you can use a part of the flash inside the microcontroller. I searched quite some time as well, resulting in deep diving into the underlying Mbed OS which facilitates a sort of filesystem and has the so-called KvStore. I use it to do some Config file type style settings, and seems to work quite well, at least for what I started with right now.
https://os.mbed.com/docs/mbed-os/v6.1/apis/kvstore.html
Examples KvStore usage
My current code (under development);
#include <mbed.h>
#include <KVStore.h>
#include <kvstore_global_api.h>
....
// NVMEM keys and strings
static char KvBuf [40];
static char CheckValidStr[] = "55AA";
....
// *****************************************************************************
// NVMEM routines to read/write the configuration to/from non volatile memory
// *****************************************************************************
static void nvmemGetConfig()
{
int16_t res;
int16_t i;
int32_t templ;
size_t actualSize;
res = kv_get("/kv/check_valid", KvBuf, sizeof(KvBuf), &actualSize);
Serial.println (KvBuf);
if (res != MBED_SUCCESS)
{
// Reset the nvmem storage when not yet initialized
res = kv_reset("/kv/");
Serial.println("KV: Could not get check_valid");
res = kv_set("/kv/check_valid", CheckValidStr, strlen(CheckValidStr), 0);
res = kv_set("/kv/cal_offset", "0", 2, 0);
}
else if (strcmp(KvBuf, CheckValidStr) == 0)
{
Serial.println("KV: store is valid");
res = kv_get("/kv/cal_offset", KvBuf, sizeof(KvBuf), &actualSize);
Hx711SensorOffset = atol(KvBuf);
sprintf(PrintBuf, "Hx711SensorOffset = %d", Hx711SensorOffset);
Serial.println(PrintBuf);
}
}
As the frequency of writes that I intend for this non volatile memory is high, I will investigate the possibility to keep RAM On, when in System Off, using the RAMn.POWER control registers.