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.

TMS320F280021: The PIE interrupt of ADC and ADCINT1/ADCINT2 issue

Part Number: TMS320F280021

Hi team,

Here're some issues from the customer may need your help:

When using the ADC Interrupts of the 2800X families:

The 2800x family has four interrupts, ADCINT1, ADCINT2, ADCINT3, ADCINT4.

1. When using the ADCINT1 interrupt, the following 3 tests were performed:

A. When using ADCA1 of the PIE interrupt vector table as the interrupt entry, the interrupt program is working properly, Led_FLASH pin flip time: 17.2us, 80 times. 

PieVectTable.ADCA1_INT  = &adc_A1ISR;     // Function for ADCA interrupt 1

IER |= M_INT1;//T0 ADCINT1

PieCtrlRegs.PIEIER1.bit.INTx1 = 1;// ADCINT1


EPwm1Regs.ETSEL.bit.SOCAEN = 0;     // Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;    // Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;     // Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430;   // Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;           // Set period to 4096 counts

EPwm1Regs.TBCTL.bit.CTRMODE = 3;    // Freeze counter

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;     // SOC0 will convert pin A1
                                           // 0:A0  1:A1  2:A2  3:A3
                                           // 4:A4   5:A5   6:A6   7:A7
                                           // 8:A8   9:A9   A:A10  B:A11
                                           // C:A12  D:A13  E:A14  F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;     // Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;   // Trigger on ePWM1 SOCA

AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;   // Enable INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 0;       //Discontinuous 
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Make sure INT1 flag is cleared

The timer function starts the ePWM conversion for 25 ms 
EPwm1Regs.ETSEL.bit.SOCAEN  = 1;        // Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;   // Unfreeze, and enter up count mode

ADC1 interrupt function
__interrupt void adc_A1ISR(void)
{
    LED_FLASH=1;

    Current.Sum+=AdcaResultRegs.ADCRESULT1;
    if(++Current.ConversionCount==80)
    {
        Current.ConversionCount=0;
        Current.Data=(Current.Sum/80);
        Current.Sum=0;

        EALLOW;
        EPwm1Regs.ETSEL.bit.SOCAEN  = 0;        // Enable SOC on A group
        EPwm1Regs.TBCTL.bit.CTRMODE = 3;   // Unfreeze, and enter up count mode
        EDIS;
    }
    //
    // Clear the interrupt flag
    //
    AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

    //
    // Check if overflow has occurred
    //
    if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT1)
    {
        AdcaRegs.ADCINTOVFCLR.bit.ADCINT1 = 1; //clear INT1 overflow flag
        AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
    }

    //
    // Acknowledge the interrupt
    //
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

B. When using ADCC1 of the PIE interrupt vector table as the interrupt entry, the interrupt program does not run and the interrupt cannot be entered.

PieVectTable.ADCC1_INT  = &adc_C1ISR;     // Function for ADCC interrupt 1

IER |= M_INT1;//T0 ADCINT1

PieCtrlRegs.PIEIER1.bit.INTx3 = 1;// ADCINT1

EPwm1Regs.ETSEL.bit.SOCAEN = 0;     // Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;    // Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;     // Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430;   // Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;           // Set period to 4096 counts

EPwm1Regs.TBCTL.bit.CTRMODE = 3;    // Freeze counter

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;     // SOC0 will convert pin A1
                                           // 0:A0  1:A1  2:A2  3:A3
                                           // 4:A4   5:A5   6:A6   7:A7
                                           // 8:A8   9:A9   A:A10  B:A11
                                           // C:A12  D:A13  E:A14  F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;     // Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;   // Trigger on ePWM1 SOCA

AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;   // Enable INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 0;       //discontinous
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Make sure INT1 flag is cleared

The timer function starts the ePWM conversion for 25 ms 
EPwm1Regs.ETSEL.bit.SOCAEN  = 1;        // Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;   // Unfreeze, and enter up count mode

ADC1 interrupt function
__interrupt void adc_C1ISR(void)
{
    LED_FLASH=1;

    Current.Sum+=AdcaResultRegs.ADCRESULT1;
    if(++Current.ConversionCount==80)
    {
        Current.ConversionCount=0;
        Current.Data=(Current.Sum/80);
        Current.Sum=0;

        EALLOW;
        EPwm1Regs.ETSEL.bit.SOCAEN  = 0;        // Enable SOC on A group
        EPwm1Regs.TBCTL.bit.CTRMODE = 3;   // Unfreeze, and enter up count mode
        EDIS;
    }
    //
    // Clear the interrupt flag
    //
    AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

    //
    // Check if overflow has occurred
    //
    if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT1)
    {
        AdcaRegs.ADCINTOVFCLR.bit.ADCINT1 = 1; //clear INT1 overflow flag
        AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
    }

    //
    // Acknowledge the interrupt
    //
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

