SPRAA74A
4 Creating Device Initialization GEL Files
3.2 OnTargetConnect() Function
With the introduction of Connect/Disconnect in CCStudio version 2.40, the OnTargetConnect()
callback was created with the intention that it perform the minimum target initialization needed to
access the target regularly (for example, to set PLLs and disable watchdog timers). Its execution
finishes before anything else occurs.
You might tend to view OnTargetConnect() as a location for all desired target initialization steps
that cannot be run in StartUp(). We would like to discourage this for the following reasons:
• If using CCS 2.40 and 3.0: Except for GEL_Reset() and GEL_IsInRealtimeMode(), calls to
any built-in GEL functions that access the target are not allowed. Calls to custom GEL
functions that do not call built-in GEL functions themselves are fine. These built-in GEL calls
are not recommended because some built-in calls can disrupt the Connect/Disconnect
process in CCStudio. If GEL built-in calls that access the target are needed for additional
initialization, it is recommended that they be called from a separate function after a target
connection has been established and after OnTargetConnect() has finished execution. For
example, such a function could be called from the GEL pull-down hotmenu.
NOTE: For CCStudio 3.1 (and higher), this limitation does not exist because the
OnTargetConnect() callback has been modified to be called later when it will not disrupt the
connect procedure. Any target initialization action can be made here if using CCStudio 3.1
• It is important to remember that OnTargetConnect() is called each time a target connection
is established. If you disconnect the target and do a power cycle, re-initialize the target upon
re-connecting. Treat every connection as a first connection—with the essential target
initialization actions always run. Otherwise, people may disconnect, power cycle the target,
try to connect, and run into problems. If any custom target initialization steps should not be
run every time a target connection is made, these steps should be placed in a custom GEL
function that can be called manually as described in the preceding paragraph.
If you connect to the target in real-time mode, you can connect unobtrusively and leave the
target in a running state. Issuing a command in OnTargetConnect() that modifies the target state
(such as GEL_Reset() ), halts the target and defeats the ability to connect unobtrusively. Real-
Time mode is available on 'C27x, 'C28x, 'C55x and 'C64x processors.
There is a new built-in GEL function called GEL_IsInRealtimeMode(). (See Appendix A:
CCStudio Version Support Matrix.) This call returns a 1 if the target is started up in real-time
mode, and 0 if it not. This call can be used in OnTargetConnect() to perform different actions
depending on whether you are in real-time mode.
/* OnTargetConnect() is called each time a target is connected. */
/* Its execution finishes before anything else occurs. */
/* Customize this function to perform essential target initialization. */
OnTargetConnect()
{
// Check to see if started up in real-time mode
if (GEL_IsInRealtimeMode() ) {
// do real-time target init stuff
} else {
// do regular initialization
GEL_Halt();
GEL_Reset();
}
}