Other Parts Discussed in Thread: MSP430WARE
Hello,
So I have been observing this strange behavior where I try to write to the flash but immediately after writing it would cause a reset. After further investigation, we found in one of the forums that "CPU instructions cannot be executed during flash writes". We concluded that even though we stop the WDT there needs to be a wait before Erase bit is set for what we assume is allowing execution of the command to turn off the WDT to finish in its entirety. This was not documented anywhere in the examples we looked through. We were wondering if this is an expected behavior or if there is another underlying issue. We are using MSP430ware_3_80_14_01. The snippet of code below is how we were writing to flash.
WDTCTL = WDTPW + WDTHOLD; // Wait inserted here FCTL1 = FWKEY + ERASE; // Set Erase bit FCTL3 = FWKEY; // Clear Lock bit dest[0] = 0; // Dummy write to erase Flash segment FCTL1 = FWKEY + WRT; // Set WRT bit for write operation for (uint8_t i=0; i<size; i++) { *dest++ = *settings++; } FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCK; // Set LOCK bit WDTCTL = WDT_ARST_1000;