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.

TMS570LC43x ePWM Frequency

i want to generate a PWM from 0 Hz to 500KHz.

how can i calculate it?

e.g for a PWM with a frequency of 20Hertz i need set Period time to 50000000.

I cannot set 

etpwmSetTimebasePeriod(etpwmREG1, 50000000);

because of the second parameter is a uint16 value

isnt it?

sample code:

etpwmSetClkDiv(etpwmREG1, ClkDiv_by_1, HspClkDiv_by_1);/* Set the TBCLK frequency = VCLK3 frequency = 75MHz */
etpwmSetTimebasePeriod(etpwmREG1, 74);/* Set the time period as 1000 ns (Divider value = (1000ns * 75MHz) - 1 = 74)*/

  • Hi,

      You will need to prescale the VCLK3 to increase the timebase. With your current setp the timebase is 75MHz or 13.3ns. You need to adjust the CLKDIV and HSPCLKDIV such that your timebase is large enough for you to set the PWM period at 20Hz.  

    void etpwmSetTimebasePeriod ( etpwmBASE_t etpwm,
    uint16  period 
    )

    Sets period of timebase counter.

    Parameters
    etpwm The pulse width modulation (ETPWM) object handle (etpwmREG1..7)
    period 16-bit Time-base period

    This function sets period of timebase counter