Hi team,
void Flash_Write(void) { int16 *data_ptr; uint16 *Flash_ptr; uint8 i; __disable_interrupt(); Flash_ptr = (uint16 *)Flash_default; data_ptr = &product_info.vref_ad_zero; if(FCTL3 & LOCK) FCTL3 = FWKEY | LOCK; //信息段解锁 FCTL3 = FWKEY; // Clear Lock bit FCTL1 = FWKEY + ERASE; // Set Erase bit *Flash_ptr = 0; // Dummy write to erase Flash segment FCTL3 = FWKEY; FCTL1 = FWKEY + WRT; for (i = 0; i < CHECK_P_NUM; i++) { while((FCTL3 & BUSY) == BUSY); //Wait Busy *Flash_ptr++ = *data_ptr++; // Write value to flash } FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY | LOCK; // Set LOCKSEG bit __enable_interrupt(); }
Below is the code for the flash section, and the changed data is erased when it runs to 19 lines. When running to line 29, the data to be written to flash has been written. But when continuing to run to 32 lines, and then click on the next step, the chip gets stuck directly. When simulated, the IAR will also be stuck.
The written address is 0xFC00, and this part of the customer's code is not occupied.
Could you help check what's the reason for that? Thanks.
Best Regards,
Cherry