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.

关于28335#pragma CODE_SECTION(xxx,"ramfuncs");的疑问

我想请教个问题,如果函数1,在预编译中采用#pragma CODE_SECTION(函数1,"ramfuncs");但是函数1内包含有函数2 ,函数3,那么为了加快速度,函数2 和函数3 也需要如下预处理吗?

#pragma CODE_SECTION(函数2,"ramfuncs");

#pragma CODE_SECTION(函数3,"ramfuncs");

函数1

{

函数2;

函数3;

}

还是只需要预处理 函数1就可以了????#pragma CODE_SECTION(函数1,"ramfuncs");

  • 利用#pragma CODE_SECTION指令可以将程序从Flash搬到RAM中运行,从而提高程序执行速率,该方法需要完成以下四步。

    第一步,利用#pragma CODE_SECTION指令关联程序和SECTIONS;

    #pragma CODE_SECTION(mainISR,"ramfuncs");

    第二步,为链接创建相关变量;

    // Used for running BackGround in flash, and ISR in RAM
    extern uint16_t *RamfuncsLoadStart, *RamfuncsLoadEnd, *RamfuncsRunStart;
    1
    2
    第三步,复制时间关键代码以及Flash设置代码到RAM;

    // Copy time critical code and Flash setup code to RAM
    // The RamfuncsLoadStart, RamfuncsLoadEnd, and
    // RamfuncsRunStart symbols are created by the linker. // Refer to the linker files.
    memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);

    第四步,修改CMD文件。

    SECTIONS
    {
    /* Allocate program areas: */
    ......
    ramfuncs : LOAD = FLASHD,
    RUN = RAML0_1,
    LOAD_START(_RamfuncsLoadStart),
    LOAD_END(_RamfuncsLoadEnd),
    RUN_START(_RamfuncsRunStart),
    PAGE = 0
  • 您只需要预处理 函数1就可以了