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.

MAX PWM frequence

Other Parts Discussed in Thread: TM4C123GH6PM

Hello all,

First let me make my questions and then give more details:

Q1) what is the max PWM I can create (not with the PWM module only)?

Q2) what is the max pulse sequence frequency I can read at?

 

Now for the details.

For Q1 --> How can I calculate the max PWM (not only for this microcontroller but for any). From what I can think of, using timers is the best chose. We give the max clock frequency we can to the timer. We use the interrupt of the timer to toggle a pins output. Then by finding out how many machine cycles each command needs, we can calculate the exact max PWM we can produce (extra question, how fast a command it executed depends on the frequency of the CPU?). Is this the only this to consider when wanting to make the max PWM that the microcontroller can produce?

 

For Q2 --> Similar with before, how fast can I read a pulse sequence? If we use an interrupt for a pin to call when it has a rising edge, then it is only limited by how fast the commands can be executed (machine cycle)?

  • Hi Dimitrios,

    First, you can't have a completely general method. For example, the Tiva timers are different from the MSP430 timers.

    And what you mean by max PWM? Because you can have a really high PWM frequency but no resolution at all.
    With the Tiva you can generate a frequency a third of the system clock. So for the TM4C123GH6PM which has a maximum clock of 80Mhz, the maximum PWM is 80/3Mhz.
    Problems with that: Resolution, you have 3 values for the duty. 0, maximum or half duty.
    Also, the wave will probably not be very neat, not really a perfect square wave.


    "How can I calculate the max PWM (not only for this microcontroller but for any). From what I can think of, using timers is the best chose. We give the max clock frequency we can to the timer. We use the interrupt of the timer to toggle a pins output. Then by finding out how many machine cycles each command needs, we can calculate the exact max PWM we can produce"
    Well, the timers can generate PWM by themselves. What you suggest is basically making PWM by software, no need for that.

    "extra question, how fast a command it executed depends on the frequency of the CPU?"
    If you make this question you still need to learn more about processors.
    CPU frequency influences the speed but not only data. Pipeline, branches, hardware predictions of code, all that influences the speed.
    Search on the web more about that, this goes more to the border of assembly.


    For Q2:
    If you use gpio interrupts, you are limited by the interrupt latency and the time the ISR takes to execute.
    Alternatively you can use the Timers in capture mode which is the best choise.


    So I tell you, read up more, you have very basic questions, even about processors in general, read about that.
    Read also the Tiva datasheet.
    Check out Tivaware and the examples that come with it