下面具体谈一下GEL文件的执行过程。使用CCSStudio Setup工具,可以为在系统配置中的每一个处理器指定一个启动GEL文 件。当CCSStudio启动时,GEL文 件加载到PC机的内存中,由CCS根据加载的GEL文件对目标板进行初始化。在CCS2.2中,主机和目标板的初始化工作都在GEL文件的Startup()函数中执行,而CCS2.2必须在打开时就会连接目标板同时进行初始化。但是对于支持Connect/Disconnect的CCSStudio例如CCS3.1,打开后目标板并没有被自动连接,这样的GEL文件中的初始化程序并没有正确执行,因为CCSStudio启动时和目标处理器是断开的。当Startup()函数试图访问目标处理器时会出错。因此在CCS3.1中需要回调函数来重新执行初始化。下面可以将SEEDDM642.gel和EVMDM642.gel做一个对比。
首先是SEEDDM642.gel中的StartUp()
- StartUp()
- {
- setup_memory_map();
- GEL_Reset();
- init_emif();
- }
EVMDM642.gel中的StartUp()
- StartUp()
- {
- setup_memory_map();
- /*------------------------------------------------------*/
- /* Uncomment the OnTargetConnect() call for CCS 2.X */
- /* support. */
- /* */
- /* */
- /*------------------------------------------------------*/
- //OnTargetConnect();
- }
从这个函数的对比就可以看到前一个在StartUp()中就已经完成了GEL和emif的初始化工作,而在后一个中就没有,这一点和前面说的软件打开时目标板的连接方式刚好一致。
因此在CCS3.1的gel文件中就多了这样一段函数:
- OnTargetConnect()
- {
- /*------------------------------------------------------*/
- /* GEL_Reset() is used to deal with the worst case */
- /* senario of unknown target state. If for some reason */
- /* a reset is not desired upon target connection, */
- /* GEL_Reset() may be removed and replaced with */
- /* something "less brutal" like a cache initialization */
- /* function. */
- /*------------------------------------------------------*/
- //GEL_Reset();
- init_emif();
- GEL_TextOut("GEL StartUp Complete./n");
- }
即在目标板连接的时候进行初始化操作,由此就可以理解为什么前面弹出的警告了,将SEEDDM642.gel对应的部分修改后在运行警告消失,即在软件打开时不对芯片初始化,改在芯片连接时进行。
同样可以看一下gel文件中的其他函数:
- /*--------------------------------------------------------------*/
- /* OnReset() */
- /* This function is called by CCS when you do Debug->Resest. */
- /* The goal is to put the C6x into a known good state with */
- /* respect to cache, edma and interrupts. */
- /*--------------------------------------------------------------*/
- OnReset( int nErrorCode )
- {
- init_emif();
- }
- /*--------------------------------------------------------------*/
- /* OnPreFileLoaded() */
- /* This function is called automatically when the 'Load Program'*/
- /* Menu item is selected. */
- /*--------------------------------------------------------------*/
- OnPreFileLoaded()
- {
- /*------------------------------------------------------*/
- /* GEL_Reset() is used to deal with the worst case */
- /* senario of unknown target state. If for some reason */
- /* a reset is not desired upon target connection, */
- /* GEL_Reset() may be removed and replaced with */
- /* something "less brutal" like a cache initialization */
- /* function. */
- /*------------------------------------------------------*/
- //GEL_Reset();
- flush_cache();
- IER = 0;
- IFR = 0;
- init_emif();
- }
- /*--------------------------------------------------------------*/
- /* OnRestart() */
- /* 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 your application code multiple times. This is different */
- /* then OnPreFileLoaded() which will do a GEL_Reset() to get the*/
- /* C6x into a known good state. */
- /*--------------------------------------------------------------*/
- OnRestart( int nErrorCode )
- {
- /*------------------------------------------------------*/
- /* Turn off L2 for all EMIFA CE spaces. App should */
- /* manage these for coherancy in the application. */
- /* GEL_TextOut("Turn off cache segment/n"); */
- /*------------------------------------------------------*/
- *(int*)0x01848200 = 0; // MAR0
- *(int*)0x01848204 = 0; // MAR1
- *(int*)0x01848208 = 0; // MAR2
- *(int*)0x0184820c = 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;
- }
本文转自emouse博客园博客,原文链接:http://www.cnblogs.com/emouse/archive/2010/03/21/2198234.html,如需转载请自行联系原作者