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.

请问period=300时,开关频率设为200KHz,那之后的TBPRD为什么为3000,不等于300,当period=380时,TBPRD又该为多少?

#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

  • 这为UP-DOWN模式
    EPwm7Regs.TBPRD = 3000; // Set timer period 3000 TBCLKs
    EPwm7Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
    EPwm7Regs.TBCTR = 0x0000; // Clear counter
    // Setup counter mode
    EPwm7Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
    EPwm7Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
    EPwm7Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
    EPwm7Regs.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 = PRD
    EPwm7Regs.ETPS.bit.INTPRD = ET_1ST; // Generate pulse on 1st event
  • 不知道你的程序中“period”是指什么?PWM_1ch_UpDwnCnt_CNF函数具体是什么?
    TBPRD是时基周期寄存器,它的计算公式是Tpwm = (TBPRD + 1) x Ttbclk,不知道公式中的这几个参数是否跟“period”有关?
x 出现错误。请重试或与管理员联系。