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: CLA not working when boot from flash

Part Number: TMS320F28069

Hi,

I tried booting my code from flash by modifying the cmd file (28069_RAM_CLA_C_lnk.cmd).

 I have manged to compile my code with no errors, but in my debug code my debugger hangs at Cla1ForceTask4andWait();  Can anyone please say what might be the issue for CLA not to be triggered.  attached is a copy of my main.c file and cmd file.

6076.main.zip

  • Hi,

    Did you make sure that you are copying the CLA code from flash to run from CLA RAM?

    You need to perform a memcpy of the CLA program and data from flash to RAM.

    It appears the CLA is not able to execute and finish the task you are forcing.

    Regards,
    sal
  • Hi Sal,

    I am just back to fix this CLA issue. I have followed you advice and invoked init_cla() function from main(). So far I have managed to have my code access the Cla1Task1 whenever an ADC EOC interrupt occurs . However, I noticed that the data does not get stored at Cmpns2.Ref, and Cmpns2.Fdb. I just see zero values when I keep stepping through the code till I exit the function.

    here is how I declared Cmpns2 in a .cla file:
    #pragma DATA_SECTION(Cmpns2, "Cla1DataRam1");
    CNTL2P2Z_CLA Cmpns2;

    I also declared the 2 lines below in main.c file.

    #pragma CODE_SECTION(cla1_task1_isr, "ramfuncs");
    interrupt void cla1_task1_isr(void);

    __interrupt void
    Cla1Task1 (void)
    {
        __mdebugstop();

        Cmpns2.Ref=BoostControl_Ref;
        Cmpns2.Fdb=(float) AdcResult.ADCRESULT0;  //Multiply by 1/(2^12) to convert it to per unit float;

        /* Compute the error */
        Cmpns2.Errn=Cmpns2.Ref-Cmpns2.Fdb;
        /* PreSat = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 + u(n-1)*A1  - Ref converted to float from Q24 */
        Cmpns2.OutPreSat = Cmpns2_Coef.b2*Cmpns2.Errn2 +Cmpns2_Coef.b1*Cmpns2.Errn1 + Cmpns2_Coef.b0*Cmpns2.Errn + Cmpns2_Coef.a2*Cmpns2.Out2 + Cmpns2_Coef.a1*Cmpns2.Out1;
        /* store history of error*/
        Cmpns2.Errn2 = Cmpns2.Errn1;
        Cmpns2.Errn1 = Cmpns2.Errn;

        Cmpns2.Out=Cmpns2.OutPreSat;

        /*  Saturate the output, use intrinsic for the CLA compiler */
        Cmpns2.Out=__mminf32(Cmpns2.Out,Cmpns2_Coef.OutMax);
        Cmpns2.Out=__mmaxf32(Cmpns2.Out,Cmpns2_Coef.OutMin);

        /* store the history of outputs */
        Cmpns2.Out2 = Cmpns2.Out1;
        Cmpns2.Out1 = Cmpns2.Out;

    }

    Please see attached a copy of my .cmd file. I don't know what I still need to do to get my CLA working form the flash. I worked with other processors before and I never run to issues as I did now with the flash. Please help!

    I dont mind sharing my code in private communication.

    2335.cmd.zip

    Cheers,

    Farid

  • Farid,

    Can you ensure that Cla1DataRam1 is linked to a RAMLS block and that you have properly configured that LS block for CLA data?

    That is the only thing I can think would be wrong here. If you can step through the CLA code, then you can be sure the CLA program is operating correctly.

    Also keep in mind the CLA and C28x data types are different. You should use stdint data types for this reason.

    sal
  • Hi Sal!

    I am assigning Cla1DataRam as below:

    Cla1DataRam1          : > RAML2,      PAGE = 1

    PAGE 1 :

      BOOT_RSVD   : origin = 0x000000, length = 0x000050     /* Part of M0, BOOT rom will use this for stack */
      RAMM0       : origin = 0x000050, length = 0x0003B0     /* on-chip RAM block M0 */
      RAMM1       : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */

      RAML2       : origin = 0x008C00, length = 0x000400     /* on-chip RAM block L2 */

    I also want to let you know that my code run as it should with CLA when I boot from RAM, so I doubt I have issues with data types in CLA. The only issue i am sure of is the setup of this cmd file for boot from the flash. I is just so frustrating I had to spend so much on this so far and yet no progress. I never had issues load code to the flash with other processors.

    Please help me move on.

  • on other cmd files I see this included:

    CLAscratch :
    { *.obj(CLAscratch)
    . += CLA_SCRATCHPAD_SIZE;
    *.obj(CLAscratch_end) } > RAML1, PAGE = 1

    do I need to have it, and what is it for?

    also I have these in my .cla file:
    #pragma DATA_SECTION(Cmpns1_Coef, "Cla1DataRam1");
    #pragma DATA_SECTION(Cmpns2_Coef, "Cla1DataRam1")
    #pragma DATA_SECTION(Cmpns3_Coef, "Cla1DataRam1");

    do I need to create sections for them in the cmd file?

    I wish there is some tutorial that explains step by step how the cmd file is created for boot from flash.

    Regards,
    Farid
  • Hi Farid,

    That scratchpad is there to act as a stack for the CLA C code.

    Please see the CLA math library examples. They are set up to execute fro both RAM and flash.

    It appears you are doing things correct, but obviously something is missing.

    Can you confirm you have properly copied the CLA1Prog and ramfuncs from flash to RAM? Also, what is the behavior you are seeing on the CLA? Can you set a breakpoint in the CLA code and step through it? Is the CLA running at all?

    sal
  • Hi Sal!

    The CLA is running but the variables inside the CLA do not change( get updated) at all. for example, I created this variable called temp for debugging in shared_data.c:

    #pragma DATA_SECTION(temp1,"CpuToCla1MsgRAM")
    float temp1=100;

    also at shared.h I made this declaration: extern temp1;

    in main.c file, I made temp1=33; and in the CLA I tried to se it to 77; but when I setup through my code in CLA, i find the value for temp1 is equal 33; this value now got updated only in main, but it did not get updated in CLA. If this says something to me,  it says that temp1 is not shared between CLA and C28, even though my declaration of the variable as shared is clear above. Just don't know whats happening.

  • Hi,

    The CLA cannot write to memory in the CPUtoCLA1 message RAM. It can only read from it. CLA can read and write to and from CLA1toCPU message RAM.

    This should help.

    sal
  • Hi Sal!

    I created a temp variable as below in shared_data.c file as below and then in shared.h I used the word extern: exten int temp.

    #pragma DATA_SECTION(temp, "Cla1DataRam1");
    int temp=1;

    inside the cla: I tried to increment temp: temp=temp+1.

    However even the cla is running it always reads 1 and never increment the temp value, which has always been the problem.

    Am I declaring cla data correctly?
  • interesting enough, now if I declare temp as:
    #pragma DATA_SECTION(temp, "Cla1ToCpuMsgRAM");
    int temp=1;

    the temp value gets incremented. I just don't know what is the problem when it is declared as Cla1DataRam1
  • I had to change my data that I allocated as "cla1dataram1" as "Cla1ToCpuMsgRAM", and then my code runs. I really would like to know what my code does not run when I allocated variables for use only by CLA as Cla1DataRam1.
  • Hi,

    I am a little unclear from your latest comments.

    Perhaps CLA1DataRam1 was not properly configured by the master C28x as CLA data memory. You need to make sure the CLA has proper access to what it is trying to read from and write to.

    sal