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.

TMS320F28035-EP: EPWM4 CMPA trigger multiple ADC conversions

Part Number: TMS320F28035-EP

Tool/software:

I've spend several hours trying to find out why my EPWM4 CMPA interrupt is not triggering a series of ADC conversions (SOC1,2,3,4,5. In fact, it's triggering none as witnessed by ADCINTFLG.

I can set a breakpoint at the EPWM4 interrupt, and it is firing as expected. So there must be something with either the EPWM4 configuration or SOC setups.

The goal is to trigger SOC1, SOC2, SOC3, SOC4, and SOC5 from the EPWM4 CMPA event. TBCTR is counting up.  When ADCINT4 occurs (triggered by EOC3), then I will read ADCRESULT1,2,3. ADCRESULT4,5 will be read later.

EPWM4 is setup to trigger SOCA and SOCB (code below)

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//*************************************************
// Configure ePWM4 module
// We don't generate PWM with this one.
//
// PWM Period = 66.67uS, 15KHZ
// Count Up mode
// Set PWM output on Zero
// Clear on CMPA, CMPB compare
// TBCLK = 15MHZ (66.67nS resolution)
// CMPA triggers an ADC SOCA and SOCB event on
// first pulse.
//************************************************
EPwm4Regs.TBPRD = 1000; // Period = 1000 TBCLK counts (1000 x 66.67nS = 66.67uS) was 1799 GAH
EPwm4Regs.CMPA.half.CMPA = 50; // Compare A = 50 TBCLK counts
EPwm4Regs.CMPB = 50; // Compare B = 50 TBCLK counts
EPwm4Regs.TBPHS.all = 0; // Set Phase register to zero
EPwm4Regs.TBCTR = 0; // clear TB counter
EPwm4Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
EPwm4Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Phase loading disabled
EPwm4Regs.TBCTL.bit.PRDLD = TB_SHADOW;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

ADC SOC setup code

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//*******************************************
// SOC1,2,3,4 and 5 are triggered by ePWM4
// CMPA event for measuring:
// SOC1 - I_MOTOR
// SOC2 - I_OFF
// SOC3 - VBUS,
// SOC4 - 3V3,
// SOC5 - TEMPERATURE (INTERNAL)
// These have the next highest priority after
// SOC0. ADC conversions will occur in
// round-robin order once triggered, starting
// at SOC1.
//********************************************
//************************************
// SOC1
// ADCINT2
// ADCTRIG11, EPWM4, ADCSOCA
// ADCINA2, Motor Current, CH2
// Sample Window = 6 (7), 233nS
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I have setup EPWM4 to generate ADCSOCA and ADCSOCB pulses since some of the channels are on ADCINA and some are on ADCINB.

Any help would be appreciated.

Thanks

-----------------------------------------------------------

Additional Information

Checking the EPWM4 ETFLG register, I can see that SOCA and SOCB have been triggered, in addition to the INT flag (register value = 0x000D) This is captured with a breakpoint set at EPWM4 ISR.

But when I look at the ADCINTFLG register (value = 0x0000) is see that no conversions have been completed.

Now you might say that no conversions have had time to complete yet, so no flags will be set (yet). But if I continue to single set out of the interrupt, and continue to step for a long time afterward, no ADCINTFLG ever gets set.

It appears, that at least for EPWM4, that the SOCA and SOCB flags are not triggering ADC conversions.

Also, here is the rest of the ADC initialization code.

You can see that SOCPRIORITY = 1, which sets SOC0 as highest priority, and SOC1-15 are in round robin mode.

 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//***************************************************
// ADC Configuration
//
// ADC external reference
// Reference buffers on
// ADC Powered Up
// ADC Enabled
//
// BandGap circuit powered on
//
// ADC result latched 1 cycle prior to result
// VREFLO internally connected to ADC for sampling
// Temperature sensor connected internally to ADCINA5
//****************************************************
AdcRegs.ADCCTL1.bit.ADCREFSEL = 1; // ADC External references
AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // ADC power on
AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // reference buffer on
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // band-gap powered on (MUST BE ON FOR ADC TO WORK)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Any comments ?

  • Hi,

    I've spend several hours trying to find out why my EPWM4 CMPA interrupt is not triggering a series of ADC conversions (SOC1,2,3,4,5. In fact, it's triggering none as witnessed by ADCINTFLG.

    Are you seeing any change in your ADC results registers? Maybe the interrupt is setup incorrectly. I do not see your code to register or enable the interrupt.

    Thanks,

    Ben Collier

  • Although it shows that I have interrupts enabled in the SOC setups, I do not have the PIE interrupt enabled for these conversions. Instead, I poll the ADCINTFLG register for conversion complete, then clear the flag(s).  I do see some stuff in two of the ADCRESULT registers, but I think it's valid data, just leftovers. No ADCINTFLG was ever set.

  • Gregory,

    Just to confirm, do you see the ADCINT flag being set if you use the AdcRegs.ADCSOCFRC1 register to force a conversion? 

    Thanks,

    Ben Collier

  • Yes. After a manual SW trigger of SOC1-SOC5 using ADCSOCFRC1, ADCINTFLG = 0x3E, and ADCRESUL1-5 has valid (expected) data.

  • Additional information.

    I am still unclear as to whether or not I need to trigger both SOCA and SOCB for round-robbin SOC setups on ADC conversions that span channels across ADCINAx and ADCINBx. Do I need to set the SOC trigger for ADCSOCA on SOC setups that are to convert channels located on ADCINA,  and ADCSOCB on SOC setups that are to convert channels on ADCINB ?

    ADCSOCxCTL has triggers (ADCTRIG11 for ADCSOCA on EPWM4, and ADCTRIG12 for ADCSOCB on EPWM4).

    I've tried setting the SOC triggers to only ADCTRIG11 for all of the round-robin channels. In addition, I've tried setting SOC triggers to either ADCTRIG11 for ADCINA channels, and ADCTRIG12 for ADCINB channels. All with the same result - no conversions triggered.

    In addition, I've tried enabling SOCAEN only in the EWPM4 config. AND both SOCAEN and SOCBEN in ETSEL. Still, no ADC triggers as far as I can tell.

    The ETFLG register for EPWM4 indicates that a SOC pulse has been sent. This screen snapshot shows an example of an SOCAEN only test. It can be seen that the SOCA flag is set along with the INT flag, but no indication of an ADCINTFLG (polled).

    There is every indication that there is some sort of a disconnect between the SOC pulses from the EPWM4 module and the SOC input(s) to the ADC. Manually forcing SOCx on the ADC starts conversions just fine. On the PWM side, the ETFLG says it has sent the SOC pulse, but no conversion has started/completed. I've looked at this from just about every angle, and I just don't see the problem.

  • Gregory,

    I will try to get back to you this week, but I am out of office for the next few days.

    Best Regards,

    Ben Collier

  • Gregory,

    For some reason, I did not think that we had any example with EPWM triggering the ADC SOCs, but I was incorrect. 

    Could you please take a look at the F2802xAdcTempSensor example? 

    I am still unclear as to whether or not I need to trigger both SOCA and SOCB for round-robbin SOC setups on ADC conversions that span channels across ADCINAx and ADCINBx. Do I need to set the SOC trigger for ADCSOCA on SOC setups that are to convert channels located on ADCINA,  and ADCSOCB on SOC setups that are to convert channels on ADCINB ?

    The PWM module can generate SOCA and SOCB events. These are different from the 16 ADC SOCs.

    Each ADC SOC can be triggered by many different sources, including SOCA or SOCB.

    Each ADC SOC can be assigned to any ADC channel.

    Best Regards,

    Ben Collier