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.

TMS320F28379D: PWM Default System Clock

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Hi,

I am practicing to generate a PWM signal in TMS320F28379D Launchpad Development Kit.

I want to know the default PLLsystemClk to the PWM module and the Default TBCLK I will be getting from PWM pins.

I have configured the board to operated in 200MHz using PLL with 20Mhz External Oscillator.

I have the default values:

ClkCfgRegs.PERCLKDIVSEL[EPWMCLKDIV] = 2;
TBCTL[HSPCLKDIV] = 1;
TBCTL[CLKDIV] = 2;

If my system clock is 200Mhz, I will be getting 50Mhz as TBCLK after the Prescale divisors.
But my PWM frequency is only 25Mhz. Why?

Questions:

I want to know whether I am missing anything to configure more? why I am getting 25Mhz instead of 50Mhz?

  • Hi Manohar,

    Please check the description of the above mentioned register bits as this config would lead to 25 MHz. E.g.
    ClkCfgRegs.PERCLKDIVSEL[EPWMCLKDIV] = 2; // this configures epwmclk = 200MHz as x0 = /1 of PLLSYSCLK

    TBCTL[HSPCLKDIV] = 1; // configures /2
    TBCTL[CLKDIV] = 2; // configures /4
    Above config results in TBCLK = 200Mhz/(2x4) = 25Mhz

    Thanks
    Vasudha
  • Hi Vasudha,

    Appreciate your fast reply.

    I have checked the registers you shared with me and below are the register values(default)
    ClkCfgRegs.PERCLKDIVSEL[EPWMCLKDIV] = 1; // configures/2
    TBCTL[HSPCLKDIV] = 0; // configures/1
    TBCTL[CLKDIV] = 1; // configures/2
    Configured PLLSystemClock to be 200Mhz. From the above register settings I should get TBCLK to be 50Mhz,But its giving me 25Mhz.

    Tpwm = (TBPRD + 1) * Ttbclk; //TBPRD = 0
    My PWM is UP counter mode, I have made the TBPRD register to zero. So the Tpwm = Ttbclk.

    Question:
    Instead of 50Mhz, Why I am getting 25Mhz? Is there any configuration I am still missing?

    Regards,
    Manohar
  • Hi Manohar,

    You should not be setting TBPRD value to zero. Please refer to EPWM examples in C2000Ware to get more details on pwm configuration.

    Thanks
    Vasudha
  • Thank you Vasudha.
    I know that TBPRD register is to get the exact clock frequency of PWM.

    Tpwm = (TBPRD + 1) * Ttbclk; //TBPRD = 0

    The above formula is for PWM frequency calculation. I want to map the TBCLK directly to PWM clock, So making it as zero.

    Just confirm me what exact TBCLK I will be getting if I configure the following register with 200Mhz System Clock?
    ClkCfgRegs.PERCLKDIVSEL[EPWMCLKDIV] = 1; // configures/2
    TBCTL[HSPCLKDIV] = 0; // configures/1
    TBCTL[CLKDIV] = 1; // configures/2

    I am getting 25Mhz clock in PWM pin.


    Regards,
    Manohar
  • Just confirm me what exact TBCLK I will be getting if I configure the following register with 200Mhz System Clock?
    ClkCfgRegs.PERCLKDIVSEL[EPWMCLKDIV] = 1; // configures/2
    TBCTL[HSPCLKDIV] = 0; // configures/1
    TBCTL[CLKDIV] = 1; // configures/2

    The above configuration will set TBCLK as 50 MHz. But I think you have configured the time-base counter in up-down mode and since the TBPRD value is 0, the output frequency is coming as 25 MHz.

    To get 50 MHz frequency, you can configure TBCLK as 100 MHz and TBPRD value as 1.

    Thanks

    Vasudha

  • Hi Vasudha,

    Just clarify me only one thing. So that I don't want you to get distracted from my query.

    System Clock = 200Mhz //From PLL
    Time Base counter mode = UP_MODE
    ClkCfgRegs.PERCLKDIVSEL[EPWMCLKDIV] = 1; // configures/2
     TBCTL[HSPCLKDIV] = 0; // configures/1
     TBCTL[CLKDIV] = 1; // configures/2
    TBPRD = 1;

    With the above configuration, what is the expected PWM frequency?

    Regards,
    Manohar

  • TBCLK freq will be 50MHz & PWM freq will be 25MHz.

  • Thanks Vasudha for your great support.

    Your right.

    if the TBCLK = 50Mhz = 20ns to one clock cycle
    The PWM line gets toggled for each 20ns. which means it requires 40ns to one clock cycle.

    That's the reason I am getting PWM frequency to be 25Mhz instead of 50Mhz.

    This is what I have understood from the scenarios, Can you confirm on it?


    Regards,
    Manohar