社区导航

 

搜索
查看: 114|回复: 0

[资料分享] TMS320C6000基础学习(6)—— gel文件

[复制链接]

6236

TA的帖子

19

TA的资源

一粒金砂(高级)

Rank: 3Rank: 3

发表于 2020-2-12 17:36 | 显示全部楼层 |阅读模式

什么是gel文件?gel文件能干什么?

gel全称General Extended Language,即通用扩展语言文件,gel文件中由类似C语言的代码构成,gel语言是一种解释性语言,gel文件扩展名为.gel;

gel文件用于(1)扩展CCS功能,比如菜单选项等,(2)通过gel可以访问目标板的存储器。

 

1. gel基本语法——类C

gel函数和gel参数不需要在DSP程序中定义。gel具有C语言的很多相似的东西:函数、return语句、if-else语句、while语句、与C一样的注释方式、#define,这些函数或语句的用法也与C中的非常类似。

 

GEL函数

funcName(param1 "discription" [,param2 "discription", param3 "discription",...])

{

statements;

}

gel函数中不用声明返回类型和参数类型,但函数中可以使用return语句返回;

参数使用“参数+字符串类型的描述”组成,参数不需要定义,可以是以下的任意一种:实际/仿真的DSP目标板的符号值;数字常量(表达式或常值);字符串常量。

GEL函数调用:通常可以在输入C表达式的任意地方调用GEL函数,也可以在另一个GEL函数中调用GEL函数。GEL函数无法递归调用。

 

GEL语句

返回语句:

 

return [expression];

 

条件语句:

 


 
  1. if (exp)

  2. statements 1;

  3. else

  4. statements 2;

循环语句:

 

 


 
  1. while (exp) {

  2. statements;

  3. }

 

 

GEL预处理

 

#define identifier(arguments list)     token-expression

 

 

GEL注释

// 注释

/* 注释 */

 

2. gel特有关键字

menuitem/hotmenu

在CCS v4.2中测试,menuitem添加Scripts菜单下的子菜单项,hotmenu添加menuitem定义菜单项的子菜单项,参考本文后面的例子。

这两个关键字声明的函数都不需要参数,比如

 


 
  1. menuitem "Addressing Modes";

  2. hotmenu C27x_Mode()

  3. {

  4. AMODE = 0;

  5. OBJMODE = 0;

  6. }

  7.  
  8. hotmenu C28x_Mode()

  9. {

  10. AMODE = 0;

  11. OBJMODE = 1;

  12. }

  13.  
  14. hotmenu C2xLP_Mode()

  15. {

  16. AMODE = 1;

  17. OBJMODE = 1;

  18. }

上面代码将产生如下的菜单结构,

 

Scripts

-Addressing Modes

- C27x_Mode

- C28x_Mode

- C2xLP_MODE


dialog

向menuitem定义的菜单中添加一个入口子菜单,并在点击子菜单时弹出对话框。

menuitem "MyFunc"

dialog InitTarget(StartAddr "Starting Address", EndAddr "Ending Address")

{

statements;

}

dialog RefreshTarget()

{

statements;

}

 

slider

添加滑动条,每次移动滑动条都用滑动条上的新值重新调用GEL文件,定义格式如下,

slider param_def(minVal, maxVal, increment, pageIncrement, paramName)

{

statements;

}

 

