#define period 300 //300 cycles -> 200KHz @60MHz CPU
#define period_instr_pwm 120 //512 cycles -> 117k @60MHz CPU
// Configure PWM1 for 200Khz switching Frequency PWM_1ch_UpDwnCnt_CNF(1, period, 1, 0); // Configure PWM2 for 200Khz switching Frequency PWM_1ch_UpDwnCnt_CNF(2, period, 0, 0);
// Configure PWM4 for Instrumentation; 1Mhz switching Frequency PWM_1ch_UpDwnCnt_CNF(4, period_instr_pwm, 0, 0);
EALLOW;
SysCtrlRegs.PCLKCR1.bit.EPWM7ENCLK = 1; // ePWM7
// Setup TBCLK
EPwm7Regs.TBPRD = 3000; // Set timer period 3000 TBCLKs
EPwm7Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm7Regs.TBCTR = 0x0000; // Clear counter
// Setup counter mode
user6103892:这为UP-DOWN模式EPwm7Regs.TBPRD = 3000;// Set timer period 3000 TBCLKsEPwm7Regs.TBPHS.half.TBPHS = 0x0000;// Phase is 0EPwm7Regs.TBCTR = 0x0000;// Clear counter
// Setup counter modeEPwm7Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count upEPwm7Regs.TBCTL.bit.PHSEN = TB_DISABLE;// Disable phase loadingEPwm7Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;// Clock ratio to SYSCLKOUTEPwm7Regs.TBCTL.bit.CLKDIV = TB_DIV1;EPwm7Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
// Configure the Start of Conversion for the ADC.EPwm7Regs.ETSEL.bit.INTEN = 1;// EPwm7Regs.ETSEL.bit.INTSEL = ET_CTR_PRD;// Select Int from counter = PRDEPwm7Regs.ETPS.bit.INTPRD = ET_1ST;// Generate pulse on 1st event
#define period 300 //300 cycles -> 200KHz @60MHz CPU
#define period_instr_pwm 120 //512 cycles -> 117k @60MHz CPU
// Configure PWM1 for 200Khz switching Frequency PWM_1ch_UpDwnCnt_CNF(1, period, 1, 0); // Configure PWM2 for 200Khz switching Frequency PWM_1ch_UpDwnCnt_CNF(2, period, 0, 0);
// Configure PWM4 for Instrumentation; 1Mhz switching Frequency PWM_1ch_UpDwnCnt_CNF(4, period_instr_pwm, 0, 0);
EALLOW;
SysCtrlRegs.PCLKCR1.bit.EPWM7ENCLK = 1; // ePWM7
// Setup TBCLK
EPwm7Regs.TBPRD = 3000; // Set timer period 3000 TBCLKs
EPwm7Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm7Regs.TBCTR = 0x0000; // Clear counter
// Setup counter mode
Green Deng:不知道你的程序中“period”是指什么?PWM_1ch_UpDwnCnt_CNF函数具体是什么?
TBPRD是时基周期寄存器,它的计算公式是Tpwm = (TBPRD + 1) x Ttbclk,不知道公式中的这几个参数是否跟“period”有关?
TI中文支持网



