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 文件中声明的变量的值?
谢谢
