I need to capture the position from an optical coder. No problem with that, I configured the quadratic decoder hardware on my SAME70 and it works well. It increments / decrements the counter and resets on index edge.
The problem I have is that the timers are 16bits (too bad on a 32b MCU !!) and I have 180 000 edges per rotation, which does not fit in a 16b counter :/
The "Solution" I did is to get the interrupt on overflow, and increment a variable (named diz). So combining diz and CV0 gives me the position.
I also use TC_QIER_IDX interruption to reset diz.
The following image shows that:
Until here, no problem.
What is problematic is if I turn in the other way. I can't detect the "underflow" on TC0 (going from 0x0000 to 0xFFFF), so I can't decrement diz. Here is what happens :
So 2 questions:
- Do you think to a better solution than using interrupts? Some kind of counter configuration to automatically increment another counter on overflow
- If no, do you see a solution for my the described problem when I decrement my counter?
Thanks in advanced