Hello,
I'm having trouble with my flash bank clear subroutine.
I always delete the same memory bank when starting program execution or after a reset.
Normally it works fine, but sometimes the BUSY flag stays active and does not exit the subroutine.
This is my subroutine.
void cmdFlash_BankErase(uint8_t * flashAddress){
SFRIE1 &= ~WDTIE; // Disnable WDT interrupt
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
do {} while(FCTL3 & BUSY); // Wait for !BUSY
FCTL3 = FWKEY; // Clear Lock bit
FCTL1 = FWKEY|MERAS; // Set Erase bit for segment erase
* flashAddress = 0; // Dummy write to erase Flash seg
do {} while(FCTL3 & BUSY); // Wait for !BUSY
FCTL3 = FWKEY|LOCK; // Set LOCK bit
SFRIE1 |= WDTIE; // Enable WDT interrupt
}
I am doing something wrong?. What can be the cause of this error?
I could leave WDT active with a long time (severals minutes), so that in normal operation it does not affect erasing Flash and if the erasing process fail, the micro Flash can recover?
Regards,