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: ADC settings to trigger interrupt

Part Number: TMS320F28377D


Tool/software:

I want to do the following : 

1. at pwm count = 0 sample my signal using ADC 

2. Once ADC conversion has been done, generate a End Of Conversion  pulse. Trigger the interrupt based on this EOC

This is my code for this : 

PWM settings : 


EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable INT   I dont think this is the correct setting
EPwm1Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 1st event

// EPWM ADC settings
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable ADC A start of conversion
EPwm1Regs.ETSEL.bit.SOCBEN = 0; // Disable ADC B start of conversion
EPwm1Regs.ETSEL.bit.SOCASEL = 1; // Enable event time-base counter equal to zero

ADC settings : 

AdcaRegs.ADCCTL2.bit.RESOLUTION = 0;
AdcaRegs.ADCCTL2.bit.PRESCALE = 0;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 convert ADCINA0 which is mapped to my signal at the board 
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 19; //SOC0 uses sample duration of 20 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //SOC0 begins conversion on ePWM1 SOCA
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // ADCINT1 is enabled ... I think this is needed 
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // EOC0 is trigger for ADCINT1

how is the EOC 0 triggering the interrupt ? 

Any idea if this looks okay  ? 

  • Hello,

    EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable INT   I dont think this is the correct setting

    EPwm1Regs.ETSEL.bit.INTEN = 1; is not necessary, as you're not using the EPWM interrupt. You can set it to 0.

    You could refer to TRM chapter 11.7 EOC and Interrupt Operation. Each SOC has a corresponding end-of-conversion (EOC) signal. This EOC signal can be used to trigger an ADC interrupt. The ADC can be configured to generate the EOC pulse at either the end of the acquisition window or at the end of the voltage conversion. This is configured using the bit INTPULSEPOS in the ADCCTL1 register.

    Regarding the EOC0 triggering the interrupt:

    When the ADC conversion is complete, the EOC0 flag is set.

    The AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; setting tells the ADC to trigger an interrupt on EOC0.
    The AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; setting enables the ADCINT1 interrupt.
    When the EOC0 flag is set, the ADCINT1 interrupt is triggered.


    In addition, make sure you've enabled the ADCINT1 interrupt in the PIE (Peripheral Interrupt Enable) register.
    In your interrupt service routine (ISR), you should clear the EOC0 flag and the ADCINT1 interrupt flag to prevent multiple interrupts from being triggered. TRM 11.7.1 Interrupt Overflow
    Overall, your code looks good, and with these minor adjustments, it should work as expected.