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

how to use sd_flash_write? SDK13

I want to write at the end of memory ROM data in address 0x7FFFF

uint8_t tst_arr[1] = {6};
sd_flash_write((uint32_t*)0x7FFFF, (uint32_t*) &tst_arr, 1);

Is it correct?

But if I made it, in a memory watch I can't see any changes from 0xFF to my data (6).

Parents
  • No you cannot do it like this, flash writes should be 32-bit aligned. So if you want to write 8-bits to address 0x7FFFF then you should read 24-bits from address 0x7FFFC, concatenate it with your 8-bits and write resulting 32-bits back to address 0x7FFFC. Alternatively you can skip reading and put 0xFFFFFF at the beginning if you are sure that flash is erased before your write (or if you simply don't care about these preceding 3 bytes).

  • Oh no, never place nrf_delay_xxx anywhere in the code beside when you really want to have busy loop, it's occupying the MCU and so nothing else can run. First of all sd_flash_write is returning some uint32_t response code. You are not reading it so you should change that and check its NRF_SUCCESS. Print it to debug printout or something similar. To use all this you need to have several things in place like enabling Soft Device etc. Hard to say when not seeing the rest of the code. But in general the way forward is to do more debug on your side not pasting more code here to the forum...

Reply
  • Oh no, never place nrf_delay_xxx anywhere in the code beside when you really want to have busy loop, it's occupying the MCU and so nothing else can run. First of all sd_flash_write is returning some uint32_t response code. You are not reading it so you should change that and check its NRF_SUCCESS. Print it to debug printout or something similar. To use all this you need to have several things in place like enabling Soft Device etc. Hard to say when not seeing the rest of the code. But in general the way forward is to do more debug on your side not pasting more code here to the forum...

Children
Related