I'm using mpc5777 and I'm going to use the encoder A and B with GPIO179, GPIO180. I'm going to use Quadrature mode at this time, but I organized the code as follows. Should I do it like this?
void init_eMIOS_QEDC(void)
{
eMIOS_0.MCR.B.GPREN = 1;
eMIOS_0.MCR.B.GPRE = 0;
//GPIO179 eMIOS_0채널 24
eMIOS_0.UC[24].C.B.MODE = 0x0D; //Quadrature
eMIOS_0.UC[24].C.B.BSL = 0x03; // Internal counter
eMIOS_0.UC[24].C.B.EDSEL = 1;
//GPIO180 eMIOS_0채널 25
SIU.PCR[179].R = 0x0600; // Configure GPIO179 for eMIOS0 (A-phase)
SIU.PCR[180].R = 0x0600; // Configure GPIO180 for eMIOS1 (B-phase)
if(eMIOS_0.UC[24].S.B.OVFL==1)
{
OVFLG += 1;
eMIOS_0.UC[24].S.B.OVFL=1;
}
Counter = eMIOS_0.UC[24].CNT.R;
// Counter = eMIOS_0.UC[24].A.R;
}
The counting value is eMIOS_0.UC[24].CNT.R This one or eMIOS_0.UC[24].A.R; Where is this saved?
Hi,
if GPIO179, GPIO180 are going to be used, eMIOS_0 ch 0 and ch1 are available on those pins. Thus eMIOS_0 ch1 have to be set to QDEC mode, not ch 24 you have. Counting value is read from eMIOS_0.UC[1].CNT.R register.
Moreover you will need to configure IGF module, otherwise inputs does not pass to eMIOS module. See more in https://community.nxp.com/t5/MPC5xxx/How-to-setup-eMIOS-QDEC-function/m-p/905051
BR, Petr