This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Write to FLASH after BLE init

I am working in sdk14 nrf52832 I want to write flash after BLE initializing ,but write flash it has no action

while(sd_flash_page_erase(64) != NRF_SUCCESS){} //address = 0x40000
while(sd_flash_write((uint32_t *)0x40000,(uint32_t *)&ptr,((sizeof(TypedefBle)+3)/4))){}
NVIC_SystemReset();
Parents
  • Hi,

    Putting the function call inside a loop won't guarantee that the flash operation is finished after the loop.

    As in the documentation of sd_flash_page_erase and sd_flash_write, you need to wait for the flash callback event :

    NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
    NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
    

    Before you proceed to the next command. If you want to reset after you write, you need to wait for the NRF_EVT_FLASH_OPERATION_SUCCESS callback event of the write command.

  • I register an application with fstorage.

    NRF_FSTORAGE_DEF(nrf_fstorage_t my_fs) = { .evt_handler = fs_event_handler, .start_addr = 0x00040000, .end_addr = 0x00041000, };

    But an error occurred when connected: case PM_EVT_PEER_DATA_UPDATE_FAILED: { // Assert. APP_ERROR_CHECK(p_evt->params.peer_data_update_failed.error); } break;

    error_code = NRF_ERROR_NULL ...

Reply Children
No Data
Related