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

nRF52832 FLASH write issue

I want to write a piece of big data to flash.
Every time I write 112 word length, I write it many times.
Every time I write, the address is shifted back 112.
Before I write, I need to erase the pages that need to be written.
However, I find that only the first time I write successfully, but later I write unsuccessfully.
The API I use is sd_flash_write, what's the reason? thank you!

Parents
  • My code is as below:

    #define TEST_LEN    112
    #define WRITE_TIME    10
    void write_test(void)
    {
        uint8 ota_data[TEST_LEN] = {0};

        
        for(int i = 0; i < TEST_LEN; i++)
        {
            ota_data[i] = i;
        }

        for(int i = 0; i < WRITE_TIME; i ++)
        {
            sd_flash_write((uint32_t *)tag_ota_write_addr, (uint32_t *)ota_data, TEST_LEN);

            NRF_LOG_INFO("addr = 0x%x", tag_ota_write_addr);

            tag_ota_write_addr += TEST_LEN;

            nrf_delay_ms(200);
        }
    }

Reply
  • My code is as below:

    #define TEST_LEN    112
    #define WRITE_TIME    10
    void write_test(void)
    {
        uint8 ota_data[TEST_LEN] = {0};

        
        for(int i = 0; i < TEST_LEN; i++)
        {
            ota_data[i] = i;
        }

        for(int i = 0; i < WRITE_TIME; i ++)
        {
            sd_flash_write((uint32_t *)tag_ota_write_addr, (uint32_t *)ota_data, TEST_LEN);

            NRF_LOG_INFO("addr = 0x%x", tag_ota_write_addr);

            tag_ota_write_addr += TEST_LEN;

            nrf_delay_ms(200);
        }
    }

Children
Related