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 示例时、内部信息闪存写入失败

Guru**** 2768525 points

Other Parts Discussed in Thread: MSP430F5529

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1037522/msp430f5529-internal-info-flash-write-failed-when-using-usb-example

器件型号:MSP430F5529

您好!

我正在尝试从 MSP430F5529上的 Info D 内部闪存区域读取/写入数据。

当使用 MSP430F55xx_flashwrite_02.c 示例时、它运行良好、但当我使用 USB 示例(C1_LedOnOff)时、它似乎不起作用。

我正在使用 C1_LedOnOff 示例、初始代码为以下附加代码(用于调试):

void main (void)
{
    WDT_A_hold(WDT_A_BASE); // Stop watchdog timer

    unsigned long * Flash_ptrD;               // Initialize Flash pointer Seg D
    unsigned long FlashTmp;

    Flash_ptrD = (unsigned long *) 0x1800;    // Initialize Flash pointer
    FlashTmp = *Flash_ptrD;                       // Initialize Value
    FlashTmp++;
    FCTL3 = FWKEY;                            // Clear Lock bit
    FCTL1 = FWKEY+ERASE;                      // Set Erase bit
    *Flash_ptrD = 0;                          // Dummy write to erase Flash seg
    FCTL1 = FWKEY+BLKWRT;                     // Enable long-word write
    *Flash_ptrD = FlashTmp;                      // Write to Flash
    FCTL1 = FWKEY;                            // Clear WRT bit
    FCTL3 = FWKEY+LOCK;                       // Set LOCK bit
    while(1);                                 // Loop forever, SET BREAKPOINT HERE

    // Minumum Vcore setting required for the USB API is PMM_CORE_LEVEL_2 .
    PMM_setVCore(PMM_CORE_LEVEL_2);
    USBHAL_initPorts();           // Config GPIOS for low-power (output low)
    USBHAL_initClocks(8000000);   // Config clocks. MCLK=SMCLK=FLL=8MHz; ACLK=REFO=32kHz
    initTimer();           // Prepare timer for LED toggling
    USB_setup(TRUE, TRUE); // Init USB & events; if a host is present, connect

    __enable_interrupt();  // Enable interrupts globally
    
    while (1)
    {
        ...

使用 USB 示例时、是否有锁定闪存信息区域的内容?

谢谢、

Itay

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

    您好、Itay、

    该程序对我来说看起来很好。  段 A 有一个单独的锁定位、但段 D 不存在该锁定位。 我看不到 USB 软件在使用 USB 示例时可以/应该锁定闪存的任何机制。   

    你到底是怎么做的? 您导入了一个 USB 示例、基本上复制了 Flashwrite_02.c 示例、但它的工作方式不同?   

    谢谢、

    JD

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

    您好!

    正确。 这正是我所做的。

    我认为它与 USB 中断机制相关、但是当我在激活 USB 之前尝试写入闪存事件时、写入操作失败(只是没有写入操作完成)。

    谢谢、

    Itay

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

    JD、您好!

    您是否认为您可以尝试重现此情况并帮助解决此问题?

    非常感谢、

    Itay

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

    成功解决了这个问题。

    只需向  虚拟写入添加(unsigned int *)即可擦除闪存段:

    void main (void)
    {
        WDT_A_hold(WDT_A_BASE); // Stop watchdog timer
    
        unsigned long * Flash_ptrD;               // Initialize Flash pointer Seg D
        unsigned long FlashTmp;
    
        Flash_ptrD = (unsigned long *) 0x1800;    // Initialize Flash pointer
        FlashTmp = *Flash_ptrD;                       // Initialize Value
        FlashTmp++;
        FCTL3 = FWKEY;                            // Clear Lock bit
        FCTL1 = FWKEY+ERASE;                      // Set Erase bit
        *(unsigned int *)Flash_ptrD = 0;                          // Dummy write to erase Flash seg
        FCTL1 = FWKEY+BLKWRT;                     // Enable long-word write
        *Flash_ptrD = FlashTmp;                      // Write to Flash
        FCTL1 = FWKEY;                            // Clear WRT bit
        FCTL3 = FWKEY+LOCK;                       // Set LOCK bit
        while(1);                                 // Loop forever, SET BREAKPOINT HERE
    
        // Minumum Vcore setting required for the USB API is PMM_CORE_LEVEL_2 .
        PMM_setVCore(PMM_CORE_LEVEL_2);
        USBHAL_initPorts();           // Config GPIOS for low-power (output low)
        USBHAL_initClocks(8000000);   // Config clocks. MCLK=SMCLK=FLL=8MHz; ACLK=REFO=32kHz
        initTimer();           // Prepare timer for LED toggling
        USB_setup(TRUE, TRUE); // Init USB & events; if a host is present, connect
    
        __enable_interrupt();  // Enable interrupts globally
        
        while (1)
        {
            ...