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.

TMS320F28069: how to share variables between CPU and CLA

Part Number: TMS320F28069
Other Parts Discussed in Thread: C2000WARE

I am calling task1 from an ISR as follow:

__interrupt void
adc_isr1(void)
{
ADCValue_PWM1B = AdcResult.ADCRESULT0;
Cla1ForceTask1();

AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; /* Clr ADCINT1 flag for next SOC */
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; /* Acknowledge interrupt to PIE */
}

in the CLA I am modifying the ADC value as follow:

__interrupt void
Cla1Task1 (void)
{
__mdebugstop();
ADCValue1= ADCValue_PWM1B*3;
}

However, the value of ADCValue1 does not change in main, I always read zero. Can anyone advise on how to share variables between CPU and CLA.

here is how I defined my variables inside shared_data.c:

#pragma DATA_SECTION(ADCValue_PWM1B,"CpuToCla1MsgRAM");
Uint16 ADCValue_PWM1B;

#pragma DATA_SECTION(ADCValue1,"Cla1ToCpuMsgRAM");
Uint16 ADCValue1;

  • Hi,

    You seem to have the proper use of the #pragma. Can you confirm these are in the proper section from your .map file please.

    Since you have the mdebugstop in Task1, you can connect the CLA target and single step to see what the assembly code is doing and what addresses it is accessing.

    What do you see when you single step?

    Regards,
    sal
  • I Think I am having issues with data types here:

    __interrupt void
    Cla1Task1 (void){
       __mdebugstop();

       ADCValue1= (float)ADCValue_PWM1B*2;
    }

    With the debugger, I find that ADCValue_PWM1B=485( which is what I expect from my ADC) but when I step further I get a value of: 1905092393 for ADCValue1.

    here are my variables declarations again:

    #pragma DATA_SECTION(ADCValue_PWM1B,"CpuToCla1MsgRAM");
    long ADCValue_PWM1B;

    #pragma DATA_SECTION(ADCValue1,"Cla1ToCpuMsgRAM");
    long ADCValue1;


    unsigned long y; 

    Any comments?

  • Something not right here. I declared ADCvalue1 as a float and tried performing the basic calculation below, but it does not give the right answer, I get some huge number like: -5.29....e+32. Could anyone tell me why this is happening? is it a CLA configuration ?

    __interrupt void
    Cla1Task1 (void)
    {
    ADCValue1= 1.2+1.1;
    }
  • Hi,

    The CLA and the C28x have different data type sizes for some data types. Please see the compiler user guide: www.ti.com/.../spru514p.pdf

    It is better to use standard int types from <stdint.h>

    Can you post the assembly of the "ADCValue1 = 1.2 + 1.1;" please?

    Also, what do you see when you singlestep through the code? You can add an __mdebugstop() to the start of the Task.

    Also, how are those variables declared in the header file to the CLA? That may be part of the issue. The CLA code needs a header file with those variables declared there.

    Regards,
    sal
  • I fixed this issue now.

    This CLA task is called from within an ADC ISR. It appears now that this task is called only once even though I am getting ADC interrupts at correct times. Does this have to do with any bits that I have to clear inside CLA task ?
  • I have assigned an ADC to trigger an CLA task:   AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; I have noticed that the CLA is called only once? can any one tells me what I might be missing?

    __interrupt void
    Cla1Task1 (void)
    {
       __mdebugstop();
       ADCValue_PWM1B = AdcResult.ADCRESULT0;
       ADCValue1= ADCValue_PWM1B*2;
    }

    __interrupt void
    cla1_task1_isr(void)
    {
        AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
        PieCtrlRegs.PIEACK.bit.ACK11 = 1;

    }

  • Do yo have the debugger connected to the CLA? If you do, it will halt at the mdebugstop and not be triggered again.

    Make sure it is not connected and it should be triggered continuously. Once the CLA hits an MSTOP which is automatically inserted by the compiler at the end of a task, the CLA will stop running and wait for another trigger to start running again.

    If it isn't triggering again, you can look at the MIER and MIRUN registers to help start your debugging.

    Hope this helps,
    sal
  • Thank for your reply! I am still debugging this I will update you.

    would it be possible to toggle a GPIO inside a CLA task; I need this for debugging to make sure I am indeed accessing the CLA at right times.

    Thanks
  • Hi,

    Yes, the CLA as access to the GPIOs. You may need to give the CLA access to the pin as a master on this device.

    Also, please refer to the CLA math library examples and other CLA examples in C2000Ware which should be helpful.

    Regards,
    sal
  • I added the code below in the ADC ISR and CLA is being called as expected. Can anyone explain what that piece of code has to do with triggering the CLA task.

    EALLOW;
    Cla1Regs.MMEMCFG.all |= CLA_PROG_ENABLE;
    EDIS;

    in main() I already called:
    EALLOW;
    Cla1Regs.MMEMCFG.all = CLA_PROG_ENABLE|CLARAM0_ENABLE|CLARAM1_ENABLE|CLARAM2_ENABLE|CLA_RAM1CPUE;
    Cla1Regs.MCTL.bit.IACKE = 1;
    EDIS;


    adc_isr1(void)
    {
    AdcRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; /* Clr ADCINT2 flag for next SOC */
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; /* Acknowledge interrupt to PIE */

    EALLOW;
    Cla1Regs.MMEMCFG.all |= CLA_PROG_ENABLE;
    EDIS;

    Cla1ForceTask1();

    }
  • Hi Farid,

    It appears you previously did not enable the CLA Program RAM. By not enabling it, the CLA was unable to fetch the CLA program, and this caused the CLA to not execute the code in Task1 and subsequently to hang likely in an infinite loop and never get triggered again. If program RAM was not enabled then the CLA could not fetch the instructions including the MSTOP which would have halted the CLA Task and allowed it to get triggered again,

    Hope this helps!
    sal