DSP的Gel作用
DSP的Gel作用
1 GEL文件基本作用
當CCSStudio啟動時,GEL文件加載到PC機的內存中,如果定義了StartUp()函數則執行該函數在CCSStudio(V2.3或更早的版本中),主機和目標板的初始化工作都在Startup()函數中執行但是對于支持Connect/Disconnect的CCSStudio(V2.4或之后的版本,尤其3.1版本),這樣的GEL文件有可能沒有正確的執行,因為CCSStudio啟動時和目標處理器是斷開的這個時候,當Startup()函數試圖訪問目標處理器時會出錯
因此,V2.4或之后的版本,尤其3.1版本CCS啟動時候,一個新的回調函數OnTargetConnect()來執行目標處理器的初始化工作
2 GEL回調函數
2.1 Startup()函數
????? 如果指定的GEL文件中包含Startup()函數,當 CCSStudio啟動時執行Startup()函數支持Connect/Disconnect的CCSStudio的啟動時,Startup()函數中 不包括訪問目標處理器的代碼,目標處理器由回調函數OnTargetConnect()來初始化
?????? 推薦:
l???????? 建立基本的CCSStudio內存映射關系(不需要訪問目標處理器)
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()函數
?絕對最小的系統初始化處理,保證CCSStudio在目標處理器上處于一種可信賴的狀態例如:禁止看門狗時鐘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()函數使得CCSStudio處于一種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();
}
2.4 OnReset()函數
?當目標處理器復位后該函數被調用如果你需要每次重新啟動程序設計了軟復位,GEL_Restart()在此處調用
/* 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;
}
3 存儲器映射
CCSStudio存儲器映射告訴調試器目標處理器的那些存儲區域可以訪問那些不能訪問CCSStudio存儲器映射一般在StartUp()函數種執行
3.1 GEL_MapAdd()函數
該函數添加一個存儲區域到存儲區映射中
3.2 GEL_MapOn()和GEL_MapOff()函數
可以調用GEL_MapOn() or GEL_MapOff()來打開或關閉存儲區映射當存儲區映射關閉時,CCSStudio假定可以訪問所有的存儲區空間
3.3 GEL_MapReset()函數
?GEL_MapReset()函數清除所有的存儲區映射沒有存儲區映射時,缺省設置是所有的存儲區空間都不能訪問
4 盡量避免使用GEL初始化
可以考慮在GEL文件中使用GEL_MapAdd()建立存儲區映射以準許CCSStudio可以調試,但是不在GEL文件中執行外設設置例如:EMIF寄存器初始化看門狗禁止
?因為GEL語法和C兼容,inif_emif()函數可以在.c文件中實現,和應用程序鏈接在一起但是要注意以下幾點:
使用volatile來保證變量不被優化例如:
*(volatile int *)EMIFA_SDRAMTIM = 0x00000618; /* SDRAM timing (refresh) */?????? 在編譯調試過程中避免在GEL文件中進行外設設置,當到達了最終程序時,需要一個智能加載軟件從FLASH或主機加載程序對EMIF進行設置,然后通過 (E)DMA或memcpy()拷貝程序/數據
轉載于:https://www.cnblogs.com/gune/p/3240566.html
總結
- 上一篇: EM算法精解
- 下一篇: Google Chrome 11 浏览器