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.

PWM

Hello ,

I have a point in the PWM that I don't understand , it is

When to use the system clock as the basic module clock , and when to use the clock divider.

If I used the system clock, the load register will have a value that is different from the value that will be assigned to it if clock divider is used , so what will happen if I use the system clock or divider to generate as for example a 10KHz PWM .

  • Your answer will reveal upon your further/deeper read of the MCU manual and/or PWM Code Examples.

    The System Clock - or its divided replica - is fed to the PWM Generators. Indeed you are correct - that is one "control element" impacting PWM output value. Yet there are additional control elements - you have control over both the PWM frequency and the PWM duty cycle - and that w/almost total independence from your selected System Clock.

    You must note that (both) PWM Frequency and Duty Cycle are adjustable - which enables you to select the most appropriate clock rate for the PWM Generators. Again PWM Frequency & Duty Cycle are adjusted by your specification of the, "Number of System Clocks" (parameters) employed by each of those two PWM functions.

    As a (very) simple example - should you "half" the system clock you'd have to (likewise) reduce the pertinent parameter values w/in (both) PWM Frequency and PWM Duty Cycle to gain an identical PWM output.

    Following the vendor's PWM code examples - and use of a scope or logic analyzer - will drive home these points...

  • Hello Muhammad

    The clock divider works on the system clock and provides an alternate clock other than the direct system clock. It is a pre-divided clock. So all load values are now referred to the same. As an example a load value of X which leads to 10KHz PWM at system clock would result in 5KHz PWM when the pre divider of 2 is used.
  • Hello sir ,

    So ,is it better to use clock divider when lower frequency is required ?

    And in the example you wrote , in this case what is the better to use system clock or divider ?

  • Hello Muhammad,

    For the TM4C129x with the system clock of 120MHz and the maximum load count of 2^16, a PWM of ~1831 Hz is possible. So if the range required is even smaller than that then yes, of course.