hi i am using the MPC5777c EMIOS module in PEC mode for counting the number of pulses given to input channel. The following below is my code
void D_EMIOS_0_PEC_Init(uint8_t ui8_channel_no,uint16_t ui16_GPIO_pin_no)
{
SIU.PCR[ui16_GPIO_pin_no].R = 0x0500;
eMIOS_0.MCR.B.GPRE = 0x81; //130/129+1 = 1MHz
eMIOS_0_UC.UC[ui8_channel_no].A.R = 0;
eMIOS_0_UC.UC[ui8_channel_no].B.R = 10;
eMIOS_0_UC.UC[ui8_channel_no].C.B.EDPOL = 1;
eMIOS_0_UC.UC[ui8_channel_no].C.B.MODE = 0x1;
eMIOS_0.MCR.B.GPREN = 0;
eMIOS_0.MCR.B.FRZ = 1;
eMIOS_0_UC.UC[ui8_channel_no].C.B.UCPREN = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.FREN = 1;
eMIOS_0_UC.UC[ui8_channel_no].CNT.R = 0x0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.BSL = 0x3;
eMIOS_0_UC.UC[ui8_channel_no].C.B.ODIS = 1;
eMIOS_0_UC.UC[ui8_channel_no].C.B.FCK = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.IF = 0x0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.FCK = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.MODE = 0x0B;
eMIOS_0_UC.UC[ui8_channel_no].A.R = 0;
eMIOS_0_UC.UC[ui8_channel_no].B.R = 10;
eMIOS_0_UC.UC[ui8_channel_no].C.B.UCPRE = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.EDPOL = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.EDSEL = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.UCPREN = 1;
eMIOS_0.MCR.B.GPREN = 1;
eMIOS_0.MCR.B.GTBE = 1;
}
by using function generator i gave 1MHz pulses to the input channel i.e. CH[2] GPIO[181]. Can you please check any error is there in my code ,i am not getting any output value my both registers EMIOS_CNTn register and EMIOS_ALTAn registers are showing zero only.
Solved! Go to Solution.
hi petrs
Can i get the example code for configuring IGF module
Hi,
you can refer e.g. here
BR, Petr
hi petrs, based on that example i modified my code still am not getting my output.Following below is my code
void D_EMIOS_0_PEC_Init(uint8_t ui8_channel_no,uint16_t ui16_GPIO_pin_no)
{
SIU.PCR[ui16_GPIO_pin_no].R = 0x0500;
eMIOS_0.MCR.B.GPRE = 0x81;
eMIOS_0_UC.UC[ui8_channel_no].A.R = 0;
eMIOS_0_UC.UC[ui8_channel_no].B.R = 10;
eMIOS_0_UC.UC[ui8_channel_no].C.B.EDPOL = 1;
eMIOS_0_UC.UC[ui8_channel_no].C.B.MODE = 0x1;
// set IGF to filter low pulses <1.5us
IGF_0.FTHR.B.FTH = 0x82; // falling threshold = pulse width * clock = 1us*130Mhz = 130
IGF_0.MCR18.B.RFM = 0x0; // rising edge: bypassed
IGF_0.MCR18.B.FFM = 0x2; // falling edge: integrated type
IGF_0.MCR18.B.FGEN = 0x1; // enable filter
eMIOS_0.MCR.B.GPREN = 0;
eMIOS_0.MCR.B.FRZ = 1;
eMIOS_0_UC.UC[ui8_channel_no].C.B.UCPREN = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.FREN = 1;
eMIOS_0_UC.UC[ui8_channel_no].CNT.R = 0x0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.BSL = 0x0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.ODIS = 1;
eMIOS_0_UC.UC[ui8_channel_no].C.B.FCK = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.IF = 0x0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.FCK = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.MODE = 0x0B;
eMIOS_0_UC.UC[ui8_channel_no].A.R = 0;
eMIOS_0_UC.UC[ui8_channel_no].B.R = 10;
eMIOS_0_UC.UC[ui8_channel_no].C.B.UCPRE = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.EDPOL = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.EDSEL = 0;
eMIOS_0_UC.UC[ui8_channel_no].C.B.UCPREN = 1;
eMIOS_0.MCR.B.GPREN = 1;
eMIOS_0.MCR.B.GTBE = 1;
}
Hi,
what if you only enable IGF in bypassed mode, so use only IGF_0.MCR18.B.FGEN = 0x1; // enable filter and comment other IGF setting.
Also A1 holds the start time and B1 holds the stop time for the time window. You selected counter bus A as timebase, so do you have CH23 configured and running, thus a match with A1 can clear PEC internal counter and start counting external events?
BR, Petr
Hi,
you will need to configure IGF module, otherwise inputs does not pass to eMIOS module. For eMIOS_0 ch2 it should be IGF_0 ch18
IGF_0.FILTER[18].MCR.B.FGEN = 1;
BR, Petr