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.

TMS320F28027: About ADC and PWM interrupt

Genius 3095 points
Part Number: TMS320F28027


Dear team:

When both ADC and PWM modules are enabled in my program, ADC runs normally, but PWM interrupts cannot be responded to. If the ADC module is disabled, the PWM interrupt can respond.

The trigger source of ADC module is PWM2A, the trigger event is CTR = PRD, PWM interrupt trigger event is CTR = 0.

I have tried to replace the trigger source of ADC module with CPUTimer0. Sampling after replacement is no problem, but the PWM interrupt still does not respond.

Below is my program:

void InitAdc(void)
{
extern void DSP28x_usDelay(Uint32 Count);

// *IMPORTANT*
// The Device_cal function, which copies the ADC calibration values from TI reserved
// OTP into the ADCREFSEL and ADCOFFTRIM registers, occurs automatically in the
// Boot ROM. If the boot ROM code is bypassed during the debug process, the
// following function MUST be called for the ADC to function according
// to specification. The clocks to the ADC MUST be enabled before calling this
// function.
// See the device data manual and/or the ADC Reference
// Manual for more information.

EALLOW;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
(*Device_cal)();
EDIS;

// To powerup the ADC the ADCENCLK bit should be set first to enable
// clocks, followed by powering up the bandgap, reference circuitry, and ADC core.
// Before the first conversion is performed a 5ms delay must be observed
// after power up to give all analog circuits time to power up and settle

// Please note that for the delay function below to operate correctly the
// CPU_RATE define statement in the F2802x_Examples.h file must
// contain the correct CPU clock period in nanoseconds.
EALLOW;
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Power ADC BG
AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // Power reference
AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // Power ADC
AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable ADC
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Select internal BG
EDIS;

DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
}

PWM interrupts are modified according to the sample program:

void PWM_ISR()
{
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.EPWM1_INT = &epwm1_isr;
PieVectTable.EPWM2_INT = &epwm2_isr;
PieVectTable.EPWM3_INT = &epwm3_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;// Enable EPWM INTn in the PIE: Group 3 interrupt 1-3
PieCtrlRegs.PIEIER3.bit.INTx2 = 1;
PieCtrlRegs.PIEIER3.bit.INTx3 = 1;
IER |= M_INT3;
EINT;
}

EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // ctr = 0时产生中断
EPwm1Regs.ETSEL.bit.INTEN = 1; // enable PWM interrupt
EPwm1Regs.ETPS.bit.INTPRD = 1; // Generate INT on 3rd event

Best regards