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.
我在使用CLA的过程中发现
CLA的初始化如下
void CLLLC_HAL_setupCLA(void) { // // setup CLA to register an interrupt // #if CLLLC_ISR1_RUNNING_ON == CLA_CORE memcpy((uint32_t *)&Cla1ProgRunStart, (uint32_t *)&Cla1ProgLoadStart, (uint32_t)&Cla1ProgLoadSize ); // // first assign memory to CLA // MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS0, MEMCFG_LSRAMMASTER_CPU_CLA1); MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS1, MEMCFG_LSRAMMASTER_CPU_CLA1); MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS2, MEMCFG_LSRAMMASTER_CPU_CLA1); MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS3, MEMCFG_LSRAMMASTER_CPU_CLA1); MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS4, MEMCFG_LSRAMMASTER_CPU_CLA1); MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS5, MEMCFG_LSRAMMASTER_CPU_CLA1); MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS6, MEMCFG_LSRAMMASTER_CPU_CLA1); MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS7, MEMCFG_LSRAMMASTER_CPU_CLA1); MemCfg_setCLAMemType(MEMCFG_SECT_LS0, MEMCFG_CLA_MEM_DATA); MemCfg_setCLAMemType(MEMCFG_SECT_LS1, MEMCFG_CLA_MEM_DATA); MemCfg_setCLAMemType(MEMCFG_SECT_LS2, MEMCFG_CLA_MEM_DATA); MemCfg_setCLAMemType(MEMCFG_SECT_LS3, MEMCFG_CLA_MEM_DATA); MemCfg_setCLAMemType(MEMCFG_SECT_LS4, MEMCFG_CLA_MEM_PROGRAM); MemCfg_setCLAMemType(MEMCFG_SECT_LS5, MEMCFG_CLA_MEM_PROGRAM); MemCfg_setCLAMemType(MEMCFG_SECT_LS6, MEMCFG_CLA_MEM_PROGRAM); MemCfg_setCLAMemType(MEMCFG_SECT_LS7, MEMCFG_CLA_MEM_PROGRAM); // // Suppressing #770-D conversion from pointer to smaller integer // The CLA address range is 16 bits so the addresses passed to the MVECT // registers will be in the lower 64KW address space. Turn the warning // back on after the MVECTs are assigned addresses // #pragma diag_suppress = 770 CLA_mapTaskVector(CLA1_BASE , CLA_MVECT_1, (uint16_t)&Cla1Task1); CLA_mapTaskVector(CLA1_BASE , CLA_MVECT_2, (uint16_t)&Cla1Task2); CLA_mapTaskVector(CLA1_BASE , CLA_MVECT_3, (uint16_t)&Cla1Task3); CLA_mapTaskVector(CLA1_BASE , CLA_MVECT_4, (uint16_t)&Cla1Task4); CLA_mapTaskVector(CLA1_BASE , CLA_MVECT_5, (uint16_t)&Cla1Task5); CLA_mapTaskVector(CLA1_BASE , CLA_MVECT_6, (uint16_t)&Cla1Task6); CLA_mapTaskVector(CLA1_BASE , CLA_MVECT_7, (uint16_t)&Cla1Task7); CLA_mapBackgroundTaskVector(CLA1_BASE, (uint16_t)&Cla1BackgroundTask); #pragma diag_warning = 770 CLA_enableIACK(CLA1_BASE); CLA_enableTasks(CLA1_BASE, CLA_TASKFLAG_ALL); CLA_enableHardwareTrigger(CLA1_BASE); CLA_setTriggerSource(CLA_TASK_8, CLLLC_ISR2_TRIG_CLA); CLA_enableBackgroundTask(CLA1_BASE); CLA_setTriggerSource(CLA_TASK_1, CLLLC_ISR2_TRIG_CLA);//CLA_TRIGGER_ADCB1);//CLLLC_ISR1_TRIG_CLA); #endif }
当我使用BackgroundTask时
__attribute__((interrupt("background"))) void Cla1BackgroundTask ( void ) { #ifdef BUCK_CONTROL_RUNNING_ON_CLA BUCK_runIsr(); #ifdef BUCK2_ENABLE BUCK2_runIsr(); #endif #ifdef BUCK3_ENABLE BUCK3_runIsr(); #endif #ifdef BUCK4_ENABLE BUCK4_runIsr(); #endif #endif if(CLAtest == 1) { CLLLC_HAL_setProfilingGPIO2();//GPIO22置高 CLAtest = 0; } else { CLLLC_HAL_resetProfilingGPIO2();//GPIO22置低 CLAtest = 1; } }
编译就会不通过,如图
但当我把相同的任务内容放在Task1时
__attribute__((interrupt)) void Cla1Task1 ( void ) { #if(CLA_DEBUG == 1) __mdebugstop(); #endif #ifdef BUCK_CONTROL_RUNNING_ON_CLA BUCK_runIsr(); #ifdef BUCK2_ENABLE BUCK2_runIsr(); #endif #ifdef BUCK3_ENABLE BUCK3_runIsr(); #endif #ifdef BUCK4_ENABLE BUCK4_runIsr(); #endif #endif if(CLAtest == 1) { CLLLC_HAL_setProfilingGPIO2();//GPIO22置高 CLAtest = 0; } else { CLLLC_HAL_resetProfilingGPIO2();//GPIO22置低 CLAtest = 1; } }
程序就能编译通过并正常运行,这是什么原因?
CLA 编译器不允许在后台任务中进行函数调用。允许使用内联函数,并且可以改为使用内联函数。
此外,确保编译标志 --cla_background_task(Advanced Options-> Runtime Model Options)已打开。
Background我是打开的
CLA不能函数调用只能使用内联函数也对,但是CLATASK1是可以运行的啊说明它确实是内联的,函数是一模一样的啊,但是放到Background就不行,是Background有区别嘛?
那又回到我之前问你的那个问题了
#ifndef __TMS320C28XX_CLA__ #define BUCK_DCL_CTRL_TYPE DCL_DF22 #define BUCK_DCL_CTRL_DEFAULTS DF22_DEFAULTS #define BUCK_DCL_SPS_TYPE DCL_DF22_SPS #define BUCK_DCL_SPS_DEFAULTS DF22_SPS_DEFAULTS #define BUCK_DCL_RESET DCL_resetDF22 #define BUCK_DCL_LOAD_PID DCL_loadDF22asSeriesPID #define BUCK_DCL_LOAD_ZPK DCL_loadDF22asZPK #define BUCK_DCL_UPDATE DCL_updateDF22 #define BUCK_DCL_RUN_IMMEDIATE DCL_runDF22_C5 #define BUCK_DCL_RUN_PARTIAL DCL_runDF22_C6 #define BUCK_DCL_RUN_CLAMP DCL_runClamp_C2 #else // //#####BEGIN_INTERNAL##### //todo Figure out how to replace the FPU32 equivalents of _RESET, _LOAD_PID, _LOAD_ZPK, _UPDATE //#####END_INTERNAL##### // NOTE: the above are still used in the CLA case. Just that they get defined out when compiling // the .cla file since they are not visible to it. // #define BUCK_DCL_CTRL_TYPE DCL_DF22_CLA #define BUCK_DCL_RUN_IMMEDIATE DCL_runDF22_L2 #define BUCK_DCL_RUN_PARTIAL DCL_runDF22_L3 #define BUCK_DCL_RUN_CLAMP DCL_runClamp_L1 #endif
对于这样的定义,你之前跟我说当CLA调用该头文件时"__TMS320C28XX_CLA__"会被定义就会执行"#else"的内容,而现在执行出来的效果是,CLATASK1调用有这个效果,而Background调用,没有这个效果