3. gel文件的例子

 


 
  1. /*

  2. * This GEL file (DSP621x_671x.gel) provides example code on how to

  3. * reset the C6x DSP and initialize the External Memory Interface.

  4. *

  5. * You will have to edit settings in emif_init() to your own

  6. * specifications as the example is applicable to the C6711 DSK.

  7. *

  8. * This file is has minimal functionality and is designed to be used

  9. * as a starting point for custom GEL files.

  10. *

  11. * Refer to CCS Help for detailed information on GEL commands.

  12. *

  13. */

  14.  
  15. /*

  16. * The StartUp() function is called every time you start Code Composer.

  17. * It should only include functions that do not "touch the hardware" -

  18. * Hardware initialization should be invoked from the OnTargetConnect()

  19. * function or the GEL menu.

  20. */

  21. StartUp()

  22. {

  23.  
  24. /* setMemoryMap;

  25. this should be a function to initialize the mem map based

  26. on the particular hardware that is used

  27. */

  28. }

  29.  
  30. /*--------------------------------------------------------------*/

  31. /* OnTargetConnect() -- this function is called after a target */

  32. /* connect. */

  33. /*--------------------------------------------------------------*/

  34. OnTargetConnect()

  35. {

  36. /* GEL_Reset is used to deal with the worst case senario of

  37. unknown target state. If for some reason a reset is not

  38. desired upon target connection, GEL_Reset may be removed

  39. and replaced with something "less brutal" like a cache

  40. initialization function

  41. GEL_Reset();

  42. */

  43. }

  44.  
  45. OnReset(int nErrorCode){

  46. /* emif_init(); */

  47. }

  48.  
  49. /*

  50. * OnPreFileLoaded()

  51. * This function is called automatically when the 'Load Program'

  52. * Menu item is selected .....

  53. */

  54. OnPreFileLoaded()

  55. {

  56. CleanCache();

  57. }

  58.  
  59. /*

  60. * CleanCache()

  61. * Actually Invalidate L1D, L1P, and L2

  62. */

  63. CleanCache() {

  64. *(int *)0x01845004 = 1;

  65. }

  66.  
  67. emif_init()

  68. {

  69. /*---------------------------------------------------------------------------*/

  70. /* EMIF REGISTERS */

  71. /*---------------------------------------------------------------------------*/

  72.  
  73. #define EMIF_GCTL 0x01800000

  74. #define EMIF_CE1 0x01800004

  75. #define EMIF_CE0 0x01800008

  76. #define EMIF_CE2 0x01800010

  77. #define EMIF_CE3 0x01800014

  78. #define EMIF_SDRAMCTL 0x01800018

  79. #define EMIF_SDRAMTIMING 0x0180001C

  80. #define EMIF_SDRAMEXT 0x01800020

  81.  
  82. /*---------------------------------------------------------------------------*/

  83. /* EMIF REGISTER VALUES - these should be modified to match TARGET hardware */

  84. /*---------------------------------------------------------------------------*/

  85.  
  86. *(int *)EMIF_GCTL = 0x00003040;/* EMIF global control register */

  87. *(int *)EMIF_CE1 = 0xFFFFFF23; /* CE1 - 32-bit asynch access after boot*/

  88. *(int *)EMIF_CE0 = 0xFFFFFF30; /* CE0 - SDRAM */

  89. *(int *)EMIF_CE2 = 0xFFFFFF23; /* CE2 - 32-bit asynch on daughterboard */

  90. *(int *)EMIF_CE3 = 0xFFFFFF23; /* CE3 - 32-bit asynch on daughterboard */

  91. *(int *)EMIF_SDRAMCTL = 0x07117000; /* SDRAM control register (100 MHz)*/

  92. *(int *)EMIF_SDRAMTIMING = 0x0000061A; /* SDRAM Timing register */

  93. }

