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:闪存写入卡住问题

Guru**** 2378980 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1055781/msp430i2040-flash-write-stuck-issue

器件型号: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(); 
}

下面是闪存部分的代码、更改后的数据在运行到19行时被擦除。 当运行到第29行时、将被写入闪存的数据已经被写入。 但是、当继续运行到32行、然后单击下一步时、芯片会直接卡住。 仿真时、IAR 也会卡住。

写入的地址为0xFC00、客户代码的这一部分没有被占用。

您能否帮助检查原因是什么? 谢谢。

此致、

樱桃