write and read FLASH SAMD21

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

 

I have a problem with writing and reading the Flash memory with the nonvolatile memory controller (NVMCTRL) of the SAMD21.

I created an ATMEL Start project and included the FLASH driver (with default values).

 

When using the example code FLASH0_example() which first writes some data to the flash address 0x3200 and then reads it back (utilizing the flash_read function) from the same address, the data is written to the flash, but then it hungs up on the flash_read function.

Stepping into the code it seems, that it hungs up in the following line of code:
 

while (!hri_nvmctrl_get_interrupt_READY_bit(device->hw)) {
        /* Wait until this module isn't busy */
    }

 

The implementation of the function is as follows:

 

static inline bool hri_nvmctrl_get_interrupt_READY_bit(const void *const hw)
{
    return (((Nvmctrl *)hw)->INTFLAG.reg & NVMCTRL_INTFLAG_READY) >> NVMCTRL_INTFLAG_READY_Pos;
}

 

But when reading out the INTFLAG.READY bit directly, it reads to 1:

while(NVMCTRL->INTFLAG.bit.READY == 0){}

 

So my question is: What is the function hri_nvmctrl_get_interrupt_READY_bit doing and what could be the reason, that the nvmctrl seems to be busy?
 

Thanks for your help!

Last Edited: Thu. Nov 28, 2019 - 11:50 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Update: it works if I write only one character to the flash.

In the example a whole page is written.