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 replacement for ADC ISR using C code

Other Parts Discussed in Thread: TMS320F28063, CONTROLSUITE, TMS320F28069

I'm having time critical application which is updated from ADC ISR of TMS320F28063 device.

I wanted to know can the same functionality be done from CLA?

The controlSUITE example of "cla_adc_fir_flash" is having the calculations in assembly language, can other applications be done using C program?

If so please guide me on how the implementation is done.

  • Ravi,

    There is a CLA C example in the online C2000 multi-day workshop.

    processors.wiki.ti.com/.../C2000_Multi-Day_Workshop

    See lab #9.

    - David
  • Sir,

    Please can u guide me more on this. I'm referring to the "F28069 Workshops" Lab 10 examples.  

    This examples compiles without errors, but if I change the device to F28063 then I'm getting gmake errors. I have attached the image of problems occurring in CCS. 

    Please suggest the necessary changes. 

  • Ravi,

    The post you made doesn't show what the error is. Look at the build console and it will show you what the problem is. I suspect what happened is that you changed the processor in the project, and CCS automatically added in another linker .cmd file for that processor (28063_RAM_link.cmd). You need to remove it, and then modify the lab10.cmd for the memory in the F28063 (vs. F28069, which is the original processor).

    Regards,
    David
  • Sir,

    I loaded the Lab 10 program meant for 28069 directly without changing the device and linker file to 28063.

    The EPWM1A signal was seen, but the EPWM2A (used for ADC SOC) was not generated and the program didn't stop in the Cla1Task1() at __mdebugstop().

    I wanted to read ADCRESULT0 at xDelay[0], but the valiue didn't change even by varying the signal at ADC channel 0.

    Please help me understand the problem.
  • Ravi,

    So it occurs to me, the F28063 does NOT have the CLA.  See the datasheet sprs698f, p.7, Table 3-1.  Without the CLA, obviously the code isn't going to work!

    Regards,

    David

  • Sir,

    I'm really sorry. I should had have checked whether CLA was supported for F28063.

    I started by reading the TRM for F2806x devices and the "controlSUITE\device_support\f2806x\v110\F2806x_examples\cla_adc" example.

    Can you please tell me for parallel processing is CLA the only way ?
  • Ravi,

    Ravi said:

     
    Can you please tell me for parallel processing is CLA the only way ?

    Your original problem statement was: "I'm having time critical application which is updated from ADC ISR of TMS320F28063 device."
     
    The CLA would handle the update independent of the CPU.  If you don't have the CLA, then you need to make the ADC ISR high priority.  You would need to enable the ADC interrupt and allow the ADC ISR to nest in all other ISRs.  This will still have more variability than the CLA approach, since at a minimum there will be something like 20 cycles (at least) at the start of other ISRs (including the 10 cycle CPU interrupt response time) before you can get the ADC interrupt re-enabled and nested.
     
    You can also have issues with RPT (repeat) single blocks, if they are in use anywhere in your code.  These blocks are not interruptible, so they can delay interrupts from being taken.  I believe there is a switch in the C compiler to turn off use of RPT.  For ASM code, you can simply look at the code (search the code sources for RPT).  I know RPT is sometimes used in TI code libraries.
     
    - David
  • Sir, 

    I have changed the device to F28069 for implementation of CLA. I first ran the Lab 10 example, I was able to read ADC result 0 values in "interrupt void CLA1_INT1_ISR(void)" located at "DefaultIsr_10_12.c".  

    I wanted to know about "interrupt void Cla1Task1 ()" in "ClaTasks_C.cla". In the example the FIR calculations are done in this function. I tried to increment a count in this function, but the count didn't increase and the program didn't stop at " __mdebugstop()".

    which of the functions:  "interrupt void CLA1_INT1_ISR(void)" or "interrupt void Cla1Task1 ()" is running on a separate clock ?

    Please guide me. 

  • Ravi,

    I downloaded the lab10 from the website you cited in your earlier post, and it works.  You have to remove ClaTasks.asm from the project in order to successfully build.  I assume you did this (or alternately commented out the _ClaTask1 function in ClaTasks.asm).  What's going on here is that the lab had examples of tasks written in ASM and C.  The lab instructions directed the student to use the C task first, then the ASM task.  The solutions have both files in there, and the project picks them both up.  You need to remove one or the other.

    Anyway, you have to connect to both the CPU and the CLA in order for the debugger to halt at the mdebugstop.  Maybe that is the problem.  Also, after connecting to the CLA, use Run->Load->Symbols to load the .out file for your project into the CLA CCS view.  Otherwise, you will not get source level debug with the CLA.

    The CLA normally shows as 'Suspended' (instead of running) since the CLA spends most of its time halted.

    There is some helpful information here on CLA debug:

    http://processors.wiki.ti.com/index.php?title=Control_Law_Accelerator_(C2000_CLA)_Debug_on_CCS_FAQ

    Follow the items for CCSv4 or v5 (since this page is a bit old, and CCS v6 is not listed, but pretty much same thing as v4 or v5).

    Regards,

    David

  • David M. Alter said:

    Anyway, you have to connect to both the CPU and the CLA in order for the debugger to halt at the mdebugstop.  Maybe that is the problem.  Also, after connecting to the CLA, use Run->Load->Symbols to load the .out file for your project into the CLA CCS view.  Otherwise, you will not get source level debug with the CLA.

    The CLA normally shows as 'Suspended' (instead of running) since the CLA spends most of its time halted.

    Sir,

    With your help I was able to see the breakpoint and also incremented a count in "interrupt void ClaTask1()".

    I wanted to include CLA in our project. I'm having two references i.e. Lab12 and "ti\controlSUITE\device_support\f2806x\v110\F2806x_examples\cla_adc_fir_flash" examples.

    I have taken the .cmd file from the controlSUITE example and I'm trying to include CLA initialization according to "Lab12" example as I want to use CLA in C program.


    But I haven't succeeded in including CLA. Please can you tell me what is the proper procedure to include CLA for TMS320F28069 device and how to modify the "controlSUITE example" for F28069, cla_adc_fir_flash" which in assembly to C code.

  • Ravi,

    Attached is a self-contained CCSv6.2.0 project showing CLA task coding in C on F28069 device.  The project is in the Lab10 subfolder.

    /cfs-file/__key/communityserver-discussions-components-files/171/F28069_5F00_CLA_5F00_C_5F00_Example.zip

    Regards,

    David

  • Sir,

    I have tried earlier the project Lab10, which you have mentioned. This project runs from RAM. Lab12 example of the Workshop runs from flash, that example is also running. 

    I was having problems including the CLA flash implementation for TMS320F28069 device. As the Lab12 .cmd (linker) file is for the F28069 experimental kit, so I was using the .cmd from controlSUITE example of CLA FIR flash.

  • Sir,

    I have added CLA C code for flash referring Lab12 example and controlSUITE FIR flash example in our application program. I'm able to read ADC results and also performed calculations in CLA Task 1.

    I wanted to know, how to set/clear/toggle a GPIO in CLA?

    The CLA is said to be having a separate clock, then also it is dependent on a trigger. I'm having an ADC ISR of 40 us. I wanted to achieve better accuracy by having a high speed count (10 us), which should be unaffected by communication. As the ADC ISR was taking about 25 us, so I wanted to go for CLA to improve on the timing, as the application output can get affected if ADC ISR execution time exceeds 40 us. 

    How can I make the CLA Task 1 to be triggered faster ?

  • Ravi,

    Ravi said:

    I wanted to know, how to set/clear/toggle a GPIO in CLA?

    The CLA does NOT have access to the GPIO in the F2806x devices.  You would need a F2837x or F2807x device for that.

    Ravi said:

    The CLA is said to be having a separate clock, then also it is dependent on a trigger. I'm having an ADC ISR of 40 us. I wanted to achieve better accuracy by having a high speed count (10 us), which should be unaffected by communication. As the ADC ISR was taking about 25 us, so I wanted to go for CLA to improve on the timing, as the application output can get affected if ADC ISR execution time exceeds 40 us. 

    How can I make the CLA Task 1 to be triggered faster ?

    I'm not understanding what you want to do here.  It sounds like your want the CLA to read and process the ADC results.  So then, why not just trigger the CLA task from an ADC interrupt (ADCINTx) when the conversion result(s) is ready?
    - David
  • Sir,

    If I have count which is incremented in CLA Task 1, that count has been moved from "ClaToCpuMsgRAM".

    I want to clear the count in ADC ISR at a specific condition then how should I do that ? as the same variable can't copied from CLA to CPU and vice versa, I'm unable to clear the count, but I can read the value.

    Please guide me.

  • Sir,

    A variable is declared in Main file and made extern in .cla file. The variable is has been assigned from CLA to CPU Msg RAM. The variable is incremented in CLA task 1, can this variable be initialized to a different value (e.g. variable made 0) in ADC ISR ?

    I'm unable to clear a variable which is assigned from CLA to CPU Msg RAM.

    Please, does any one know about this ?

  • Ravi,

    The CPU has read-only access to the CLA-to-CPU message RAM.  The CPU cannot write to it.

    What you can do is use a spare CLA task that is triggered by software to initialize the CLA-to-CPU RAM.  The F2806x workshop lab 10 (which I believe you said you have from the web) actually shows an example of this.  In the file ClaTasks_C.cla (the CLA tasks, written in C in this case):

    /**********************************************************************
    * Task: CLA Task 8
    *
    * The delay elements xDelay are placed in the section ClaToCpuMsgRAM.
    * The C28x does not have write access to this array. Therefore, this
    * array will not be initialized at startup time by the cinit routine.
    * The purpose of this task is to do a one-time initialization of the
    * delay buffer and set the elements to zero.
    **********************************************************************/
    interrupt void Cla1Task8 (void)
    {
        // Local Variables
        int16 i;

        __mdebugstop();

        for(i = 0; i < 5; i++)
        {
         xDelay[i] = 0.0;  
        }
    }

    and in the file Cla_10.c, function InitCla(), the CPU triggers the task, once:

    //--- Enable use software to start a task (IACK)
        Cla1Regs.MCTL.bit.IACKE = 1;        // Enable IACKE to start task using software

    //--- Force one-time initialization Task 8 - zero delay buffer
        Cla1Regs.MIER.all = 0x0080;            // Enable CLA interrupt 8
        asm("  IACK  #0x0080");                // IACK - CLA task force instruction
        asm("  RPT #3 || NOP");                // Wait at least 4 cycles
        while(Cla1Regs.MIRUN.bit.INT8 == 1);   // Loop until task completes

    Regards,

    David