ASF4 Writing User Row to set up BOD33

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I'm using the SAMD51N20A processor in a project and I wish to implement a function that checks if the BOD33 fuse bits are set up correctly and if not than it loads some predefined default values back. I checked the datasheet and found that the NVM User Page is stored at address 0x00804000 and the fuse bits are located in the first 32 bytes. I wish to implement the following logic:


1. Read the User Page to a uint8_t buffer

2. Compare the buffer content with the predefined default values

3. Change the bits corresponding to the BOD33

4. Write back the changes to NVM (if there were changes)

5. Restart the device to load the correct BOD33 settings


I'm using Atmel START/ASF4 framework and I found the flash driver that can read and write to NVM which could be used but I also found user_page specific internal functions in the hpl_nvmctrl.c header files. 


int32_t _user_area_read(const void *base, const uint32_t offset, uint8_t *buf, uint32_t size)

uint32_t _user_area_read_bits(const void *base, const uint32_t bit_offset, const uint8_t n_bits)


static int32_t _user_row_write_exec(const uint32_t *_row)

int32_t _user_area_write(void *base, const uint32_t offset, const uint8_t *buf, const uint32_t size)


int32_t _user_area_write_bits(void *base, const uint32_t bit_offset, const uint32_t bits, const uint8_t n_bits)


I'm not sure which of these I should use, since I couldn't find any documentation regarding these functions.


What should I use as *base, bit_offset, bits & n_bits paramteres?

Is the base #define _NVM_USER_ROW_BASE 0x804000?


Thanks for your help!