Hi,
I try to write some data into the flash memory, but I always get a hardfault when I try to use the write function provided from the examples:
uint32_t nrf_flash_write(uint32_t * p_dst, const uint32_t* p_src, uint32_t size) { if (!IS_WORD_ALIGNED(p_dst) || !IS_WORD_ALIGNED(p_src)) { return NRF_ERROR_INVALID_ADDR; } if (size == 0 || !IS_WORD_ALIGNED(size)) { return NRF_ERROR_INVALID_LENGTH; } #if !defined(HOST) size /= WORD_SIZE; /* Turn on flash write enable and wait until the NVMC is ready: */ NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos); wait_for_ready(); while (size--) { if (*p_src != FLASH_BLANK_WORD) { *p_dst = *p_src; wait_for_ready(); } p_dst++; p_src++; } /* Turn off flash write enable and wait until the NVMC is ready: */ NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos); wait_for_ready(); #else memcpy(p_dst, p_src, size); #endif return NRF_SUCCESS; }
No I think this is because of the softdevice, that is stopped for an amount of time. There is also a mesh_flah.c available, but I don't see any functions for writing to the flash. What I actually need is some functionality, such that I can write a uint8_t array with specific length to the flash and then read it again.