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.

MSP430F5529通过USB和UART进行BSL擦除存储区的代码时,段擦除、块擦除、全部擦除的问题?

Other Parts Discussed in Thread: MSP430F5529

各位老师:大家好!

        我在进行MSP430F5529的BSL代码修改时遇到了一些问题。在解锁BSL会默认进行除BSL代码段及information段的所有代码的擦除,现在修改BSL源代码,在输入错误BSL密码后,不希望全部擦除main memory存储区的部分代码,采用按段擦除,在usb模式下可行,在uart模式下却必须进行整体擦除才可行。是否usb和uart模式下在输入错误密码擦除时存在其他问题?还有,在函数中block_erase==1时进行块擦除也无法实现块擦除,是否按地址擦除代码存在问题?谢谢!!!

代码如下:芯片选型5529

//0--3 usb_ram;4--19 ram;20--147 main memory bank a and b; 148--211 bank c; 212--275 bank d;

      long addre=0x1c00;

      for(int mm=0;mm<148;mm++)  //276

      {

        BSL430_eraseLocation(0, addre);//usb ram ~~bank b

        addre=addre+512;

      }

 

 

char BSL430_eraseLocation(char block_erase, unsigned long addr)

{

    char exceptions;

 

    if (LockedStatus == UNLOCKED || 0 == earseflash)

    {

        exceptions = SUCCESSFUL_OPERATION;

     

#ifdef RAM_BASED_BSL

        while (FCTL3 & BUSY) ;

#endif

        FCTL3 = FwRamKey;                       // Clear Lock bit

        if(0==block_erase)

          FCTL1 = FwRamKey + ERASE;               // Set Erase bit

        else

          FCTL1 = FwRamKey + MERAS;               // Set Erase bit

       

        __data20_write_char(addr, 0);           // Dummy write to erase Flash seg

#ifdef RAM_BASED_BSL

        while (FCTL3 & BUSY) ;

#endif

        FCTL3 = FwRamKey + LOCK;                // Set LOCK bit

    }

    else

    {

        exceptions = BSL_LOCKED;

    }

    return exceptions;

}