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.

[参考译文] TM4C1230C3PM:在调试期间使用 GEL_TextOut 在控制台中打印 main.c 变量

Guru**** 2463330 points
Other Parts Discussed in Thread: EK-TM4C123GXL

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1477316/tm4c1230c3pm-print-main-c-variable-in-console-during-debug-with-gel_textout

器件型号:TM4C1230C3PM
Thread 中讨论的其他器件: EK-TM4C123GXL

工具与软件:

您好!

我有一个程序可以测量电压和电流、我希望能够在调试时将其打印在控制台中。

我使用两个变量 ui32Vbusest 和 ui32IShuttest、通过以下函数计算:

void readVoltage(){
   FV 浮动 Bus_Float_Value;
   I2C_LIBDataVBusGetFloat (&G、sI2C_LIBInst、&fV Bus_Float_Value);
   ui32Vbusest =(uint32_t)(fV Bus_Float_Value * 1000);//以毫伏为单位的 Vbus 无符号 int
}

void readCurrent(){
   uint16_t ui16V 分流 RAW_value;
   I2C_LIBDataVShuntGetRaw (&G、sI2C_LIBInst、&ui16VShunt_raw_Value);
   ui32IShunttest =(((ui16VShunt_raW_value 和0x7FFF)* 10)/ 8);// I Shunt unsigned int (以毫安为单位)
}

根据 此页面、我将以下内容添加到了 GEL 文件中:

OnTargetConnect()
{
	recordVariables();
}

menuitem "Record Variables";

hotmenu startTimer()
{
    // GEL_SetTimer(milliseconds, timer_id, "callback");
    // Parameters
    //   milliseconds: specifies the amount of time in milliseconds that should elapse between callbacks.
    //   timer_id:     specifies a number to uniquely identify this timer.
    //   callback:     is a string representing the GEL expression to evaluate every time the timer fires.

    GEL_SetTimer(5000, 1, "recordVariables()");
}

hotmenu stopTimer()
{
    // GEL_CancelTimer(timer_id);
    // Parameter:
    //   timer_id: the id of the timer to cancel

    GEL_CancelTimer(1);
}

recordVariables()
{
	GEL_TextOut("Voltage test \n");
    GEL_TextOut("Voltage: %u \n",,,,,ui32Vbustest);
    GEL_TextOut("Current: %u \n",,,,,ui32IShunttest);
}

当我开始调试时、控制台显示如下:

Cortex_M4_0:GEL 输出:
存储器映射初始化完成
Cortex_M4_0:GEL 输出:电压测试
Cortex_M4_0:GEL:执行 OnTargetConnect ()时出错:未找到标识符:ui32Vbusest
    在 GEL_TextOut ("Voltage:%u \n"、0、0、0、0、 ui32Vbusest)[tm4c1230c3p.gel:147]
    at recordVariables ()[tm4c1230c3p.gel:25]
    在 OnTargetConnect()

但是、当我在 GEL 文件中声明一个本地 int 时、我可以在控制台中正确输出它。

如何使 GEL 输出函数显示 main.c 文件中声明的变量的值?

谢谢

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

    您好!

    [报价用户 id="643240" url="~/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1477316/tm4c1230c3pm-print-main-c-variable-in-console-during-debug-with-gel_textout "]

    我有一个程序可以测量电压和电流、我希望能够在调试时将其打印在控制台中。

    [报价]

     为什么不要只是通过 UART 将其发送出去、UART 可连接到 PC 的虚拟 COM 端口、这是最好的方法。 TivaWare SDK 具有 UARTPrintf ()函数、用于将消息发送到 COM 端口。  

    您可以参阅有关如何在 C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\hello 中使用 UARTPrintf 的示例。 UARTPrintf 不处理浮点。 您需要将浮点型转换为字符串、并使用 UARTPrintf 将字符串发送出去。  

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

    非常感谢、我选择了这个方法、发现它比处理 GEL 文件更高效。
    对于如何在 CCS12中轻松地将 float/uint32转换为字符串、有任何想法/建议吗?

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

    您好!

     请参阅以下示例。