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.

TM4C1290NCPDT -- Accurate PWM Generation using

Other Parts Discussed in Thread: TM4C1290NCPDT

Dear Sir / Madam

i have TM4c1290NCPDT TIVA ware uC which i want to use to generate the Square wave signal with Desired Freq but with Fine Accuracy i.e. i want to use it with 50 Khz and Also with 5Khz too but with accruacy of +/- 0.1Hz.

I have used the PWM Generator Block for the same.

But it will not work properly.

Suppose i want to Generate the PWM with 4KHz signal then i should write the as per formula in uPWMload is:

My system clock is 60MHz now divisor is 64 so 60000000/64 = 937500 now in order to make 4kHz signal i have do : 937500/4000 = 234.375

Now i have to load in ROM_PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 234.375);but the API wants the unsigned int so it will be truncated to 234 so it will give me e

altered from 4KHz to 3.963 KHz now what should i want to do? for the correct 4KHz.

Thanks and regards

Pradhan

  • Hi,

    Look for DDDS chip here:

  • HI Petrei

    Can you please suggest me any change in the program to get the accurate PWM frequency.

    will it be mandatory to use Analog device chip only?
    Thanks and regards
    Pradhan
  • Hi,

    As you already observed, it is not possible to have the required accuracy with actual PWM module. This is due also to the nature of digital dividers implemented. For more specific needs like your it is better to use a specialised chip. The suggested one is cheap enough to be used; but of coarse, you know better other undisclosed requirements to decide for or against its use.

  • Hi

    Thanks for your reply, but my main concern is how will I use this waveform as the base frequency for my PWM generation.

    Can you please advice. As per my knnowledge, ucontroller will generate its own base frequency based on the value we give in software.

    Awaiting for your kind response.
    Pradhan
  • This appears to be the "second of N" identical, posted requirements - most likely a school assignment. Should not such questions be addressed to the teacher - or his/her assistants?

    In particular - I'd ask the teacher, "How might a simple MCU achieve so tight (0.1Hz) a tolerance when multiple variables - some outside of the MCU's control/domain - surely will impact results? Perhaps a far more thoughtful assignment would be one which, "Maximizes the MCU's accuracy" - NOT one which targets an "unachievable" objective!
  • Hi,

    You claim this: "i want to use to generate the Square wave signal with Desired Freq but with Fine Accuracy " in your first post on this thread - if so, then use the suggested chip instead the PWM to get the signal. If you still need a PWM, then you should ask for "generate a pulse signal" with specified duty factor.

  • cb1_mobile said:
    This appears to be the "second of N" identical, posted requirements - most likely a school assignment. Should not such questions be addressed to the teacher - or his/her assistants?

    Also perhaps the two can get together, sometimes it's easier to deal deal with the instructor as a group rather than fearing exposing yourself as ill-prepared.

    e2e.ti.com/.../522602

    cb1_mobile said:

    In particular - I'd ask the teacher, "How might a simple MCU achieve so tight (0.1Hz) a tolerance when multiple variables - some outside of the MCU's control/domain - surely will impact results?

    Somehow. I suspect that's not quite what the instructor requested. But you never know.

    Robert

    And sometimes the instructor is looking for pupils to find why something is impossible

  • Robert Adsett said:
    Somehow. I suspect that's not quite what the instructor requested

    While "in the realm" the fact that "now" two have made the identical (unreasonable) request strongly suggests that posters are simply repeating what they've been told.

    The spectacular "imbalance" between poster understanding and requirement's presentation signals (immediately) that NOT, "All is well."

  • It could be they've miss-interpreted precision as meaning accuracy.

    Showing understanding that difference could even be part of the reason for the exercise.

    Robert
  • Hello Pradhan,

    I believe what you are asking is how do you set the device up so you get divisors that divide evenly to achieve exactly the PWM frequency that is targeted. To do this you would need to select a system clock that divides down evenly so that it is not truncated since the control registers do not accept fractional values. This is often the case with clock generation within an MCU and is often an obstacle in communications with exact baud rates, implementing real time clocks in MCUs, etc. The added complexity of the range of PWM frequencies with consistent precision requirements makes this a impossible task as you will always have errors due to the precision of the dividers somewhere in the range unless you define specific frequencies that are multiples of the base frequency.

    Some devices may offer precision PWM capability where they can handle not only the integer parts of the divisors but also a separate fractional divisor to further tune the clocks/PWMs. There are certainly specialized devices that give very precise PWM signals. For example, other than stand alone specialized PWM generating devices, I believe that TIs C2000 product line has implemented high precision PWM capability in some of their devices as this is often needed in some complex motor control applications. (link to one such MCU is www.ti.com/.../tms320f28067)

    Outside of the above information, I have outline additional contributors to clock accuracy within the MCU in the original thread on this topic located here.
    e2e.ti.com/.../1900872