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.

[参考译文] TMS570LC4357:基于 ARM 的微控制器论坛

Guru**** 2465890 points
Other Parts Discussed in Thread: HALCOGEN, LAUNCHXL2-570LC43

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1105167/tms570lc4357-arm-based-microcontrollers-forum

器件型号:TMS570LC4357
主题中讨论的其他器件:HALCOGENLAUNCHXL2-570LC43

我有一个在 FreeRTOS v9上运行的 Hercules 安全开发套件。 我使用的是 Code Composer Studio v11和 HALCoGen v4。
我的程序在 printf()中挂起。 SCI 工作正常。 我包含了 stdio.h 库。 构建代码时不会出现任何问题。 由于我对这个平台很陌生、我肯定会错过一些东西。

下面给出了一个测试代码片段

#include "FreeRTOS.h"
#include "os_task.h"
#include "HL_sci.h"
#include "HL_het.h"
#include "HL_gio.h"
#include "stdio.h"
#include "HL_sys_common.h"

#define UART sciREG1
#define LENGTH 18

xTaskHandle xTas1kHandle, xTask2Handle;
uint8 TEXT[LENGTH] = {'B', 'u', 't', 't', 'o', 'n', ' ', 'i', 's', ' ', 'p', 'r', 'e', 's', 's', 'e', 'd', ' '};

void consolePrint(sciBASE_t *sci, uint8 *text, uint32 length){
    while(length--){
        while((sci->FLR & 0x4) == 4);
        sciSendByte(sci, *text++);
    }

}

void vTask1(void *pvParameters){
    for(;;){
        gioSetBit(hetPORT1, 0, (gioGetBit(hetPORT1, 0)^1));
        printf("Hello World\n\r"); //code hangs here
        vTaskDelay(100);
    }
}

void vTask2(void *pvParameters){
    for(;;){
        if((gioGetBit(gioPORTA, 7) == 0)){
        consolePrint(UART, &TEXT[0], LENGTH);
        vTaskDelay(100);
        }
    }
}

int main(void)
{
    sciInit();
    gioSetDirection(hetPORT1, 0xFFFFFFFF);
    gioSetDirection(gioPORTA, 0x00000000);

    if (xTaskCreate(vTask2, "Task 2", configMINIMAL_STACK_SIZE, NULL, 1, &xTask2Handle) != pdTRUE){
        while(1);
    }

    if (xTaskCreate(vTask1, "Task 1", configMINIMAL_STACK_SIZE, NULL, 1, &xTas1kHandle) != pdTRUE){
        consolePrint(UART, &TEXT[0], LENGTH);
    }

    vTaskStartScheduler();
    while(1);

    return 0;
}

有人能帮我解决这个问题吗? 任何建议均可获得采纳。

谢谢你。

