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.

TMS320F28377D: How to choose the interrupts?

Part Number: TMS320F28377D

Hello,

Maybe this the basic questions. I look for some answers online and I didn't get it.

There are many kinds of interrupts, ADC, EPWM AND EPWM_TZ interrupt.  What is the difference among them? Which one should I choose?

I used once for ADCA1 and once EPWM1_TZ, now I look back and I am confused.  Does anyone can help me understand it?

For example, I need to choose one from the following list. Why should I choose it?

ADCA1 interrupt

EPWM1_TZ interrupt

EPWM1 interrupt

Thanks,

Emily

  • Hi Emily,

    Hongmei Wan said:

    ADCA1 interrupt

    EPWM1_TZ interrupt

    EPWM1 interrupt

    The above 3 interrupts are for 3 different purposes namely:

    ADCA1 interrupt - ADC interrupt based on conversion.

    EPWM1_TZ interrupt - ePWM tripzone interrupt

    EPWM1 interrupt - ePWM interrupt based on set frequency.

    Hongmei Wan said:
    For example, I need to choose one from the following list. Why should I choose it?

    What is the requirement?

    Regards,

    Gautam

  • Thanks, Gautam.

    I know the name but I don't exactly know when to use it.

    Now I am using ADCA1 interrupt. I ask me why I use it and I have to say I don't know. Could you please give me suggestions in what conditions I use it?

    My PWM frequency is 300kHz. Three boards interleaving. Sensing 3 currents in total, 2 voltages in total, 2 temperatures each ( 6 in total ).

    Only one interrupt function I would write for each board.  Inside the function of  __interrupt void adc_isr(void) would mainly be closed-loop calculations for buck-boost converter.

    In the following code,

    What I think is: EPwm10Regs.ETSEL.bit.SOCASEL = 1;    -> to set when (conunter of EPWM10 =0) to sample and start the conversion, and  AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 5;   ->  EOC5 is trigger for ADCINT1. I think it will go to the interrupt function of __interrupt void adc_isr(void) at the end of SOC5  because I give the settings of AdcdRegs.ADCSOC5CTL.bit.  However it doesn't go into __interrupt void adc_isr(void) when the value of AdcaRegs.ADCINTSEL1N2.bit.INT1SEL is above 2.

    What I understand is if I need SOC15, then it will go into __interrupt void adc_isr(void) to run the code at the end of SOC15, so AdcaRegs.ADCINTSEL1N2.bit.INT1SEL would be set as 15. Other wise it won't finish the conversions. It seems all the SOCs will be done whatever this value of AdcaRegs.ADCINTSEL1N2.bit.INT1SEL is. Why? What value I need to give?

    __interrupt void adc_isr(void)
    {

        i= AdcaResultRegs.ADCRESULT0;
        j= AdcbResultRegs.ADCRESULT0;
        k= AdccResultRegs.ADCRESULT0;

        m= AdcaResultRegs.ADCRESULT1;
        n= AdcbResultRegs.ADCRESULT1;

        T0= AdcdResultRegs.ADCRESULT0;
        T0= AdcdResultRegs.ADCRESULT1;
        T0= AdcdResultRegs.ADCRESULT2;
        T0= AdcdResultRegs.ADCRESULT3;
        T0= AdcdResultRegs.ADCRESULT4;
        T0= AdcdResultRegs.ADCRESULT5;

    }

    void ConfigureADC(void)
    {
        EALLOW;
        // ADC-A
        AdcaRegs.ADCCTL2.bit.PRESCALE = 6;             // Set ADCCLK divider to /4; 0110 ADCCLK = Input Clock / 4.0
        AdcaRegs.ADCCTL2.bit.RESOLUTION =  0;         // 12-bit resolution
        AdcaRegs.ADCCTL2.bit.SIGNALMODE = 0;         // Single-ended channel conversions (12-bit mode only)
        AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;        // Set pulse positions to late
        AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;            // Power up the ADC

      // setting of ADC-B ADC-C ADC-D, same as ADC-A

        DELAY_US(1000);
    }

    void SetupADCEpwm(void)
    {
        EALLOW;
        //SOC0, Inductor current IL
        AdcaRegs.ADCSOC0CTL.bit.CHSEL = 4;              // SOC0 will convert pin A4, inductor current of BIU1
        AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14;         // Sample window is ...?
        AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA

        AdcbRegs.ADCSOC0CTL.bit.CHSEL = 4;              // SOC0 will convert pin B4, inductor current of BIU2
        AdcbRegs.ADCSOC0CTL.bit.ACQPS = 14;         // Sample window
        AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA


        AdccRegs.ADCSOC0CTL.bit.CHSEL = 4;              // SOC0 will convert pin C4, inductor current of BIU3
        AdccRegs.ADCSOC0CTL.bit.ACQPS = 14;         // Sample window
        AdccRegs.ADCSOC0CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA

        //SOC1, battery voltages
        AdcaRegs.ADCSOC1CTL.bit.CHSEL = 14;             //SOC1 will convert pin ADCIN14, Vb1
        AdcaRegs.ADCSOC1CTL.bit.ACQPS = 14;         // Sample window
        AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA

        AdcbRegs.ADCSOC1CTL.bit.CHSEL = 15;             //SOC1 will convert pin ADCIN15, Vb2
        AdcbRegs.ADCSOC1CTL.bit.ACQPS = SAH_time;         // Sample window
        AdcbRegs.ADCSOC1CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA


        //Temperature sensing
        AdcdRegs.ADCSOC0CTL.bit.CHSEL = 0;          // SOC0 will convert pin D0, temperature of BIU1
        AdcdRegs.ADCSOC0CTL.bit.ACQPS = 14;         // Sample window
        AdcdRegs.ADCSOC0CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA
        AdcdRegs.ADCSOC1CTL.bit.CHSEL = 1;          // SOC1 will convert pin D1, temperature of BIU1
        AdcdRegs.ADCSOC1CTL.bit.ACQPS = 14;         // Sample window
        AdcdRegs.ADCSOC1CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA

        AdcdRegs.ADCSOC2CTL.bit.CHSEL = 2;          // SOC2 will convert pin D2, temperature of BIU2
        AdcdRegs.ADCSOC2CTL.bit.ACQPS = 14;         // Sample window
        AdcdRegs.ADCSOC2CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA
        AdcdRegs.ADCSOC3CTL.bit.CHSEL = 3;          // SOC3 will convert pin D3, temperature of BIU2
        AdcdRegs.ADCSOC3CTL.bit.ACQPS = 14;         // Sample window
        AdcdRegs.ADCSOC3CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA

        AdcdRegs.ADCSOC4CTL.bit.CHSEL = 4;          // SOC4 will convert pin D4, temperature of BIU3
        AdcdRegs.ADCSOC4CTL.bit.ACQPS = 14;         // Sample window
        AdcdRegs.ADCSOC4CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA
        AdcdRegs.ADCSOC5CTL.bit.CHSEL = 5;          // SOC5 will convert pin D5, temperature of BIU3
        AdcdRegs.ADCSOC5CTL.bit.ACQPS = 14;         // Sample window
        AdcdRegs.ADCSOC5CTL.bit.TRIGSEL = 0x17;         // Trigger on ePWM10 SOCA

        //end of SOCs trigger flag for interrupt
        AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0;         // EOC5 is trigger for ADCINT1
        AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;           // Enable INT1 flag
        AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;         // Make sure INT1 flag is cleared
        EDIS;

        DELAY_US(10000);
    }

    void InitEPwm10(void)
    {
        EALLOW;
        EPwm10Regs.TBCTL.bit.CTRMODE = 3;           // Freeze counter for now
        EPwm10Regs.TBPRD = SW_PRD;                   // Same period as PWM1
        EPwm10Regs.TBCTL.bit.PHSEN = 1;             // Enable phase loading
        EPwm10Regs.TBPHS.bit.TBPHS = 0;                // Phase
        EPwm10Regs.TBCTR = 0x0000;                  // Clear counter
        EPwm10Regs.TBCTL.bit.HSPCLKDIV = 0;         // MAX speed 100MHz; set ratio to 1/2 SYSCLK
        EPwm10Regs.TBCTL.bit.CLKDIV = 0;            // same as HSPCLKDIV???
        EPwm10Regs.TBCTL.bit.SYNCOSEL = 0;            //sync in clock signal  ??

        EPwm10Regs.ETSEL.bit.SOCAEN    = 0;            // Disable SOC on A group
        EPwm10Regs.ETSEL.bit.SOCASEL = 1;//2;        //Select SOCA on -  1: zero, 2:period, 3: zero or period
        //EPwm10Regs.ETSEL.bit.SOCAEN = 1;             // Enable the ADC Start of Conversion A (EPWMxSOCA) Pulse
        EPwm10Regs.ETPS.bit.SOCAPRD = 1;            // Generate pulse on 1st event
        EDIS;

        // Start ePWM 10 to begin ADC sampling and interrupts
        EPwm10Regs.ETSEL.bit.SOCAEN = 1;                    //Enable the ADC Start of Conversion A (EPWMxSOCA) Pulse
        EPwm10Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;        //enable up-down mode
    }

  • Hi Hongmei,

    Since ADCA only goes through 2 conversions (SOC0 and SOC1), ADCA-SOC2 through ADCA-SOC5 are never triggered. Because of this, if you set AdcaRegs.ADCINTSEL1N2.bit.INT1SEL to 2 through 5 (or higher) nothing will happen.

    You can either trigger:

    Interrupt ADCD1 with AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 5

    or

    Interrupt ADCA1 if you add dummy samples to ADCA SOC2 through ADCA SOC5

  • Thank you very much, Devin.

    That is very interesting. I never knew it.

    1. Where  can I get this information " ADCA only goes through 2 conversions (SOC0 and SOC1) " ?   How many conversions does Interrupt ADCD1 go through?

    2.  Interrupt ADCD1 with AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 5  or  Interrupt ADCA1 if you add dummy samples to ADCA SOC2 through ADCA SOC5,  which one is better?

    3.  When AdcaRegs.ADCINTSEL1N2.bit.INT1SEL=0, does this mean at the end of SOC0 we only can get the result0 and  the program goes into the interrupt?

    If  AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 5, we can get the result0 through result5?

    Thanks,

  • Hi Hongmei,

    1) This is based on your code. Since for ADCA only SOC0 and SOC1 are configured to use trigsel = 0x17, only SOC0 and SOC1 will convert when this trigger happens.

    2) Using the interrupt ADCD1 will require some configurations to the PIE/Interrupt configurations. Filling in dummy conversions on ADCA will require more changes to the ADC settings. I'm not sure if one is inherently better. Do you have other tirgger sources other than 0x17? If so, it might be slightly better to fill out the dummy conversion slots on all ADCs to ensure synchronous operation between the multiple ADCs.

    3)Yeah, if the interrupt is triggered at the end of SOC0, SOC1 (and any subsequent SOCs that are configured) could still be converting. If you try to read the result1 register in the ISR, you could get the old value.

    But yeah, if you use INT1SEL = 5, results 0 through 5 should be ready. The problem is that if SOC5 isn't configured to convert, SOC5 will never happen and therefore the ISR will never happen.
  • A lot of thanks to you, Devin.