C. When using ADCA2 of the PIE interrupt vector table as the interrupt entry, the interrupt program does not run and the interrupt cannot be entered.

PieVectTable.ADCA2_INT  = &adc_A2ISR;     // Function for ADCA interrupt 1

IER |= M_INT10; //ADCINT1

PieCtrlRegs.PIEIER10.bit.INTx2 = 1;// ADCINT1

EPwm1Regs.ETSEL.bit.SOCAEN = 0;     // Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;    // Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;     // Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430;   // Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;           // Set period to 4096 counts

EPwm1Regs.TBCTL.bit.CTRMODE = 3;    // Freeze counter

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;     // SOC0 will convert pin A1
                                           // 0:A0  1:A1  2:A2  3:A3
                                           // 4:A4   5:A5   6:A6   7:A7
                                           // 8:A8   9:A9   A:A10  B:A11
                                           // C:A12  D:A13  E:A14  F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;     // Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;   // Trigger on ePWM1 SOCA

AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;   // Enable INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 0;       //discontinous
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Make sure INT1 flag is cleared

The timer function starts the ePWM conversion for 25 ms 
EPwm1Regs.ETSEL.bit.SOCAEN  = 1;        // Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;   // Unfreeze, and enter up count mode

ADC1 interrupt function
__interrupt void adc_A2ISR(void)
{
    LED_FLASH=1;

    Current.Sum+=AdcaResultRegs.ADCRESULT1;
    if(++Current.ConversionCount==80)
    {
        Current.ConversionCount=0;
        Current.Data=(Current.Sum/80);
        Current.Sum=0;

        EALLOW;
        EPwm1Regs.ETSEL.bit.SOCAEN  = 0;        // Enable SOC on A group
        EPwm1Regs.TBCTL.bit.CTRMODE = 3;   // Unfreeze, and enter up count mode
        EDIS;
    }
    //
    // Clear the interrupt flag
    //
    AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

    //
    // Check if overflow has occurred
    //
    if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT1)
    {
        AdcaRegs.ADCINTOVFCLR.bit.ADCINT1 = 1; //clear INT1 overflow flag
        AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
    }

    //
    // Acknowledge the interrupt
    //
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

2. When using the ADCINT2 interrupt, the following two tests were performed:

a. When using ADCA1 of the PIE interrupt vector table as the interrupt entry, the interrupt program does not run and the interrupt cannot be entered.

PieVectTable.ADCA1_INT  = &adc_A1ISR;     // Function for ADCA interrupt 1

IER |= M_INT1;//T0 ADCINT1

PieCtrlRegs.PIEIER1.bit.INTx1 = 1;// ADCINT1


EPwm1Regs.ETSEL.bit.SOCAEN = 0;     // Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;    // Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;     // Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430;   // Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;           // Set period to 4096 counts

EPwm1Regs.TBCTL.bit.CTRMODE = 3;    // Freeze counter

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;     // SOC0 will convert pin A1
                                           // 0:A0  1:A1  2:A2  3:A3
                                           // 4:A4   5:A5   6:A6   7:A7
                                           // 8:A8   9:A9   A:A10  B:A11
                                           // C:A12  D:A13  E:A14  F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;     // Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;   // Trigger on ePWM1 SOCA

AdcaRegs.ADCINTSEL1N2.bit.INT2SEL = 0; // End of SOC1 will set INT2 flag
AdcaRegs.ADCINTSEL1N2.bit.INT2E = 1;   // Enable INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT2CONT = 0;       //discontinous
AdcaRegs.ADCINTFLGCLR.bit.ADC2NT1 = 1; // Make sure INT2 flag is cleared

The timer function starts the ePWM conversion for 25 ms 
EPwm1Regs.ETSEL.bit.SOCAEN  = 1;        // Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;   // Unfreeze, and enter up count mode

ADC1 interrupt function
__interrupt void adc_A1ISR(void)
{
    LED_FLASH=1;

    Current.Sum+=AdcaResultRegs.ADCRESULT1;
    if(++Current.ConversionCount==80)
    {
        Current.ConversionCount=0;
        Current.Data=(Current.Sum/80);
        Current.Sum=0;

        EALLOW;
        EPwm1Regs.ETSEL.bit.SOCAEN  = 0;        // Enable SOC on A group
        EPwm1Regs.TBCTL.bit.CTRMODE = 3;   // Unfreeze, and enter up count mode
        EDIS;
    }
    //
    // Clear the interrupt flag
    //
    AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;

    //
    // Check if overflow has occurred
    //
    if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT2)
    {
        AdcaRegs.ADCINTOVFCLR.bit.ADCINT2 = 1; //clear INT2 overflow flag
        AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; //clear INT2 flag
    }

    //
    // Acknowledge the interrupt
    //
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

