Working on with quad encoders. used A and A pins. I kept ctrl register as 8001. still I counter is not counting.. I also want direction register to set. any sample code or Application note will be helpful.
See attached example testing quadrature count mode of the eTimer module.
It sets some eTimer channels and FlexPWM to generate quadrature signals and another eTimer channel for a Quadrature count mode.
Thanks for reply.. Now counter is running..
But how to find speed and direction. Now Encoder input is applied with train of pulses in A and with 90deg offset with A. With this how to find speed and direction. Actually now I can see counter running and it keeps reducing. Some calculation need to be done?
The speed measuring method depends on sensor signal (frequency range). The interrupt can be used, but it is not sufficient for high rates. You can also use the capture feature then read the period upon needs, etc. It is so application dependent I think.
There is no “flag” which say you if counter is counting up/down in Quadrature count mode. The easiest way how to get the direction is to take two counter samples and calculate the difference.
But you can also do it in HW way; set the output mode for the counter which asserts OFLAG when counting up and cleares when counting down. You can use this output as secondary input for other channel within module. If this channel will be stopped, then the CTRL2[INPUT] bit will reflect that direction. If this channel will be started you can also detect the OFLAG edge and generate interrupt on direction change.
Retrieving data ...