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.

系统中断及PWM配置

各位老师大家好,我正在学习PWM算法,运行的是TI的例程,现在遇到一些问题。

控制芯片采用的是F28035,工作频率为60MHz

1、首先是主程序的设置:

EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.EPWM1_INT = &MainISR;//全局中断采用PWM中断
EDIS;

// Enable PIE group 3 interrupt 1 for EPWM1_INT
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;

// Enable CNT_zero interrupt using EPWM1 Time-base
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable EPWM1INT generation
EPwm1Regs.ETSEL.bit.INTSEL = 1; // Enable interrupt CNT_zero event
EPwm1Regs.ETPS.bit.INTPRD = 1; // Generate interrupt on the 1st event
EPwm1Regs.ETCLR.bit.INT = 1; // Enable more interrupts
InitCommros();

这样全局中断就采用的是PWM中断吧?

那为什么程序中或设置的中断频率是10khz呢?

// Define the ISR frequency (kHz)
#define ISR_FREQUENCY 10

2、第二个问题就是PWM的PeriodMax 参数设置,

程序中关于PeriodMax 的定义为:

typedef struct {
Uint16 PeriodMax; // Parameter: PWM Half-Period in CPU clock cycles (Q0)
int16 MfuncPeriod; // Input: Period scaler (Q15)
int16 MfuncC1; // Input: EPWM1 A&B Duty cycle ratio (Q15)
int16 MfuncC2; // Input: EPWM2 A&B Duty cycle ratio (Q15)
int16 MfuncC3; // Input: EPWM3 A&B Duty cycle ratio (Q15)
int16 PWM1out;
int16 PWM2out;
int16 PWM3out;
} PWMGEN ;

这个对应的寄存器就是TBPRD吧?

那为什么要将PeriodMax这么设置呢? 

 pwm1.PeriodMax = SYSTEM_FREQUENCY*1000000*T/2;  // Prescaler X1 (T1), ISR period = T x 1 

//=60MHz*1000000*1/10khz

非常感谢!!!