1423 views|0 replies

3836

Posts

19

Resources
The OP
 

TMS320C6000 Basic Learning (6) - gel file [Copy link]

What is a gel file? What can a gel file do?

GEL stands for General Extended Language, which is a general extended language file. The GEL file is composed of codes similar to C language. GEL language is an interpreted language. The extension of GEL file is .gel.

GEL files are used to (1) extend CCS functionality, such as menu options, and (2) provide access to the target board's memory.

1. Basic syntax of gel - Class C

Gel functions and gel parameters do not need to be defined in the DSP program. Gel has many similarities to C language: functions, return statements, if-else statements, while statements, the same comment method as C, #define, and the usage of these functions or statements is also very similar to that in C.

GEL Function

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

{

statements;

}

There is no need to declare the return type and parameter type in the gel function, but the return statement can be used in the function;

Parameters are composed of "parameter + string type description". Parameters do not need to be defined and can be any of the following: symbolic value of the actual/simulated DSP target board; digital constant (expression or constant); string constant.

GEL function call: You can usually call a GEL function anywhere you enter a C expression, or you can call a GEL function from within another GEL function. GEL functions cannot be called recursively.

GEL Statements

Return statement:

return [expression];

Conditional Statements:


  1. if (exp)

  2. statements 1;

  3. else

  4. statements 2;

Loop statement:


  1. while (exp) {

  2. statements;

  3. }

GEL Pretreatment

#define identifier(arguments list)     token-expression

GEL Notes

// Comments

/* Comments */

2. Gel-specific keywords

menuitem/hotmenu

Tested in CCS v4.2, menuitem adds submenu items under the Scripts menu, and hotmenu adds submenu items of the menu item defined by menuitem. Refer to the examples later in this article.

Functions declared with these two keywords do not require parameters, such as


  1. menuitem "Addressing Modes";

  2. hotmenu C27x_Mode()

  3. {

  4. AMODE = 0;

  5. OBJMODE = 0;

  6. }

  7. hotmenu C28x_Mode()

  8. {

  9. AMODE = 0;

  10. OBJMODE = 1;

  11. }

  12. hotmenu C2xLP_Mode()

  13. {

  14. AMODE = 1;

  15. OBJMODE = 1;

  16. }

The above code will generate the following menu structure,

Scripts

-Addressing Modes

-C27x_Mode

- C28x_Mode

- C2xLP_MODE


dialog

Add an entry submenu to the menu defined by menuitem and pop up a dialog box when the submenu is clicked.

menuitem "MyFunc"

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

{

statements;

}

dialog RefreshTarget()

{

statements;

}

slider

Add a slider. Each time you move the slider, call the GEL file again with the new value on the slider. The definition format is as follows:

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

{

statements;

}

3. GEL file example


  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. * The StartUp() function is called every time you start Code Composer.

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

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

  18. * function or the GEL menu.

  19. */

  20. StartUp()

  21. {

  22. /* setMemoryMap;

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

  24. on the particular hardware that is used

  25. */

  26. }

  27. /*--------------------------------------------------------------*/

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

  29. /* connect. */

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

  31. OnTargetConnect()

  32. {

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

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

  35. desired upon target connection, GEL_Reset may be removed

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

  37. initialization function

  38. GEL_Reset();

  39. */

  40. }

  41. OnReset(int nErrorCode){

  42. /* emif_init(); */

  43. }

  44. /*

  45. * OnPreFileLoaded()

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

  47. * Menu item is selected .....

  48. */

  49. OnPreFileLoaded()

  50. {

  51. CleanCache();

  52. }

  53. /*

  54. * CleanCache()

  55. * Actually Invalidate L1D, L1P, and L2

  56. */

  57. CleanCache() {

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

  59. }

  60. emif_init()

  61. {

  62. /*---------------------------------------------------------------------------*/

  63. /* EMIF REGISTERS */

  64. /*---------------------------------------------------------------------------*/

  65. #define EMIF_GCTL 0x01800000

  66. #define EMIF_CE1 0x01800004

  67. #define EMIF_CE0 0x01800008

  68. #define EMIF_CE2 0x01800010

  69. #define EMIF_CE3 0x01800014

  70. #define EMIF_SDRAMCTL 0x01800018

  71. #define EMIF_SDRAMTIMING 0x0180001C

  72. #define EMIF_SDRAMEXT 0x01800020

  73. /*---------------------------------------------------------------------------*/

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

  75. /*---------------------------------------------------------------------------*/

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

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

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

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

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

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

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

  83. }

