erasing a sector with/without flash interrupt cause the system hung.
Dear Sir/Madam:
I try to use write and erase a sector with interrupt enable.
writing interrupt work , but erase interrupt does not work and cause the system reset after hunging for a while
the reason I use interrupt, is to avoid the erase holding system too long .
here are my setting.
....
NVIC_EnableIrq(NVIC_FLASH);
...
- working for writing data to sector works
the interrupt work
if (!FLASH_SR_bit.BSY)
{
FLASH_UNLOCK();
fl8Data = (uint8_t*)data;
fl8Addr = (uint8_t*)addr;
// for 8 bytes write
if (FLASH_IS_UNLOCKED())
{
/*Set the programming bit*/
FLASH_CR_bit.MER = false;
FLASH_CR_bit.SER = false;
FLASH_CR_bit.PSIZE = 0;
FLASH_CR_bit.EOPIE = 1; // operation done interrupt
FLASH_CR_bit.ERRIE = 1; // ERROR INTERRUPT
*fl8Addr = *fl8Data;
FLASH_CR_bit.PG = true;
FLASH_LOCK();
}
}
2 erase with/wihtout interrupt , does not work.
if(!FLASH_SR_bit.BSY)
{
FLASH_UNLOCK();
if (FLASH_IS_UNLOCKED())
{
FLASH_CR_bit.PG = false;
FLASH_CR_bit.MER = false;
FLASH_CR_bit.EOPIE = 1; // operation done interrupt
FLASH_CR_bit.ERRIE = 1; // ERROR INTERRUPT
FLASH_CR_bit.SER = true;
FLASH_CR_bit.SNB = 5; // any kinds of sector does not work
FLASH_CR_bit.STRT = true;
retval = true;
FLASH_LOCK();
}
}
in erase case, both interrupt and no interrupt do not work , and system reset after the system hung there for a while
my questions
does erasing sector work like this way, or my setting is not correct?
thanks
rose
