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.

How to System clock affect PWM width step?



Hello all,

So I am using TivaWare to generate PWM. I want to understand how exactly the “PWMGenPeriodSet” command influences the step of the PWM.

Let me get more specific. In the “TivaWare™ Peripheral Driver Library” (page 433) is says that PWMGenPeriodSet has 3 argument. The 3o argument is:

-          ui32Period: specifies the period of PWM generator output, measured in clock ticks.

How does this affect my PWM width step?

 

By experimenting I saw this:

Had a system clock at around 8MHz and with 320 width step (ui32Period=320). Sent the PWM to a LED. After that I reduced my system clock to 4MHz and left the width step the same. The LED would light up must faster and more sharply.

 

Why exactly is this happening? How can I calculate what is the max width step of the PWM according to the system clock? (in other words, how accurate can I get with a width of the PWM by using a X MHz system clock)

  • Hi Dimitrios,

    Could you explain a bit better?
    Are you varying the duty at all?
    What do you mean about lights up faster and more sharply? Are you varying the period or the duty? If so how?

    That function, PWMGenPeriodSet, sets the period of the PWM while PWMPulseWidthSet is the one that sets the PWM duty.
    The 3rd parameter for PWMGenPeriodSet is the period in clock cycles. So either at 8Mhz or 4Mhz it takes 320 cycles. But in terms of second at 4Mhz 320 cycles takes longer than 8Mhz (double the period).
    The maximum value is 65535 since the PWM module has a 16bit counter.