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.

ADC interupts

How to set up multiple ADC interrupts in 2808

  • Hi Waseem,
    Can you elaborate on your question? What do you have working and where exactly are you having issues? Do you have code that works once, but subsequent interrupts are missed? Do you have code with one ISR that works but you want to add additional ISRs?
  • Hi Waseem,

    The "Example_280xAdc.c" sample code already has ISR configured for 2 ADCs. Are you looking for multiple such ISRs or multiple ADC in the ISR?

    Regards,
    Gautam
  • Hi Devin
    I need to sample voltage at different instant within a PWM cycle. I think it is possible only by utilizing a number of interupts to fetch the voltages.
    I am still not able to figure out how for ADC SOC is configured at a particular instant.
  • Hi Waseem,

    Conceptually this is how it would work:

    ePWM module has multiple events that can cause a trigger to the ADC: zero crossing, period match, compare A, and compare B. Each ePWM has two events, SOCA and SOCB. Configure the SOCA and SOCB triggers in the ePWM module to occur at the intended time. If you need to trigger at more than 2 instants, you will need to synchronize another ePWM module and then use the additional events from that module.

    Now configure an ADC SOC for each event. Each ADC SOC has the following: ACQPS setting, trigger setting, channel setting. For each ePWM event configure an ADC SOC to have use the corresponding ePWM event as a trigger. Set the channel based on what external signal you want to convert at that instant (if you want to convert the same signal at multiple points in the ePWM cycle, these channel settings would all be the same). Set the ACQPS value based on the external input network to allow adequate settling.

    Now that all the SOCs are configured, you can decide how you want to collect the data. If your control algorithm runs once per ePWM cycle, you can just set the last SOC that occurs in time to trigger a single interrupt. In the interrupt, you can read all the data from the ADC and then adjust the duty/phase/frequency of the ePWM to achieve the control that you need. If you want to make adjustments during the ePWM cycle, or if you want to start pre-computing values before then end of the ePWM cycle, you can set each SOC to trigger its own interrupt.
  • Hi Devin

    Thanks for your detailed explanation.. i Need some more explanation about

     What did u mean by Configuring an ADCSOC

    Also how different data can be read from ADC.

    Regards

    Waseem

  • Waseem Ahmad said:
     What did u mean by Configuring an ADCSOC

    Configuring ADCSOC is nothing but selecting the trigger source:

    Waseem Ahmad said:
    Also how different data can be read from ADC.

    Through ADCRESULT register. For eg.

    Regards,

    Gautam

  • Hi Devin
    I am doing this but not able to figure out where i went wrong. I am just listing the adc code where i am sampling the voltage at ADCINA3 pin of dsp repetively at different event and for that i am using epwm6 and 5 as a trigger. once conversion is complete i am genertaing an epwm 5 interupt and storing the result in sam-1 ,sam2 etc..
    could u figure out where i went wrong. i am trying to decipher the same but not able to do
    Regards
    Waseem

    Code is:



    AdcRegs.ADCMAXCONV.all = 0x0003;

    AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x3; // Setup ADCINA3
    AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x3; // Setup ADCINA3


    AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x3; // Setup ADCINA3
    AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x3; // Setup ADCINA3

    AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1
    AdcRegs.ADCTRL2.bit.EPWM_SOCB_SEQ2= 1;// Enable SOCB from ePWM to start SEQ2



    // to trigger adc soc on cmpa

    EPwm6Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group
    EPwm6Regs.ETSEL.bit.SOCASEL = 4; // Select SOC from from CPMA on upcount
    EPwm6Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
    EPwm6Regs.CMPA.half.CMPA = 3000; // Set compare A value
    EPwm6Regs.TBPRD = 5000; // Set period for ePWM1
    EPwm6Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;



    // to trigger adc soc on zero


    EPwm5Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group
    EPwm5Regs.ETSEL.bit.SOCASEL =1; // Select on zero
    EPwm5Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
    EPwm5Regs.TBPRD = 5000; // Set period for ePWM1
    EPwm5Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;


    //to trigger adc soc on cmpa decreasing

    EPwm6Regs.ETSEL.bit.SOCBEN = 1; // Enable SOC on B group
    EPwm6Regs.ETSEL.bit.SOCBSEL = 5; // Select SOC WHEN CCPMA on downcount
    EPwm6Regs.ETPS.bit.SOCBPRD = 1;// Generate pulse on 1st event



    //to trigger adc soc on period


    EPwm5Regs.ETSEL.bit.SOCBEN = 1; // Enable SOC on B group
    EPwm5Regs.ETSEL.bit.SOCBSEL = 2; // Select SOC WHEN COUNTER IS period
    EPwm5Regs.ETPS.bit.SOCBPRD = 1;// Generate pulse on 1st event


    //to trigger generate pwm interupt on zero

    EPwm5Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
    EPwm5Regs.ETSEL.bit.INTEN = 1; // Enable INT
    EPwm5Regs.ETPS.bit.INTPRD = 0x1;







    for(;;)
    {
    asm(" NOP");

    }


    }


    interrupt void epwm5_timer_isr(void)
    {


    sam_2=AdcRegs.ADCRESULT0; //ADCINA3 reault on cmpa
    sam_1=AdcRegs.ADCRESULT1; //ADCINA3 reault on aero
    sam_4=AdcRegs.ADCRESULT4; //ADCINA3 reault on cmpa decreasing
    sam_3=AdcRegs.ADCRESULT5; //ADCINA3 reault on period
  • Hi Gautam.

    I am doing this but not able to figure out where i went wrong. I am just listing the adc code where i am sampling the voltage at ADCINA3 pin of dsp repetively at different event and for that i am using epwm6 and 5 as a trigger. once conversion is complete i am genertaing an epwm 5 interupt and storing the result in sam-1 ,sam2 etc..
    could u figure out where i went wrong. i am trying to decipher the same but not able to do.
    Regards
    Waseem

    Code is:



    AdcRegs.ADCMAXCONV.all = 0x0003;

    AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x3; // Setup ADCINA3
    AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x3; // Setup ADCINA3


    AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x3; // Setup ADCINA3
    AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x3; // Setup ADCINA3

    AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1
    AdcRegs.ADCTRL2.bit.EPWM_SOCB_SEQ2= 1;// Enable SOCB from ePWM to start SEQ2



    // to trigger adc soc on cmpa

    EPwm6Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group
    EPwm6Regs.ETSEL.bit.SOCASEL = 4; // Select SOC from from CPMA on upcount
    EPwm6Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
    EPwm6Regs.CMPA.half.CMPA = 3000; // Set compare A value
    EPwm6Regs.TBPRD = 5000; // Set period for ePWM1
    EPwm6Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;



    // to trigger adc soc on zero


    EPwm5Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group
    EPwm5Regs.ETSEL.bit.SOCASEL =1; // Select on zero
    EPwm5Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
    EPwm5Regs.TBPRD = 5000; // Set period for ePWM1
    EPwm5Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;


    //to trigger adc soc on cmpa decreasing

    EPwm6Regs.ETSEL.bit.SOCBEN = 1; // Enable SOC on B group
    EPwm6Regs.ETSEL.bit.SOCBSEL = 5; // Select SOC WHEN CCPMA on downcount
    EPwm6Regs.ETPS.bit.SOCBPRD = 1;// Generate pulse on 1st event



    //to trigger adc soc on period


    EPwm5Regs.ETSEL.bit.SOCBEN = 1; // Enable SOC on B group
    EPwm5Regs.ETSEL.bit.SOCBSEL = 2; // Select SOC WHEN COUNTER IS period
    EPwm5Regs.ETPS.bit.SOCBPRD = 1;// Generate pulse on 1st event


    //to trigger generate pwm interupt on zero

    EPwm5Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
    EPwm5Regs.ETSEL.bit.INTEN = 1; // Enable INT
    EPwm5Regs.ETPS.bit.INTPRD = 0x1;







    for(;;)
    {
    asm(" NOP");

    }


    }


    interrupt void epwm5_timer_isr(void)
    {


    sam_2=AdcRegs.ADCRESULT0; //ADCINA3 reault on cmpa
    sam_1=AdcRegs.ADCRESULT1; //ADCINA3 reault on aero
    sam_4=AdcRegs.ADCRESULT4; //ADCINA3 reault on cmpa decreasing
    sam_3=AdcRegs.ADCRESULT5; //ADCINA3 reault on period