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.

TMS320F28377D: 完全参考官方程序,但是无法启动cla

Part Number: TMS320F28377D

如题,我将官方的配置文件全部复制过来我的工程,但是却无法启动cla,具体现象为:运行到Cla1ForceTask1andWait();时就一直不执行,配置代码为:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//###########################################################################
// FILE: cla_divide_cpu01.c
// TITLE: CLA Divide Example for F2837xS.
//
//! \addtogroup cpu01_example_list
//! <h1>CLA Division: Newton Raphson Approximation (cla_divide_cpu01)</h1>
//!
//! In this example, Task 1 of the CLA will divide two input numbers using
//! multiple approximations in the Newton Raphson method.
//!
//! \b Memory \b Allocation \n
//! - CLA1 to CPU Message RAM
//! - Res - Result of the division operation
//! - CPU to CLA1 Message RAM
//! - Num - Numerator of input
//! - Den - Denominator of input
//!
//! \b Watch \b Variables \n
//! - Num - Numerator of input
//! - Den - Denominator of input
//! - Res - Result of the division operation
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

整体工程如下:

0486.cla.rar

文件目录如下:

编译的时候还出现了以下的警告:

请问到底是哪里出了问题呢?

  • 你好,你的工程里包含了这个文件路径吗?

  • cla3.rar

    您好,昨天的工程我修改过cmd文件,现在已经不会再报错,但是cla还是没能正常运行,下面是配置代码:

    /*
    * init.c
    *
    * Created on: 2023年11月6日
    * Author: DELL
    */

    #include "main.h"
    #include "cla_divide_shared.h"

    //
    // Defines
    //
    #define WAITSTEP asm(" RPT #255 || NOP")

    //
    // Globals
    //

    //
    // Task 1 (C) Variables
    // NOTE: Do not initialize the Message RAM variables globally, they will be
    // reset during the message ram initialization phase in the CLA memory
    // configuration routine
    //
    #ifdef __cplusplus
    #pragma DATA_SECTION("CpuToCla1MsgRAM");
    float Num;
    #pragma DATA_SECTION("CpuToCla1MsgRAM");
    float Den;
    #pragma DATA_SECTION("Cla1ToCpuMsgRAM");
    float Res;
    #else
    #pragma DATA_SECTION(Num,"CpuToCla1MsgRAM");
    float Num;
    #pragma DATA_SECTION(Den,"CpuToCla1MsgRAM");
    float Den;
    #pragma DATA_SECTION(Res,"Cla1ToCpuMsgRAM");
    float Res;
    #endif //__cplusplus
    float y[BUFFER_SIZE];

    //
    //Task 2 (C) Variables
    //

    //
    //Task 3 (C) Variables
    //

    //
    //Task 4 (C) Variables
    //

    //
    //Task 5 (C) Variables
    //

    //
    //Task 6 (C) Variables
    //

    //
    //Task 7 (C) Variables
    //

    //
    //Task 8 (C) Variables
    //

    //
    //Common (C) Variables
    //

    //
    //Golden Test Values
    //
    float div_expected[BUFFER_SIZE]={
    1, 0.9692308, 0.9393939, 0.9104478, 0.8823529,
    0.8550724, 0.8285714, 0.8028169, 0.7777778, 0.7534246,
    0.7297297, 0.7066666, 0.6842105, 0.6623377, 0.6410257,
    0.6202531, 0.6000000, 0.5802469, 0.5609756, 0.5421687,
    0.5238096, 0.5058824, 0.4883721, 0.4712644, 0.4545455,
    0.4382023, 0.4222222, 0.4065934, 0.3913043, 0.3763441,
    0.3617021, 0.3473684, 0.3333333, 0.3195876, 0.3061225,
    0.2929293, 0.2800000, 0.2673267, 0.2549020, 0.2427184,
    0.2307692, 0.2190476, 0.2075472, 0.1962617, 0.1851852,
    0.1743119, 0.1636364, 0.1531532, 0.1428571, 0.1327434,
    0.1228070, 0.1130435, 0.1034483, 0.09401710, 0.08474576,
    0.07563026, 0.06666667, 0.05785124, 0.04918033, 0.04065040,
    0.03225806, 0.02400000, 0.01587302, 0.007874016
    };
    uint16_t pass=0;
    uint16_t fail=0;

    //
    // Function Prototypes
    //
    void CLA_runTest(void);
    void CLA_configClaMemory(void);
    void CLA_initCpu1Cla1(void);
    __interrupt void cla1Isr1();
    __interrupt void cla1Isr2();
    __interrupt void cla1Isr3();
    __interrupt void cla1Isr4();
    __interrupt void cla1Isr5();
    __interrupt void cla1Isr6();
    __interrupt void cla1Isr7();
    __interrupt void cla1Isr8();

    void CLA_runTest(void)
    {
    int i, error;

    for(i=0; i<BUFFER_SIZE; i++)
    {
    Num = (float)(BUFFER_SIZE - i);
    Den = (float)(BUFFER_SIZE + i);
    Cla1ForceTask1andWait();
    y[i] = Res;
    error = fabs(div_expected[i]-y[i]);
    if (error < 0.01)
    {
    pass++;
    }
    else
    {
    fail++;
    }
    }
    #if 0
    Cla1ForceTask2andWait();
    WAITSTEP;

    Cla1ForceTask3andWait();
    WAITSTEP;

    Cla1ForceTask4andWait();
    WAITSTEP;

    Cla1ForceTask5andWait();
    WAITSTEP;

    Cla1ForceTask6andWait();
    WAITSTEP;

    Cla1ForceTask7andWait();
    WAITSTEP;

    Cla1ForceTask8andWait();
    WAITSTEP;
    #endif
    }

    //
    // CLA_configClaMemory - Configure CLA memory sections
    //
    void CLA_configClaMemory(void)
    {
    extern uint32_t Cla1funcsRunStart, Cla1funcsLoadStart, Cla1funcsLoadSize;
    EALLOW;

    #ifdef _FLASH
    //
    // Copy over code from FLASH to RAM
    //
    memcpy((uint32_t *)&Cla1funcsRunStart, (uint32_t *)&Cla1funcsLoadStart,
    (uint32_t)&Cla1funcsLoadSize);
    #endif //_FLASH

    //
    // Initialize and wait for CLA1ToCPUMsgRAM
    //
    MemCfgRegs.MSGxINIT.bit.INIT_CLA1TOCPU = 1;
    while(MemCfgRegs.MSGxINITDONE.bit.INITDONE_CLA1TOCPU != 1){};

    //
    // Initialize and wait for CPUToCLA1MsgRAM
    //
    MemCfgRegs.MSGxINIT.bit.INIT_CPUTOCLA1 = 1;
    while(MemCfgRegs.MSGxINITDONE.bit.INITDONE_CPUTOCLA1 != 1){};

    //
    // Select LS5RAM to be the programming space for the CLA
    // First configure the CLA to be the master for LS5 and then
    // set the space to be a program block
    //
    MemCfgRegs.LSxMSEL.bit.MSEL_LS5 = 1;
    MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS5 = 1;

    //
    // Next configure LS0RAM and LS1RAM as data spaces for the CLA
    // First configure the CLA to be the master for LS0(1) and then
    // set the spaces to be code blocks
    //
    MemCfgRegs.LSxMSEL.bit.MSEL_LS0 = 1;
    MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS0 = 0;

    MemCfgRegs.LSxMSEL.bit.MSEL_LS1 = 1;
    MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS1 = 0;

    EDIS;
    }

    //
    // CLA_initCpu1Cla1 - Setup CLA task vectors and set PIE table ISR handles
    //
    void CLA_initCpu1Cla1(void)
    {
    //
    // Compute all CLA task vectors
    // On Type-1 CLAs the MVECT registers accept full 16-bit task addresses as
    // opposed to offsets used on older Type-0 CLAs
    //
    EALLOW;
    Cla1Regs.MVECT1 = (uint16_t)(&Cla1Task1);
    Cla1Regs.MVECT2 = (uint16_t)(&Cla1Task2);
    Cla1Regs.MVECT3 = (uint16_t)(&Cla1Task3);
    Cla1Regs.MVECT4 = (uint16_t)(&Cla1Task4);
    Cla1Regs.MVECT5 = (uint16_t)(&Cla1Task5);
    Cla1Regs.MVECT6 = (uint16_t)(&Cla1Task6);
    Cla1Regs.MVECT7 = (uint16_t)(&Cla1Task7);
    Cla1Regs.MVECT8 = (uint16_t)(&Cla1Task8);

    //
    // Enable the IACK instruction to start a task on CLA in software
    // for all 8 CLA tasks. Also, globally enable all 8 tasks (or a
    // subset of tasks) by writing to their respective bits in the
    // MIER register
    //
    Cla1Regs.MCTL.bit.IACKE = 1;
    Cla1Regs.MIER.all = 0x00FF;

    //
    // Configure the vectors for the end-of-task interrupt for all
    // 8 tasks
    //
    PieVectTable.CLA1_1_INT = &cla1Isr1;
    PieVectTable.CLA1_2_INT = &cla1Isr2;
    PieVectTable.CLA1_3_INT = &cla1Isr3;
    PieVectTable.CLA1_4_INT = &cla1Isr4;
    PieVectTable.CLA1_5_INT = &cla1Isr5;
    PieVectTable.CLA1_6_INT = &cla1Isr6;
    PieVectTable.CLA1_7_INT = &cla1Isr7;
    PieVectTable.CLA1_8_INT = &cla1Isr8;

    //
    // Enable CLA interrupts at the group and subgroup levels
    //
    PieCtrlRegs.PIEIER11.all = 0xFFFF;
    IER |= (M_INT11 );
    }

    //
    // cla1Isr1 - CLA1 ISR 1
    //
    __interrupt void cla1Isr1 ()
    {
    //
    // Acknowledge the end-of-task interrupt for task 1
    //
    PieCtrlRegs.PIEACK.all = M_INT11;

    //
    // Uncomment to halt debugger here
    //
    // asm(" ESTOP0");
    }

    //
    // cla1Isr2 - CLA1 ISR 2
    //
    __interrupt void cla1Isr2 ()
    {
    asm(" ESTOP0");
    }

    //
    // cla1Isr3 - CLA1 ISR 3
    //
    __interrupt void cla1Isr3 ()
    {
    asm(" ESTOP0");
    }

    //
    // cla1Isr4 - CLA1 ISR 4
    //
    __interrupt void cla1Isr4 ()
    {
    asm(" ESTOP0");
    }

    //
    // cla1Isr5 - CLA1 ISR 5
    //
    __interrupt void cla1Isr5 ()
    {
    asm(" ESTOP0");
    }

    //
    // cla1Isr6 - CLA1 ISR 6
    //
    __interrupt void cla1Isr6 ()
    {
    asm(" ESTOP0");
    }

    //
    // cla1Isr7 - CLA1 ISR 7
    //
    __interrupt void cla1Isr7 ()
    {
    asm(" ESTOP0");
    }

    //
    // cla1Isr8 - CLA1 ISR 8
    //
    __interrupt void cla1Isr8 ()
    {
    //
    // Acknowledge the end-of-task interrupt for task 8
    //
    PieCtrlRegs.PIEACK.all = M_INT11;

    //
    // Uncomment to halt debugger here
    //
    // asm(" ESTOP0");
    }

    void Init_DSP(){

    InitSysCtrl();
    DINT;
    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();

    #ifdef _STANDALONE
    #ifdef _FLASH
    //
    // Send boot command to allow the CPU02 application to begin execution
    //
    IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH); //这行会被执行
    #else
    //
    // Send boot command to allow the CPU02 application to begin execution
    //
    IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_RAM);
    #endif
    #endif

    init_timer();

    EALLOW;
    InitGpio();
    GPIO_SetupPinMux(109, GPIO_MUX_CPU2, 0);
    GPIO_SetupPinOptions(109, GPIO_OUTPUT, GPIO_PUSHPULL);
    GPIO_SetupPinMux(108, GPIO_MUX_CPU1, 0);
    GPIO_SetupPinOptions(108, GPIO_OUTPUT, GPIO_PUSHPULL);
    EDIS;

    CLA_configClaMemory();
    CLA_initCpu1Cla1();

    EINT; // Enable Global interrupt INTM
    ERTM; // Enable Global realtime interrupt DBGM

    CLA_runTest();


    }

    编译信息:

    程序还是停在了:

  • 你好,你复制的是哪个例程?能否直接导入例程然后看看能否正常运行?

  • 你好,我复制的是这个例程:

    我里面的全部文件都是复制的这个例程里面的东西,但是我用一个28377s的例程,初始化cla部分完全一样的情况下能跑起来,但是把全部文件换成377D的就不行了。我用的芯片是377D

  • 谢谢您,我受这个帖子启发重新审视我的代码,我发现我的CMD文件配置有问题,最终解决了问题,感谢