b. When using ADCA2 of the PIE interrupt vector table as the interrupt entry, the interrupt program can run, but the result is not correct: the LED_FLASH pin is flipped for 20 ms (17.2us is set):

PieVectTable.ADCA2_INT  = &adc_A2ISR;     // Function for ADCA interrupt 1

IER |= M_INT10; //ADCINT1

PieCtrlRegs.PIEIER10.bit.INTx2 = 1;// ADCINT1

EPwm1Regs.ETSEL.bit.SOCAEN = 0;     // Disable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 3;    // Select SOC on up-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1;     // Generate pulse on 1st event

EPwm1Regs.CMPA.bit.CMPA = 430;   // Set compare A value to 2048 counts
EPwm1Regs.TBPRD = 862;           // Set period to 4096 counts

EPwm1Regs.TBCTL.bit.CTRMODE = 3;    // Freeze counter

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 7;     // SOC0 will convert pin A1
                                           // 0:A0  1:A1  2:A2  3:A3
                                           // 4:A4   5:A5   6:A6   7:A7
                                           // 8:A8   9:A9   A:A10  B:A11
                                           // C:A12  D:A13  E:A14  F:A15
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;     // Sample window is 10 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;   // Trigger on ePWM1 SOCA

AdcaRegs.ADCINTSEL1N2.bit.INT2SEL = 0; // End of SOC1 will set INT2 flag
AdcaRegs.ADCINTSEL1N2.bit.INT2E = 1;   // Enable INT2 flag
AdcaRegs.ADCINTSEL1N2.bit.INT2CONT = 0;       //discontinous
AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; // Make sure INT1 flag is cleared

The timer function starts the ePWM conversion for 25 ms 
EPwm1Regs.ETSEL.bit.SOCAEN  = 1;        // Enable SOC on A group
EPwm1Regs.TBCTL.bit.CTRMODE = 0;   // Unfreeze, and enter up count mode

ADC1 interrupt function
__interrupt void adc_A2ISR(void)
{
    LED_FLASH=1;

    Current.Sum+=AdcaResultRegs.ADCRESULT1;
    if(++Current.ConversionCount==80)
    {
        Current.ConversionCount=0;
        Current.Data=(Current.Sum/80);
        Current.Sum=0;

        EALLOW;
        EPwm1Regs.ETSEL.bit.SOCAEN  = 0;        // Enable SOC on A group
        EPwm1Regs.TBCTL.bit.CTRMODE = 3;   // Unfreeze, and enter up count mode
        EDIS;
    }
    //
    // Clear the interrupt flag
    //
    AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;

    //
    // Check if overflow has occurred
    //
    if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT2)
    {
        AdcaRegs.ADCINTOVFCLR.bit.ADCINT2 = 1; //clear INT1 overflow flag
        AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; //clear INT1 flag
    }

    //
    // Acknowledge the interrupt
    //
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

Issues:

1) How to configure the interrupt program to work properly as test 1C above?

2) how to configure the interrupt program to run properly as test 2a above? 

3) how to configure the interrupt program to run properly as test 2b above? Interrupts are currently available, but not working properly.

Could you help check this case? Thanks.

Best Regards,

Cherry

  • Hi,

    In 1 B, although ADCC1 is interrupt is configured, ADCC is not configured and hence ADCC1 interrupt will not be generated. 

    In 1 C, EOC trigger for ADCINT2 is not set

    AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC1 will set INT1 flag
    AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // Enable INT1 flag
    AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 0; //discontinous
    AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Make sure INT1 flag is cleared

    Thanks
    Vasudha

  • Hi Vasudha,

    Thanks for your help.

    The PIE interrupt using ADCINT3 is ADCA3 and the PIE interrupt for ADCINT4 is the ADCA4 test. But the PIE interrupt corresponding to ADCINT2 is ADCA2, the interrupt conversion time is abnormal: always 20 ms, but the PIE interrupt using ADCINT1 is ADCA1, which is normal.

    EPwm1Regs.ETSEL.bit.SOCAEN = 0; // Disable SOC on A group
    EPwm1Regs.ETSEL.bit.SOCASEL = 3; // Select SOC on up-count
    EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event

    EPwm1Regs.CMPA.bit.CMPA = 430; // Set compare A value to 2048 counts
    EPwm1Regs.TBPRD = 862; // Set period to 4096 counts

    Dose EpWM trigger need to be configured specifically?

    Thanks and regards,

    Cherry

  • Cherry,

    Tomm the 15th is holiday for both US and India C2000 teams.  Please expect the next reply by Monday end of day.

    Best,

    Matthew

  • Hello Matthew,

    Thanks for your message and this issue has been resolved by the customer. Thanks for your help again!

    Thanks and regards,

    Cherry