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 task interrupted by ADC

Other Parts Discussed in Thread: CONTROLSUITE

Hello,

I'm triggering the CLA Task through an ADC interrupt generated after EOC using the configuration in ADC_SOC_CNF.c to get adcresult values (atleast say 1k). In particular, I set the ADC to operate in CLA mode.

The issue is that the CLA task runs just once at the start of the program.

Can anyone guide how can I configure the CLA task (or the ADC) to run continuously so that I can capture atleast 1k values.

Sincerely,

Jaspreet

 

  • Hello!

    Did you try to use for basis ti\controlSUITE\device_support\f2806x\v136\F2806x_examples_ccsv5\cla_adc or this project is not appropriate for you?

    Regards,

    Igor

  • Hello Igor,

     

    Thank you for recommending the sample project, but it didn't helped me much.

    Since I'm interrupting the CLA Task from ADC EOC, and we cannot clear the ADC interrupt in the CLA Task I have cleared the interrupt flag in the main.c.

    __interrupt void cla1_isr1()

    {

        AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;    // Clear ADCINT1 flag reinitialize for next SOC

        PieCtrlRegs.PIEACK.all = 0xFFFF;

    }

    Can you please guide if Is this the right way to proceed or I need to modify something else.

    Sincerely,

    Jaspreet

     

     

  • Hi Jas, (Hi Igor)

    Since I'm interrupting the CLA Task from ADC EOC, and we cannot clear the ADC interrupt in the CLA Task I have cleared the interrupt flag in the main.c

    The above statement contradicts to the code below!

    __interrupt void cla1_isr1()

    {

        AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;    // Clear ADCINT1 flag reinitialize for next SOC

        PieCtrlRegs.PIEACK.all = 0xFFFF;

    }

    Anyways, by clearing the adc interrupt in main.c will limit you retrieving only 1 adc value i.e. loop executes only once and thats exactly what you're experiencing. 

    So you'll have to include the adc interrupt in CLA and not in main.c

    Regards,

    Gautam

  • Hello Gautam,

    Thank you for your input.

    I didn't understood why you mentioned the statement contradicts with the code. Can you please elaborate.

     

    I have been reading the CLA wiki docs to resolve the issue as below.

     

    Q: If the CLA takes an ADC interrupt, can it then clear the ADC's interrupt flag?

    No.  The CLA can not access the ADC configuration registers so it can not clear the ADC interrupt flag.  Here are three options for handling this:
    Option 1
    Place the ADC in continuous mode.  In this mode the next conversion will start, when triggered, even if the flag is still set.  
    Option 2
    Service the ADC interrupt with the main CPU as well as the CLA and have the main CPU clear the flag.
    Option 3
    Have the main CPU service the end of task interrupt from the CLA and clear the flag.

    The above code was used to perform Option 3.

    Apart from this, I have configured the ADC in CLA mode (start stop mode with auto clr INT Flag) defined in the ADC_SOC_Cnf.c. Certainly this instruction should clear the flag and allow to re-run the CLA Task. But not performing as said.

    Sincerely,

    Jaspreet

  • I'll have to look into your main function too then... can you attach your whole implementation?

    Regards,

    Gautam

  • Hi Jaspreet,

    Allow me to ask some questions:

    • Are you clearing the correct flag ? I.e. is ADC 1 the correct one?
    • How do you trigger the ADC after an interrupt occured?
    • Did you check if the interrupt overflow error register was set?

    BR Andreas

  • Hello Gautam and Andreas,

    Please find complete implementation for your review.

     

    0647.DPLibTemplate-F2806x.zip

     

    Sincerely,

    Jaspreet

  • Sorry, I'll  be leaving now. I hope Igor/Andreas solves your problem. If not will be back tomorrow.

    Regards,

    Gautam

  • Jaspreet,

    In your project I cannot find the interrupt service routine you were referring to. Am I blind or is it missing in the project?

    Furthermore in main line 121 you are initializing your ADC to use channel 2

           // Configure the ADC with auto interrupt clear mode
           // ADC interrupt after EOC of channel 2
            ADC_SOC_CNF(ChSel, TrigSel, ACQPS, 1, 2);

    But as I understand you would like it on channel 1...

    Did you try debugging your code in order to see what happens?

    BR Andreas

  • Hello Andreas,

    My bad, I accidently removed it.

    Please find attached modified main.c2086.CLAproject-main.c.docx

    I think ADC_SOC_CNF(ChSel, TrigSel, ACQPS, 1, 2); is configured to use channel 1. There is a typo in the comment.

    I have debugged the code and observe that CLA Task runs once while updating only the Err and Err1 of the 3p3z controller.

    Any ideas what I have done wrong.

    Sincerely,

    Jaspreet

     

     

  • OK, next one then: I am not 100% certain that this is necessary as I didn't use Core with CLA yet, but where do you tell the PIE which function to call, when your interrupt occurs?? something like

    PieVectTable.CLA1INT = &cla1_isr1();

    Andreas

  • Andreas,

    I'm not sure either. I had a look on the example code which Igor mentioned.

    During the debug I noticed that Interrupt flag bits in PIEIFR11 for CLA_Task1 and CLA_Task8 are set to 1 while the PIEIER11 are cleared.

    On other note, the ADCINT1 is mapped in PIE Group Vector 1 as INT1.1 and in Group Vector 10 as INT10.1, what is the difference between the two.

    Sincerely,

    Jaspreet

     

  • Hi Jaspreet,

    I looked quickly at your code. 

    The function ADC_SOC_CNF's fourth parameter is the channel number which its end of conversion will trigger ADCINT1 interrupt, which in turn, will trigger your CLA interrupt. You passed 1 as the channel triggering an interrupt but you only have channel 0 configured to be sampled. I think 0 should be passed instead of 1. Also, if you use mode 2 for this function, you don't need an interrupt resetting the interrupt flag. Your PWM will trigger a SOC, the ADC will convert one channel ( #2 ), and then after EOC0, CLA task 1 will be triggered. 

    I'll check for other details later on.

    Regards,

  • Hello Mosin,

    Certainly you are right, my bad.

    Thank you.

     

    Sincerely,

    Jaspreet