此致
Ua

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

    你好,UA

    printf()采用较大的堆栈,请 从 HALCoGen GUI 调整 STACKSIZE:

    HalCoGen->RAM->UserStack

    您可以更改 sys_core.asm 中手动定义的堆栈大小:

    _coreInitStackPointer_

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [~ userid="45190" url="支持/微控制器/arm-based 微控制器组/arm-based 微控制器/f/arm-based 微控制器-forum/1105167/tms570lc4357-arm-based 微控制器-forum/4094438#4094438"]

    printf()采用较大的堆栈,请 通过 HALCoGen GUI 调整 STACKSIZE

    [/报价]

    printf()是从 FreeRTOS 任务内部调用的,因此不要认为调整 HALCoGen GUI 中的 STACKSIZE 会有所不同。

    假设这是 xTaskCreate 函数的第三个参数,需要增加该参数,以便为调用 printf()的任务提供更大的栈大小:

        if (xTaskCreate(vTask1, "Task 1", configMINIMAL_STACK_SIZE, NULL, 1, &xTas1kHandle) != pdTRUE){
            consolePrint(UART, &TEXT[0], LENGTH);
        }

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

    您好、UA、

    请使用 Chester 的方法来增加任务1的堆栈大小。

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

    我更改了该任务的堆栈大小。 它没有解决问题。  
    为了简化操作,我创建了一个项目,但 printf()除外。 我提供了足够的堆栈大小。 代码仍然挂起。

    #include "HL_sys_common.h"
    #include <stdio.h>
    
    int main(void)
    {
        sciInit();
        printf("hello world\n\r");
    
        return 0;
    }
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [引用 userid="522078" URL"~μ C/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forume/1105167/tms570lc4357-arm-based-microcontrollers-forume/4096805#4096805]*为了简化操作、我创建了一个项目(printf)。 [/报价]

    您在项目中使用哪种编译器?

    使用的编译器版本显示在 Compiler Selection 下的 CCS 工程属性中

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

    我使用的是 TI v20.2.6.LTS

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

    感谢王杰和 切斯特·吉隆的答复。 感谢你的帮助。
    我仍然卡在。 我可以使用 sciSend 和 sciByteSend 打印数据、而不会出现任何问题。 我的 sci 正在工作。  
    对此有任何建议吗?

    谢谢你。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [引用 userid="522078" URL"~μ C/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forume/1105167/tms570lc4357-arm-based-microcontrollers-forume/4096861#4096861"]我正在使用 TI v20.2.6.LTS [引用]

    我有   LAUNCHXL2-570LC43上运行的 github.com/.../TMS570LC4357_div_by_zero 示例。

    刚刚将工程更新为  TI v20.2.6.LTS 编译器、运行该工程时、printf()输出出现在 CCS 控制台上:

    不记得在创建项目时必须执行任何特定的操作才能使 printf()正常工作。

    您能否尝试该项目并查看 printf()是否适合您?

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

    我已经尝试了很长时间、但无法执行数据中止:

    int main (空)

       /*用户代码开始(3)*/
       sciInit();
       printf ("hello world\n"\});

       while (1){
           printf ("hello world 123\n"\});
       }

    请您详细介绍一下您的项目吗?  

    printf()函数是将字符打印到 CCS 控制台还是 UART 终端?  

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

    在我的测试中,printf()仅向 CCS 控制台输出字符串。

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

    我尝试了该示例。 它构建时没有任何问题、但无法在控制台上看到任何内容。

    为了测试我的 SCI、我尝试了以下代码、该代码工作正常。 我可以在串行终端中看到输出。

    int main(void)
    {
    /* USER CODE BEGIN (3) */
        sciInit();
        sciSend(sciREG1, 15, (unsigned char *)"Hello World! \r\n");
    /* USER CODE END */
    
        return 0;
    }
    


    非常感谢您的耐心 Chester Gillon。

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

    我没有尝试任何花哨的东西。 我刚刚启用了 HALCoGen 中的 SCI1驱动程序、并创建了 hello world 源代码。
    我想提一下、对 MCU 板进行编程后、控制台中显示了以下错误消息。  
    我使用的是 XDS100v2 USB 调试探针。

    CortexR5: GEL Output: 	Memory Map Setup for Flash @ Address 0x0CortexR5: GEL Output: 	Memory Map Setup for Flash @ Address 0x0 due to System Reset
    CortexR5: GEL Output: 	Memory Map Setup for Flash @ Address 0x0 due to System Reset
    Dap: Error: (Error -242 @ 0x0) A router subpath could not be accessed. The board configuration file is probably incorrect. (Emulation package 9.7.0.00213) 
    CortexR5: Error: (Error -2063 @ 0x0) Unable to reset device. Power-cycle the board. If error persists, confirm configuration and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 9.7.0.00213) 
    CortexR5: Error: (Error -1170 @ 0x0) Unable to access the DAP. Reset the device, and retry the operation. If error persists, confirm configuration, power-cycle the board, and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 9.7.0.00213) 
    CortexR5: Unable to determine target status after 20 attempts
    CortexR5: Failed to remove the debug state from the target before disconnecting.  There may still be breakpoint op-codes embedded in program memory.  It is recommended that you reset the emulator before you connect and reload your program before you continue debugging
    



    感谢您的耐心 QJ Wang。  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [引用 userid="522078" URL"~μ C/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1105167/tms570lc4357-arm-based-microcontrollers-forum/4102436#4102436"]它构建时没有任何问题、但在控制台上看不到任何内容[引用/引用]。

    当传递 printf 的字符串不包含换行符(通常是写入 的\n)时、将看不到输出。  以下是您的代码:

    		printf ("Hello World_2");
    

    修复方法是在字符串的末尾添加换行符:

    		printf ("Hello World_2\n"); 
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [~ userid="522078" URL"μ C/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1105167/tms570lc4357-arm-based-microcontrollers-forum/4102472#4102472"]对 MCU 板进行编程后、控制台中显示以下错误消息。  [/报价]

    问题可能是由您编程的代码引起的。 闪存中的代码使 CPU 反复进入一个异常状态、并且 CPU 不能进入一个调试状态。

    请尝试以下过程以让 CPU 进入调试状态:

    1. 打开目标配置窗口、然后启动选定的配置
    2. 切换到调试窗口。
    3. 按住 RESET (nRST)按钮。
    4. 释放 nRST 按钮后,立即单击“连接目标”。
    5. 应在几次尝试后连接电路板。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    它解决了我的问题。  

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

    感谢王杰和切斯特·吉隆的耐心和耐心。 向您致敬。