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: using timer CCP0 and CCP1 with the same timer

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

hey,

I have a pcb where the pins PH6(WT4CCP0) and PH7(WT4CCP1) are wired to the tacho pins of 2 fans.

I like to monitor the fan speed via the timer 4 counters that are triggered through CPP0 and CPP1. How to do this?

So far I only found an example for one ccp for timers(https://www.programmersought.com/article/84445560134/)

  • Hello Stefan,

    Can you describe a bit more about what you are looking to get in terms of an output here?

    Are you looking to count the number of positive edges, number of negative edges, time between positive edges, high time of the signal?

    Also if the example I shared before wasn't sufficient, what did you find lacking with it?

    Best Regards,

    Ralph Jacobi

  • morning Ralph,
    > Can you describe a bit more about what you are looking to get in terms of an output here?
    I like to measure the rising or falling edges of the digital tacho signal. So far I did not asked for a output here(through I like to control the fan speed through pwm - but this is an other topic)
    > Are you looking to count the number of positive edges, number of negative edges, time between positive edges, high time of the signal?
    exactly - I like to count the edges. No matter if rising, falling or both. Since my signal is known to me the I can easily calculate the fan speed/frequency.
    > Also if the example I shared before wasn't sufficient, what did you find lacking with it?
    sorry - I don't have the tiva examples here - maybe you can share a link to a common repro on github or so

    To make this question a bit more generic:
    I have 2 signals S1 & S2.
    S1 -> PH7 -> WT4CCP1
    S2 -> PH6 -> WT4CCP0

    These 2 signals are connected to timer 4.
    Is it possible to sense the rising/falling edge count of s1 & s2 parallel with timer 4? ;)

  • Hi Stefan,

    The counts should definitely be possible yes, thanks for the added detail, I can clearly understand the objective here now!

    The prior program I had shared with you was an example project in TivaWare, but it was focused on the edge width and not the count of edges.

    I will see about putting together a basic program together for you tomorrow that can do the count measurement on two pins. I may not use those exact pins depending what is available on the LaunchPad but it would be transferable to other timers.

    Best Regards,

    Ralph Jacobi

  • Hello Stefan,

    Alright this project should hopefully give you what you need here. It's a bit rudimentary in terms of the application itself but it shows all the configurations. Since I needed two signals, I re-used a Dead Band PWM example so there's no real offset between the A and B counts.

    The project is intended to be used by connecting PD2 and PD3 to PB7 and PB6 on the EK-TM4C123GXL LaunchPad. This feeds the M0PWM0/1 from PB6/7 output into the Wide Timer 3 CCP0/1 input on PD2/PD3.

    There are interrupts setup to trigger when a certain number of edges are counted. This is set to 1000, which means the interrupts will trigger every 4 seconds because the PWM is running at 250 Hz (so 250 edges per second).

    When those interrupts trigger, the UART should update with a message of the latest count of Match interrupts generated, and an LED will blink every 8 seconds based on odd/even match count for Timer A. ...The LED is admittedly not that useful but I needed it for debug so I left it there :).

    Ultimately, this should give you every aspect you may need. I wasn't sure if you needed the interrupt per say, so I just made sure to leverage that as well so it's also available to reference.

    Here is the full project, let me know how it works! timer_edge_count.zip

    Best Regards,

    Ralph Jacobi

  • perfect
    I missed the match value set and I had my CCP pins wrongly configured
    you example perfectly helped me. thx alot