Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

GEL Example - Periodic Recoding of a Variable

From Texas Instruments Wiki
Jump to: navigation, search

Overview

This is a GEL example which demonstrates how to use a GEL timer to periodically read the value of a variable and output it to the GEL output window. You can enable the CCS output window to stream to a file (see the CCSv5 Tips & Tricks presentation - slide called 'Debug Configurations - Common Options') so that all the values are captured to a file.

Example

In the example below, the GEL_Timer call is used to create a periodic timer that call another GEL function when the timer goes off. That function "recordVariables()" will output a string and the value of a variable to the console window. The timer can be enabled and disabled using GEL_SetTimer() and GEL_CancelTimer() respectively.

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(1);
}
 
 
recordVariables()
{
	GEL_TextOut("CpuTimer0.InterruptCount: %d \n",,,,,CpuTimer0.InterruptCount);
}

Hotmenus are used so that when the GEL script is loaded in CCS, there is a GEL menu called “Record Variables” that will appear in the CCS ‘scripts’ menu. That menu will have two sub menus to start and stop the timer.

GEL Hotmenus in CCS

Notes

GEL memory accesses are normally intrusive. This means it will momentarily halt the target to read memory. If the debugger is configured to not automatically allow target halts for debugger memory read requests, then the read will fail.

If your device has real-time mode support and it is enabled, GEL will be able to read memory non-intrusively.