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

Flash write

Hello,

I'm trying to write value to a specified address with ble_flash_page_write .

I'm using ble_flash_page_write after ble disconnect event. I've tested different page address to be sure i'm not writing on application or s110 areas and page address are multiples of 4.

At execution, an Hard fault occur at the ble_flash_page_write line... Any idea about this error ? Is there others solutions to write values to a precise flash address ?

int32_t page = 200;
uint8_t word_count = 1;
uint32_t data_array[2]={0x81ABACAB};
data_array[1] = 0x81ABACAB;
		
err_code = ble_flash_page_write(page,(uint32_t *) &data_array,1);
APP_ERROR_CHECK(err_code);
Parents
  • Hi Thomas,

    Are you calling ble_flash_page_write() when you are in a connection (connected to a peer)? That could be a reason for hardfault. You can either call this API when not in a connection (if that suits your usecase). Or you can use the API ble_flash_word_write instead. (This assumes that the Flash location to be written has been erased previously)

    It is recommended that you use the 'Persistent Storage Interface' (pstorage.h) instead of the 'Flash Manager' (ble_flash.h) to perform flash related operations. It has been added to the nRF51 SDK sicne version 5.0.0. It helps in handling asynchronous flash memory access without the application needing to know whether the radio is active (connected to the peer).

    Cheers, Balaji

Reply
  • Hi Thomas,

    Are you calling ble_flash_page_write() when you are in a connection (connected to a peer)? That could be a reason for hardfault. You can either call this API when not in a connection (if that suits your usecase). Or you can use the API ble_flash_word_write instead. (This assumes that the Flash location to be written has been erased previously)

    It is recommended that you use the 'Persistent Storage Interface' (pstorage.h) instead of the 'Flash Manager' (ble_flash.h) to perform flash related operations. It has been added to the nRF51 SDK sicne version 5.0.0. It helps in handling asynchronous flash memory access without the application needing to know whether the radio is active (connected to the peer).

    Cheers, Balaji

Children
No Data
Related