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

Save a single byte onn flash is it possible?

Hi all,

I am trying to save an UART variable I am receiving. My case is very similar to the example Flash Write Example, but I would write few bytes instead of the whole flash page it is possible?

My application uses a nRF52 and requires SDk13

Thanks

Parents
  • Sure, you can write single word (32 bits) into the flash. Just make sure it's "empty" (= 0xFFFFFFFF aka all bits set to 1) before writing otherwise your write will probably result into wrong data (flash technology cannot change 0 bits to 1 unless you erase whole page). This is one of main added values of all the pstorage/fstorage/FDS libraries, they should manage page erase, backup etc. so you do just "logical" operations and leave dealing with "physical" addressing to lower layer functions and module logic.

  • What do you mean by "I was using the UICR for the task"? That is NVM region but with specific restrictions, you can basically just write one-time into few registers. For that classic routine should be used (as for any direct work with registers!): read out full 32-bit value, mask the bits you are modifying merge it with new value you want to push in. Then simply set the register (pointer to register 32-bit address in continuous address space of the chip) to new value and you are done. Or you meant UART not UICR? I'm confused.

Reply
  • What do you mean by "I was using the UICR for the task"? That is NVM region but with specific restrictions, you can basically just write one-time into few registers. For that classic routine should be used (as for any direct work with registers!): read out full 32-bit value, mask the bits you are modifying merge it with new value you want to push in. Then simply set the register (pointer to register 32-bit address in continuous address space of the chip) to new value and you are done. Or you meant UART not UICR? I'm confused.

Children
No Data
Related