Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Level 1
Level 1
First like given

I am trying to store data using eflash incase the bluetooth connection drops, but since adding this when I hit the reset button nothing happens and I have to re-download the applicaiton.

1 Solution

Please try to use the NVRAM api such as wiced_hal_write_nvram() to write data. The api is located in wiced_hal_nvram.h file.

View solution in original post

5 Replies
500 solutions authored 250 sign-ins 1000 replies posted

Do you mean the reset pin can't reset the device? Could you give a snip code of your application?


Yeah I'm using the CYW920719Q40EVB-01 and normally I can just hit the reset button on the board to rerun the code that's currently downloaded, but whenever I call wiced_hal_eflash_erase or wiced_hal_eflash_erase_whole the program just stops running and doesn't start over. What I am trying to do is save the data to the flash in case the connection drops and then when we reset to reconnect the Bluetooth it transmits the data I stored and then clears the flash. All four of the data_on values are int16_t.  The while loop in the second part is set to 100 just for debugging.  There is data in it from 0-64 and after that its all 255 even after running the write.

here is the code for writing to flash:

void sensor_loop(uint32_t arg) {



        UINT16 data_on[4];

        data_on[0] = current.hr.on_out;

        data_on[1] = current.acc.tx;

        data_on[2] = current.acc.ty;

        data_on[3] =  current.acc.tz;//current.hr.on_out;

        int size = sizeof(data_on);

        char b[size];

        memset(b, 0x00, size);

        memcpy(b, &data_on, size);

        spp_tx_data( &data_on ,  size);

        wiced_hal_eflash_write(offset, b, size);

        offset += 16;

        WICED_BT_TRACE("offset: %d\n", offset);

Here is the code for reading and erasing:

void read_flash()



    oset = 0;

    //UINT16 check = 1;

    while(oset < 100){

        char c[8];

        memset(c, 0x0000000000000000, 8);

        WICED_BT_TRACE("eflash_read - c = 0: %d\r\n", *c);

        wiced_hal_eflash_read(oset, c, 8);

        WICED_BT_TRACE("eflash_read: %d %d %d %d %d %d %d %d\r\n", c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);

        WICED_BT_TRACE("eflash_read - oset: %d\r\n", oset);

        oset += 16;

        check = *c;

        WICED_BT_TRACE("CHECK: %d\r\n", check);


    UINT32 size1 = wiced_hal_eflash_get_size();

    WICED_BT_TRACE("SIZE: %d:\r\n", size1);

//    wiced_hal_eflash_erase(0,oset);





Please try to use the NVRAM api such as wiced_hal_write_nvram() to write data. The api is located in wiced_hal_nvram.h file.

Thank you.  I can read over the usb serial but now for the bluetooth it starts sending before the bluetooth connection is complete so I am not able to read.  Is there a way to delay without setting off the wiced_bt_app_start_timer()?  right now when I try to use the delay the code resets and starts trying to pair again.


Is this a new problem? Could you be more clear about your application?

If you use the delay, it could cause the watch dog reset. If you want to send data after connection, you can put the wiced_bt_app_start_timer() in the connection up event.