I Have the following situation:
I have a motor controller SPEED leg connected to pin #40 (PB11: EXTINT.11 / TC5.1).
The motor controller sends over that leg a rising edge for every one third of a rotation of the motor and I'm interested in figuring the rounds per second (RPS) of the motor.
I found 2 ways to figure out the RPS:
- Assign an interrupt handler to that pin and increase a counter on every event.
Once a second divide that counter by 3 and you get the RPS.
- Use TC to do that for you instead of implementing most of it in software.
Whenever I feel like it I will read the CC register and get the current speed.
Problem with number one is that it involves too much software work in the sense that it halts execution etc.
My problem with the second possible implementation is that I havent found a driver for that.
When I look in start.atmel.com I can find 2 drivers that use TC/TCC:
Timer & PWM.
Is there a driver that does what I'm interested in or do I need to write a driver from scratch ?
Is there an example on how to do something similar ? (TC that does "something" based on input from IO pin)