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: Print main.c variable in console during debug with GEL_TextOut

Part Number: TM4C1230C3PM
Other Parts Discussed in Thread: EK-TM4C123GXL

Tool/software:

Hi,

I have a program where I measure a voltage and a current and i want to be able to print it in the console while debugging.

I use 2 variables, ui32Vbustest and ui32IShunttest, calculated with these functions:

void readVoltage() {
    float fVBus_Float_Value;
    I2C_LIBDataVBusGetFloat(&g_sI2C_LIBInst, &fVBus_Float_Value);
    ui32Vbustest = (uint32_t) (fVBus_Float_Value * 1000); // Vbus unsigned int in milliVolts
}

void readCurrent() {
    uint16_t ui16VShunt_RAW_Value;
    I2C_LIBDataVShuntGetRaw(&g_sI2C_LIBInst, &ui16VShunt_RAW_Value);
    ui32IShunttest = (((ui16VShunt_RAW_Value & 0x7FFF) * 10) / 8); // I Shunt unsigned int in milli Amper
}

According to this page, I added to my GEL file:

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);
}

When I start debugging, the console shows this:

CORTEX_M4_0: GEL Output:
Memory Map Initialization Complete
CORTEX_M4_0: GEL Output: Voltage test
CORTEX_M4_0: GEL: Error while executing OnTargetConnect(): identifier not found: ui32Vbustest
     at GEL_TextOut("Voltage: %u \n", 0, 0, 0, 0, ui32Vbustest) [tm4c1230c3pm.gel:147]
     at recordVariables() [tm4c1230c3pm.gel:25]
     at OnTargetConnect()

But when I declare a local int in GEL file, I can output it fine in the console.

How can I make the GEL output function display the value of a variable declared in the main.c file?

Thanks

  • Hi,

    I have a program where I measure a voltage and a current and i want to be able to print it in the console while debugging.

      Why don't you just send it out through UART which can be connected to the PC's virtual COM port which is the best way. The TivaWare SDK has the UARTPrintf() function to send the message to the COM port. 

    You can refer to the example on how UARTPrintf is used at C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\hello. UARTPrintf does not handle floating point. You will need to convert from float to string and use UARTPrintf to send the string out. 

  • Thank you a lot, I took this route and found out it's way more efficient than playing with GEL files.
    Any idea/suggestion on how to convert float/uint32 to string easily in CCS12 ?

  • Hi,

      See below example.