The gel above comes from the ccsv4\emulation\gel\DSP621x_671x.gel file in the CCS v4 installation directory. It not only uses #define to define the register address, but also uses pointers similar to C to configure the EMIF (external memory interface).


  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. StartUp()

  13. {

  14. /* Initialize F2812 memory map */

  15. GEL_Reset();

  16. F2812_Memory_Map();

  17. /* Enable_DFT(); */

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

  19. }

  20. OnReset(int nErrorCode)

  21. {

  22. Enable_DFT();

  23. }

  24. /* commented out to avoid execution

  25. OnRestart(int nErrorCode)

  26. {

  27. }

  28. OnPreFileLoaded()

  29. {

  30. }

  31. OnFileLoaded(int nErrorCode, int bSymbolsOnly)

  32. {

  33. }

  34. */

  35. menuitem "Initialize Memory Map";

  36. /*------------------- F2812 Memory Map, MPNMC=0 --------------------*/

  37. /* */

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

  39. /* */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  54. /*------------------------------------------------------------------*/

  55. hotmenu F2812_Memory_Map()

  56. {

  57. GEL_MapReset();

  58. GEL_MapOn();

  59. /* Program memory maps */

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

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

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

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

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

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

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

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

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

  69. /* Data memory maps */

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

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

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

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

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

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

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

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

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

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

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

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

  82. /* Uncomment the map that corresponds to the MPNMC value. */

  83. F2812_Boot_ROM_Map();

  84. /* F2812_XINTF_Zone7_Map(); */

  85. }

  86. /* Map Boot ROM if MPNMC = 0 */

  87. F2812_Boot_ROM_Map()

  88. {

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

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

  91. }

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

  93. F2812_XINTF_Zone7_Map()

  94. {

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

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

  97. }

  98. /* Enable DFT read/write for SARAM blocks */

  99. Enable_DFT()

  100. {

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

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

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

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

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

  106. }

  107. menuitem "Watchdog";

  108. hotmenu Disable_WD()

  109. {

  110. /* Enable WD override */

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

  112. *0x7025 = 0x0055;

  113. *0x7025 = 0x00AA;

  114. }

  115. menuitem "Code Security Module"

  116. hotmenu Unlock_CSM()

  117. {

  118. /* Assumes flash is erased */

  119. *0xAE0 = 0xFFFF;

  120. *0xAE1 = 0xFFFF;

  121. *0xAE2 = 0xFFFF;

  122. *0xAE3 = 0xFFFF;

  123. *0xAE4 = 0xFFFF;

  124. *0xAE5 = 0xFFFF;

  125. *0xAE6 = 0xFFFF;

  126. *0xAE7 = 0xFFFF;

  127. /* Read the password locations */

  128. XAR0 = *0x3F7FF8;

  129. XAR0 = *0x3F7FF9;

  130. XAR0 = *0x3F7FFA;

  131. XAR0 = *0x3F7FFB;

  132. XAR0 = *0x3F7FFC;

  133. XAR0 = *0x3F7FFD;

  134. XAR0 = *0x3F7FFE;

  135. XAR0 = *0x3F7FFF;

  136. }

  137. menuitem "Addressing Modes";

  138. hotmenu C27x_Mode()

  139. {

  140. AMODE = 0;

  141. OBJMODE = 0;

  142. }

  143. hotmenu C28x_Mode()

  144. {

  145. AMODE = 0;

  146. OBJMODE = 1;

  147. }

  148. hotmenu C2xLP_Mode()

  149. {

  150. AMODE = 1;

  151. OBJMODE = 1;

  152. }

The above code is a GEL file for DSP320F2812

A screenshot of the results is as follows,

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list