推荐:
l 建立基本的CCS内存映射关系(不需要访问目标处理器)
l 任何不需要访问目标处理器的基本初始化
不推荐:
l Get_Reset()(该函数通过仿真器复位目标处理器)
l 通过GEL_BreakPtAdd()设置断点
l GEL_TextOUT()和GET_OpenWindow(),因为StartUp()执行时CCSStudio的任何控制窗口还没有打开
不支持Connect/Disconnect的CCSStudio GEL文件中的StartUp()函数:
/* The StartUp() function is called each time CCS is started. */
/* Customize this function to perform desired initialization. */
StartUp()
{
setup_memory_map();
GEL_Reset(); /* Do not call in StartUp() with CCStudio v2.4 or higher */
init_emif(); /* Do not call in StartUp() with CCStudio v2.4 or higher */
}
支持Connect/Disconnect的CCSStudio GEL文件中的StartUp()函数:
/* The StartUp() function is called each time CCS is started. */
/* Customize this function to perform desired initialization */
/* that will not access the target. */
StartUp()
{
setup_memory_map();
}
2.2 OnTargetConnect()函数
绝对最小的系统初始化处理,保证CCS在目标处理器上处于一种可信赖的状态。例如:禁止看门狗时钟、DSP复位结束
每一次和目标处理器建立连接时都调用OnTargetConnect()函数。
/* OnTargetConnect() is called every time a target is connected.*/
/* Its execution finishes before anything else occurs. Customize*/
/* this function to perform essential target initialization. */
OnTargetConnect()
{
// place critical target initialization steps here
GEL_Reset();
init_emif();
}
对某些平台,必须调用GEL_Reset()函数使得CCS处于一种“Good”状态,可以通过测试来确定是否需要调用GEL_Reset()函数。应该尽可能的降低GEL startup functions复杂度-包括减少GEL_Reset()的调用。
2.3 OnPreFileLoaded()函数
在加载program/symbol(.out)文件之前该回调函数执行。在该函数中执行另外的目标处理器初始化操作以保证程序可以加载和调试是一个好的选择。
/* This function is called automatically when the 'Load Program'*/
/* Menu item is selected. */
OnPreFileLoaded()
{
FlushCache();
IER = 0;
IFR = 0;
init_emif();
}
/* This function is called automatically after a SW Reset has been executed.
OnReset(int nErrorCode)
{
init_emif();
}
2.5OnRestart()函数
当程序复位时调用该函数。
This function is called by CCS when you do Debug->Restart. The goal is to put the C6x into a known good state with respect to cache, edma and interrupts. Failure to do this can cause problems when you restart and run code multiple times.
OnRestart(int nErrorCode )
{
Turn off L2 for all EMIFA CE spaces. App should manage these for coherency
GEL_TextOut("Turn off cache segment\n");
*(int *)0x1848200 = 0; /* MAR0 */
*(int *)0x1848204 = 0; /* MAR1 */
*(int *)0x1848208 = 0; /* MAR2 */
*(int *)0x184820c = 0; /* MAR3 */
/* Disable EDMA events and interrupts and clear any pending events. */
GEL_TextOut("Disable EDMA event\n"); */
*(int *)0x01A0FFA8 = 0; /* CIERH */
*(int *)0x01A0FFB4 = 0; /* EERH */
*(int *)0x01A0FFB8 = 0XFFFFFFFF; /* ECRH */
*(int *)0x01A0FFE8 = 0; /* CIERL */
*(int *)0x01A0FFF4 = 0; /* EERL */
*(int *)0x01A0FFF8 = 0xFFFFFFFF; /* ECRL */
/* Disable other interrupts */
IER = 0;
IFR = 0;
}