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.

[参考译文] TMS320F2800133:结构初始化/成员损坏 — TMS320F2800133

Guru**** 2953920 points

Other Parts Discussed in Thread: TMS320F2800133, LAUNCHXL-F2800137

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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1644009/tms320f2800133-struct-initialization-member-corruption---tms320f2800133

器件型号: TMS320F2800133
主题中讨论的其他器件: LAUNCHXL-F2800137

您好:  

我一直在使用 TMS320F2800133、并尝试测试 TI 提供的一些相关示例、但是我遇到了结构初始化问题、在 main 中声明结构成员时、结构成员无法正确初始化。 奇怪的是、当我将 main 之外的结构声明为全局变量时、成员被初始化成 corredy。 该代码正在针对闪存进行编译、但在针对 RAM 进行构建时、问题似乎得到解决。  

以下示例是 TI 为 f280013x 系列 MCU 提供的 led_ex1_blinky。 当闪存构建并刷写外部目标时、在 main 内声明结构初始化失败、并且成员初始化为 a =–1、b =–1、c =–1、这显然是不正确的。

//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include "c2000ware_libraries.h"

/*Example struct*/
typedef struct test_t
{
    int a; 
    int b;
    int c;
} test_t;

// Main
//
void main(void)
{

    /*Initization inside main*/
    test_t t = {1, 2, 3};

    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Disable pin locks and enable internal pull-ups.
    //
    Device_initGPIO();

    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    //
    Interrupt_initModule();

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    Interrupt_initVectorTable();

    //
    // PinMux and Peripheral Initialization
    //
    Board_init();

    //
    // C2000Ware Library initialization
    //
    C2000Ware_libraries_init();

    //
    // Enable Global Interrupt (INTM) and real time interrupt (DBGM)
    //
    EINT;
    ERTM;

    //
    // Loop Forever
    //
    for(;;)
    {
        //
        // Turn on LED
        //
        GPIO_writePin(myBoardLED0_GPIO, 0);

        //
        // Delay for a bit.
        //
        DEVICE_DELAY_US(500000);

        //
        // Turn off LED
        //
        GPIO_writePin(myBoardLED0_GPIO, 1);

        //
        // Delay for a bit.
        //
        DEVICE_DELAY_US(500000);
    }
}

//
// End of File
//
 
在 main 之外声明结构时、成员已正确初始化。
 

该示例首先刷写到定制设计的电路板上、现在已刷写到 LAUNCHXL-F2800137 LaunchPad 上、似乎 LaunchPad 上不再存在此问题。 TMS320F2800133 是否存在已知问题或是否有人遇到过类似的问题? 我已经查看了此 MCU 系列的 erata、似乎没有提到任何内容。

这很可能是 TMS320F2800133 之外的硬件问题、但有关可能的 MCU 硬件或软件问题的任何建议都将非常有用。  

谢谢!

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

    很抱歉晚才回复。 只需确认是否仍存在此问题。

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

    您好、Vivek、  

    感谢您回复我。 问题似乎已解决、解决方案是更改链接器文件以确保仅指定与 F2800133 相关的闪存组。 在发布此问题之前、我应该已经看过链接器文件的更改。 除了为闪存构建之外、这种变化也使我不再看到结构初始化的问题。

    谢谢、  

    Kai