Hi, I am a bit confused from the example, in the specs it is said that writing the flash is word allign, and even so the example does something strange:
do
{
NRF_LOG_INFO("Enter char to write to flash\r\n");
NRF_LOG_FLUSH();
// Read char from uart, and write it to flash:
patwr = NRF_LOG_GETCHAR();
if (patold != patwr)
{
patold = patwr;
flash_word_write(addr, (uint32_t)patwr);
++addr;
i += sizeof(patwr);
NRF_LOG_INFO("'%c' was written to flash\r\n", patwr);
}
// Read from flash the last written data and send it back:
patrd = (uint8_t)*(addr - 1);
NRF_LOG_INFO("'%c' was read from flash\r\n\r\n", patrd);
NRF_LOG_FLUSH();
}
while (i < pg_size);
every iteration i is incremented by sizeof(patwr), which is 8 and not 32, and addr is incremented by 32(++addr) which can result in an overflow.
Did I miss anything and it should work fine?