Tool/software: Code Composer Studio
Hi, I have an application where I have a quadrature encoder mounted to a motor and I need to very accurately represent position in single turn and multi turn. Ideally it would be best if I could configure the EQEP module to represent position in both ways. In single turn the QPOSCNT would be reset either by the index event or when QPOSCNT reaches the max ticks of the encoder. In multi turn the QPOSCNT would continue to accumulate position throughout multiple encoder rotations.
I'm not seeing a way to support this functionality in hardware. So my options seem to be either 1) connect the quadrature signals to two different EQEP modules and have one handle the single turn case and the other handle the multiple turn case. This doesn't work for my current application since the hardware was not designed to accomodate this.
The second option the the approach I'm currently using is to look for overflow or underflow events in software and manually keep track of adding or subtracting MAX_ENCODER_TICKS when this occurs. This works ok, but sometimes the PCU/PCO (under/overflow) flags are not synchronized with the QPOSCNT register. What I mean by this is that I'll detect an overflow or underflow event in the foreground but don't see the corresponding jump in QPOSCNT, or vice versa. While i'm checking the over/underflow flags in the foreground, i've tried disabling the PCO/PCU interrupts in the QEINT register during the critical section where I read the flag values and the QPOSCNT value, but this didnt appear to help.
Is there some way to guarantee that PCU/PCO flags are synchronized with the QPOSCNT register so that its not possible to read one before the other updates?