In my previous implementation of QD with FTM1 and FTM2 on my K22F processor, I didn't bother to check for the correct sign on the feedback because I figured I could just invert it or swap the wires. Well, now I'm back to testing and have found that the sign is incorrect.
On other processors I have used, like the dsPIC, I can just invert the polarity of the input channels. I've tried this in the following ways:
- set the FTM_QDCTRL_PHAPOL_MASK and FTM_QDCTRL_PHBPOL_MASK bits in FTMx_QDCTRL
- cleared the FTM_QDCTRL_PHAPOL_MASK and FTM_QDCTRL_PHBPOL_MASK bits in FTMx_QDCTRL
- set the Invert Polarity setting in Processor Expert
- all permutations of the above
In *all* cases, the sign of my encoder value is always the same. I would have expected one of the combinations to result in a flipped sign.
In the process of debugging this, I realized that I had never checked the "Quadrature decode initialization" checkbox in processor expert:
I interpreted this to mean that even though I have "Quadrature decode configurations" checked, the settings in the configuration list as shown below would *not* take effect:
So I also tried to check "Quadrature decode initialization", but when I did this, the encoder readings I got back had the wrong sign *and* magnitude.
At this point, I'm under the impression that 1) I am missing an undocumented step (perhaps another register needs to be cleared before I can invert polarity, 2) processor expert has a bug, or 3) I should just punt on this and swap the wiring.
Can anyone shed some light on this problem that I'm experiencing?