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.

TMS320F28075: Using Time Base Module Counter

Part Number: TMS320F28075


Am a little confused with the configuration of the ePWM module particularly the Time base counter. 

I would like to generate a PWM using the Time base module, Capture Compare module, Action qualifier module and dead band module. The PWM signals will be used to control a single phase inverter and dual interleaved boost converter. 

I've read the manual and I have a relatively good understanding of how to use the stated ePWM and microcontroller.

I will be using the Time base counter in Up count mode. The frequency of the PWM is 50kHz and I will be nomarlizing the control value i.e. the maximum value to the compare capture registers will be 1. 

In order to have this done, I will set the time base counter value to 1 and the Time base period to a value I will calculate using the formula provided in the manual as shown below;

EPWM_setTimeBaseCounter(EPWM2_BASE, 1U);//set time base counter of ePWM2 to 1

EPWM_setTimeBasePeriod(EPWM2_BASE, EPWM_TIMER_TBPRD);//Time base period count is defined by macro EPWM_TIMER_TBPRD

What does the manual mean when it says an event gets generated when "Time base counter equals the specified period". From my point of view, the period is on the x axis (time) and the counter increments along the Y axis. In my code, I want the value of the Time base counter to be 1 at the end of every cycle. 

How can I have this done? 

  • Correction Counter compare instead of capture compare.
    How do I get to set the amplitude of the Time Base Counter (Pulse Width Modulator)?
  • Hi,

    You would want to set the Time base period that corresponds to the PWM switching frequency. 
    This is the period of the time base counter.

    "15.4.3 Calculating PWM Period and Frequency" section of the TRM has the calculations needed for the Period. You can use the UP counter related configuration details.

    Please go through short training below to understand the configuration of the epwm module.

     https://training.ti.com/getting-started-c2000-epwm-module

  • Thanks Subrahmanya.
    As is stated in the manual and the training video, the Time base counter counts to a value equal to the period.
    So the control value (what's put into the Counter Compare A and B registers) has to obey the inequality 0<=CMPA<=TBPRD.
  • Hi, That's correct! for CMPA match event to occur 0<=CMPA<=TBPRD.

    EPWM_setTimeBaseCounter - This function sets the 16 bit counter value of the time base counter. This is like setting the initial value of the time base counter.

    EPWM_setTimeBasePeriod - This function sets the period of the PWM counter.

    So, for your case you need to choose EPWM_TIMER_TBPRD to equal the period of the PWM output. EPWM_TIMER_TBPRD can not be 1. This value needs to be calculated and set as explained in "15.4.3 Calculating PWM Period and Frequency"