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.

TM4C123GH6PGE: how to count impulses via the PWM peripheral

Part Number: TM4C123GH6PGE
Other Parts Discussed in Thread: EK-TM4C1294XL

Hey,

I am new to the TM4C123GH6PGE series. I like to monitor the speed of a fan. This fan provides a "tacho" signal, that generates 2 pulses for one rotation. My idea is to count the impulses in a time interval of 1 second.
After checking the datasheet I am thinking, that it is possible to use the PWM peripheral to do that job for me.
I was looking for some example code, but I didn't found some. So I am asking here for some help.

my fan is driven via PH5 -> M0PWM5 (currently I just use a GPIO output and set it to 1 = max speed)
the fan tacho signal comes back via PH6 -> M0PWM6

How do I need to setup my pins and the pwm0 peripheral to count the impulses for a certain amount of time?
How do I should use the fault, generator1, generator2, ..., generator3 ISR?

Any ideas or references to code snipes?
Stefan

  • Hello Stefan,

    I am not certain how you would use PWM to do this, maybe I am not understanding your intention here but PWM is an output of the device so I don't really see how to use it to monitor this.

    I would instead recommend you look at our TM4C129x example project for timer_edge_capture which can be found in the boards/ek-tm4c1294xl folder of TivaWare example projects. This would be a better means to do this, and the same concept would apply for TM4C123x. This would also mean you don't need a measurement over 1 second either. And it would be able to catch variations in the pulse length.

    I think that is the best solution for this but please let me know if you feel differently and we can brainstorm other ideas.

    Best Regards,

    Ralph Jacobi