This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

28035 FLASH与问题RAM



我们最近的项目,遇到了个问题,我们将中断程序移植到了RAM中运行,中断程序使用汇编语句,在中断程序前我们有.sect"ramfuncs", 并在CMD文件中对ramfuncs进行了地址分配,中断程序我们调用了CNTL_2P2Z.asm这个文件,我的问题是中断程序中调用CNTL_2P2Z,是否意味着CNTL_2P2Z程序也在RAM中运行,若在FLASH运行,我可以将其移到RAM中吗?望各位高手不吝赐教,小弟在此先行谢过。

  • 调试中用28069代替了28027,芯片的RAM要大得多,FLASH中的语句放在RAM中运行也方便。

    SECTIONS
    {

       /* Allocate program areas: */
       .cinit              : > FLASHA,     PAGE = 0
       .pinit              : > FLASHA,     PAGE = 0
       .text               : > FLASHA,     PAGE = 0
       codestart           : > BEGIN,      PAGE = 0
       ramfuncs            : LOAD = FLASHA,
                             RUN = RAML3,
                             LOAD_START(_RamfuncsLoadStart),
                             LOAD_END(_RamfuncsLoadEnd),
                             RUN_START(_RamfuncsRunStart),
           LOAD_SIZE(_RamfuncsLoadSize),
                             PAGE = 0

       因为TEXT中包括了所有运行语句,并存放在FLASHA中,运行时搬移到了RAM中,所有的子程序都搬了过去。

    在28027的FLASH_CMD文件中,也是这样的安排,所有的程序已经放到了RAM中。

    如果程序很大,只能局部放入RAM 中运行,需要执行如下的操作

    #pragma CODE_SECTION(ADC_Proc,       "ramfuncs");   //
    #pragma CODE_SECTION(IncPICalc,         "ramfuncs");
    #pragma CODE_SECTION(InitPIParameter,   "ramfuncs");
    #pragma CODE_SECTION(cpu_timer2_isr,    "ramfuncs");
    #pragma CODE_SECTION(Flash_Already,   "ramfuncs");
    #pragma CODE_SECTION(Proc_main_loop,   "ramfuncs");   //
    #pragma CODE_SECTION(epwm1_isr,       "ramfuncs");   //
    #pragma CODE_SECTION(Stop,           "ramfuncs");   //
    #pragma CODE_SECTION(xint2_isr,         "ramfuncs");
    #pragma CODE_SECTION(xint3_isr,         "ramfuncs");
    #pragma CODE_SECTION(xint4_isr,         "ramfuncs");
    #pragma CODE_SECTION(Process_receive,   "ramfuncs");
    #pragma CODE_SECTION(InitEPwm1Example,  "ramfuncs");
    #pragma CODE_SECTION(InitEPwm2Example,  "ramfuncs");
    #pragma CODE_SECTION(InitEPwm3Example,  "ramfuncs");
    #pragma CODE_SECTION(InitEPwm5Example,  "ramfuncs");
    #pragma CODE_SECTION(local_D_INTCH1_ISR,"ramfuncs");  //通信方式暂时取消
    #pragma CODE_SECTION(local_D_INTCH2_ISR,"ramfuncs");

    也就是把你所有需要放入的子程序罗列一遍,放在ramfuncs中。

  • 首先,感谢您的回答,但是我所调用的CNTL_2P2Z.asm是一个ASM格式文件,是用汇编语言编写的,这个可以使用#pragma CODE_SECTION(Process_receive,   "ramfuncs");这种形式吗?

  • wang4:

      直接用.sect "ranfuncs" 即可,参考

           .def _DSP28x_usDelay
           .sect "ramfuncs"

            .global  __DSP28x_usDelay
    _DSP28x_usDelay:
            SUB    ACC,#1
            BF     _DSP28x_usDelay,GEQ    ;; Loop if ACC >= 0
            LRETR

    cmd文件中:

       ramfuncs         : > RAMM0      PAGE = 0