上面的gel来自于CCS v4安装目录下ccsv4\emulation\gel\DSP621x_671x.gel文件,上面不仅使用了#define定义寄存器地址,还使用了类似C中的指针对EMIF(外部存储器接口)进行配置。

 

 

 


 
  1. /******************************************************************/

  2. /* Code Composer Studio supports five reserved GEL functions that */

  3. /* automatically get executed if they are defined. They are: */

  4. /* */

  5. /* StartUp() - Executed whenever CCS is invoked */

  6. /* OnReset() - Executed after Debug->Reset CPU */

  7. /* OnRestart() - Executed after Debug->Restart */

  8. /* OnPreFileLoaded() - Executed before File->Load Program */

  9. /* OnFileLoaded() - Executed after File->Load Program */

  10. /* */

  11. /******************************************************************/

  12.  
  13. StartUp()

  14. {

  15. /* Initialize F2812 memory map */

  16. GEL_Reset();

  17. F2812_Memory_Map();

  18. /* Enable_DFT(); */

  19. GEL_TextOut("Gel StartUp Complete.\n");

  20. }

  21.  
  22. OnReset(int nErrorCode)

  23. {

  24. Enable_DFT();

  25. }

  26.  
  27. /* commented out to avoid execution

  28. OnRestart(int nErrorCode)

  29. {

  30. }

  31.  
  32. OnPreFileLoaded()

  33. {

  34. }

  35.  
  36. OnFileLoaded(int nErrorCode, int bSymbolsOnly)

  37. {

  38. }

  39. */

  40.  
  41. menuitem "Initialize Memory Map";

  42.  
  43. /*------------------- F2812 Memory Map, MPNMC=0 --------------------*/

  44. /* */

  45. /* Note: M0M1MAP and VMAP signals tied high on F2812 core */

  46. /* */

  47. /* 0x000000 - 0x0007ff M0/M1 SARAM (Prog and Data) */

  48. /* 0x000800 - 0x000fff Peripheral Frame0 (PF0) (Data only) */

  49. /* 0x002000 - 0x003fff XINTF ZONE 0 (Prog and Data) */

  50. /* 0x004000 - 0x005fff XINTF ZONE 1 (Prog and Data) */

  51. /* 0x006000 - 0x006fff Peripheral Frame1 (PF1) (Data only) */

  52. /* 0x007000 - 0x007fff Peripheral Frame2 (PF2) (Data only) */

  53. /* 0x008000 - 0x009fff L0/L1 SARAM (Prog and Data) */

  54. /* 0x080000 - 0x0fffff XINTF ZONE 2 (Prog and Data) */

  55. /* 0x100000 - 0x17ffff XINTF ZONE 6 (Prog and Data) */

  56. /* 0x3d7800 - 0x3d7fff OTP (Prog and Data) */

  57. /* 0x3d8000 - 0x3f7fff FLASH (Prog and Data) */

  58. /* 0x3f8000 - 0x3f9fff H0 SARAM (Prog and Data) */

  59. /* 0x3fc000 - 0x3fffff XINTF ZONE 7 (MPNMC=1) (Prog and Data) */

  60. /* 0x3ff000 - 0x3fffff BOOT ROM (MPNMC=0) (Prog and Data) */

  61. /*------------------------------------------------------------------*/

  62. hotmenu F2812_Memory_Map()

  63. {

  64. GEL_MapReset();

  65. GEL_MapOn();

  66.  
  67. /* Program memory maps */

  68. GEL_MapAdd(0x0,0,0x800,1,1); /* M0/M1 SARAM */

  69. GEL_MapAdd(0x2000,0,0x2000,1,1); /* XINTF ZONE 0 */

  70. GEL_MapAdd(0x4000,0,0x2000,1,1); /* XINTF ZONE 1 */

  71. GEL_MapAdd(0x8000,0,0x2000,1,1); /* L0/L1 SARAM */

  72. GEL_MapAdd(0x80000,0,0x80000,1,1); /* XINTF ZONE 2 */

  73. GEL_MapAdd(0x100000,0,0x80000,1,1); /* XINTF ZONE 6 */

  74. GEL_MapAdd(0x3d7800,0,0x800,1,0); /* OTP */

  75. GEL_MapAdd(0x3d8000,0,0x20000,1,0); /* FLASH */

  76. GEL_MapAdd(0x3f8000,0,0x2000,1,1); /* H0 SARAM */

  77.  
  78. /* Data memory maps */

  79. GEL_MapAdd(0x0,1,0x800,1,1); /* M0/M1 SARAM */

  80. GEL_MapAdd(0x800,1,0x800,1,1); /* PF0 */

  81. GEL_MapAdd(0x2000,1,0x2000,1,1); /* XINTF ZONE 0 */

  82. GEL_MapAdd(0x4000,1,0x2000,1,1); /* XINTF ZONE 1 */

  83. GEL_MapAdd(0x6000,1,0x1000,1,1); /* PF1 */

  84. GEL_MapAddStr(0x7000,1,0x1000,"R|W|AS2",0); /* PF2 */

  85. GEL_MapAdd(0x8000,1,0x2000,1,1); /* L0/L1 SARAM */

  86. GEL_MapAdd(0x80000,1,0x80000,1,1); /* XINTF ZONE 2 */

  87. GEL_MapAdd(0x100000,1,0x80000,1,1); /* XINTF ZONE 6 */

  88. GEL_MapAdd(0x3d7800,1,0x800,1,0); /* OTP */

  89. GEL_MapAdd(0x3d8000,1,0x20000,1,0); /* FLASH */

  90. GEL_MapAdd(0x3f8000,1,0x2000,1,1); /* H0 SARAM */

  91.  
  92. /* Uncomment the map that corresponds to the MPNMC value. */

  93. F2812_Boot_ROM_Map();

  94. /* F2812_XINTF_Zone7_Map(); */

  95. }

  96.  
  97. /* Map Boot ROM if MPNMC = 0 */

  98. F2812_Boot_ROM_Map()

  99. {

  100. GEL_MapAdd(0x3ff000,0,0x1000,1,0); /* BOOT ROM */

  101. GEL_MapAdd(0x3ff000,1,0x1000,1,0); /* BOOT ROM */

  102. }

  103.  
  104. /* Map External Interface Zone 7 if MPNMC = 1 */

  105. F2812_XINTF_Zone7_Map()

  106. {

  107. GEL_MapAdd(0x3fc000,0,0x4000,1,1); /* XINTF ZONE 7 */

  108. GEL_MapAdd(0x3fc000,1,0x4000,1,1); /* XINTF ZONE 7 */

  109. }

  110.  
  111. /* Enable DFT read/write for SARAM blocks */

  112. Enable_DFT()

  113. {

  114. *0x950 = 0x0300; /* M0 */

  115. *0x951 = 0x0300; /* M1 */

  116. *0x952 = 0x0300; /* L0 */

  117. *0x953 = 0x0300; /* L1 */

  118. *0x954 = 0x0300; /* H0 */

  119. }

  120.  
  121. menuitem "Watchdog";

  122. hotmenu Disable_WD()

  123. {

  124. /* Enable WD override */

  125. *0x7029 = *0x7029 | 0x0068;

  126. *0x7025 = 0x0055;

  127. *0x7025 = 0x00AA;

  128. }

  129.  
  130. menuitem "Code Security Module"

  131. hotmenu Unlock_CSM()

  132. {

  133. /* Assumes flash is erased */

  134. *0xAE0 = 0xFFFF;

  135. *0xAE1 = 0xFFFF;

  136. *0xAE2 = 0xFFFF;

  137. *0xAE3 = 0xFFFF;

  138. *0xAE4 = 0xFFFF;

  139. *0xAE5 = 0xFFFF;

  140. *0xAE6 = 0xFFFF;

  141. *0xAE7 = 0xFFFF;

  142.  
  143. /* Read the password locations */

  144. XAR0 = *0x3F7FF8;

  145. XAR0 = *0x3F7FF9;

  146. XAR0 = *0x3F7FFA;

  147. XAR0 = *0x3F7FFB;

  148. XAR0 = *0x3F7FFC;

  149. XAR0 = *0x3F7FFD;

  150. XAR0 = *0x3F7FFE;

  151. XAR0 = *0x3F7FFF;

  152. }

  153.  
  154. menuitem "Addressing Modes";

  155. hotmenu C27x_Mode()

  156. {

  157. AMODE = 0;

  158. OBJMODE = 0;

  159. }

  160.  
  161. hotmenu C28x_Mode()

  162. {

  163. AMODE = 0;

  164. OBJMODE = 1;

  165. }

  166.  
  167. hotmenu C2xLP_Mode()

  168. {

  169. AMODE = 1;

  170. OBJMODE = 1;

  171. }

上面的代码是DSP320F2812的一个GEL文件

结果的一个截图如下,

image.png


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

关闭

站长推荐上一条 1/4 下一条

  • 论坛活动 E手掌握

    扫码关注
    EEWORLD 官方微信

  • EE福利  唾手可得

    扫码关注
    EE福利 唾手可得

Archiver|手机版|小黑屋|电子工程世界 ( 京ICP证 060456 )

GMT+8, 2020-4-6 21:05 , Processed in 0.087871 second(s), 20 queries , Gzip On, MemCache On.

快速回复 返回顶部 返回列表