This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to use sd_flash_protect()?

Hello,

What is he meaning of PROTENSET0, PROTENSET1 in sd_flash_protect()? How can I use this function to set WRITE PROTECT to a certain flash page? I searched a lot, but cannot find useful explanation. I found this: devzone.nordicsemi.com/.../ but I don't think it answers my question.

Can anyone give me an example code for using this function?

Thank you.

Jason

Parents
  • There is an explanation of the registers in section 9 of the nRF51_Series_Reference_manual_v3.0. Basically the two registers provide a set of bits that can be used to turn on write protection to the NVRAM. Each bit represents a 4K "page", which maps to 4 NVRAM pages. So, PROTENSET0.PROTREG0 is the first 4K of NVRAM, PROTENSET0.PROTREG1 is the second 4 K of NVRAM and so on. You need two PROTENSETx registers to cover the up to 256K of NVRAM on the nRF51 series.

    I don't have a code example, but I imagine it is error_code = sd_flash_protect(PROTENSET0_MASK, PROTENSET1_MASK);

    Where the mask values are determined by the pages you want to protect. Note from the documentation derived from the code, you cannot protect pages owned by the softdevice. Also, I don't think you can do one code page at a time, you must do blocks of 4 if I read and interpreted this correctly.

Reply
  • There is an explanation of the registers in section 9 of the nRF51_Series_Reference_manual_v3.0. Basically the two registers provide a set of bits that can be used to turn on write protection to the NVRAM. Each bit represents a 4K "page", which maps to 4 NVRAM pages. So, PROTENSET0.PROTREG0 is the first 4K of NVRAM, PROTENSET0.PROTREG1 is the second 4 K of NVRAM and so on. You need two PROTENSETx registers to cover the up to 256K of NVRAM on the nRF51 series.

    I don't have a code example, but I imagine it is error_code = sd_flash_protect(PROTENSET0_MASK, PROTENSET1_MASK);

    Where the mask values are determined by the pages you want to protect. Note from the documentation derived from the code, you cannot protect pages owned by the softdevice. Also, I don't think you can do one code page at a time, you must do blocks of 4 if I read and interpreted this correctly.

Children
No Data
Related