This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430I2040: FLASH写入卡死问题

Part Number: MSP430I2040

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(); 
}
这是我写的flash部分的代码,当运行到19行这里的时候,改位置的数据被擦除了,当运行到第29行时,已经将我需要写的数据写到了flash中,但是当我继续运行,当运行到32行,然后再点下一步运行的时候,然后芯片就直接卡死了,在仿真的时候,会导致IAR也卡死