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.

MSP430I2020: MCU can't be reset

Part Number: MSP430I2020

Hi,

I made a mistake for flash write and then MCU can't be reset.

I may erase some important value, so MCU can't be reset.

I can load new program to MCU by CCS.

But it can't work anymore.

If I run debug by CCS, it can't run and pause.

Could you help to rescue this MCU?

#define FLASH_INFO_START 0x1060
#define MAX_FLASH_INFO   928
#define FLASH_INFO_SIZE sizeof(Flash_I)


#define SIZE_OF_TYPE_NOT_LARGE(type,size) extern char _VerifySize##type[1/(size>sizeof(type))]
#define SIZE_OF_TYPE_IS_MULT_OF(type,size) extern char _VerifySize##type[1/((sizeof(type)%size)==0)]

/* check if struct <= MAX_FLASH_INFO*/
SIZE_OF_TYPE_NOT_LARGE(Flash_I,MAX_FLASH_INFO);
SIZE_OF_TYPE_IS_MULT_OF(Flash_I,2);
#define CheckSegLock()  (FCTL3 & LOCKSEG)
#define ChangeSegLock() FCTL3 = FWKEY | LOCKSEG
#define EnWriteFlash()  FCTL1 = FWKEY | SEGWRT
#define EnSegEraseFlash()  FCTL1 = FWKEY | ERASE
#define EraseSegFlash()  FlashP[0]=0
#define DisWriteFlash() FCTL1 = FWKEY
//#define InitFram() FramDisWPROT()
__always_inline static void InitFlash()
{
    FCTL2 = FWKEY | FSSEL_1 | FN1 | FN3 | FN5;
}
__always_inline static void ClrSegLock()
{
    if (CheckSegLock())
        ChangeSegLock();
}
void FlashWriteAll (void)
{
    uint16_t i;
    uint8_t *FlashP;

    FlashP = (uint8_t *)(&Flash_IP);
    ClrSegLock();
   // EnSegEraseFlash();
    //EraseSegFlash();
    //FlashReadAll();
    EnWriteFlash();
    for(i=0;i<FLASH_INFO_SIZE;i++)
        FlashP[i]=FlashBuf[i];
    DisWriteFlash();
    ChangeSegLock();
}

**Attention** This is a public forum