AnsweredAssumed Answered

etimer sync

Question asked by Hyuntae Choi on Nov 19, 2018
Latest reply on Dec 3, 2018 by Petr Stancik

Hi, I have a question about synchronization of Etimer count. (MPC5744P)

 

With Capture function of Etimer, I detect rising and falling edges of  3 hole sensor signals to calculate Motor RPM.

 

Following is my Etimer setting,

 

static void ETimer_Init(void)
{

   ETIMER_2.ENBL.R = 0x0; // disable Timer1 channels

   ETIMER_2.CH[2].CNTR.R = 0x0000;
   ETIMER_2.CH[3].CNTR.R = 0x0000;
   ETIMER_2.CH[4].CNTR.R = 0x0000;

 

   ETIMER_2.CH[2].CTRL1.R = 0x3942; // Counts only rising edge of the MC_CLK (10MHz in RUN0), divide by 2,    (10Mhz/2 = 5000000hz)
   ETIMER_2.CH[2].COMP1.R = 65500; // Compare value for 1u second delay ((1/5000000Hz)*65500 = 0.0131 sec)
   ETIMER_2.CH[2].CCCTRL.R = 0x0264; // compare on COMP1 when counting up, CAPT1 on rising edge,

 

   E TIMER_2.CH[3].CTRL1.R = 0x3943; // Counts only rising edge of the MC_CLK (10MHz in RUN0), divide by 2,    (10Mhz/2 = 5000000hz)
   ETIMER_2.CH[3].COMP1.R = 65500; // Compare value for 1u second delay ((1/5000000Hz)*65500 = 0.0131 sec)
   ETIMER_2.CH[3].CCCTRL.R = 0x0264; // compare on COMP1 when counting up, CAPT1 on rising edge,

 

   ETIMER_2.CH[4].CTRL1.R = 0x3944; // Counts only rising edge of the MC_CLK (10MHz in RUN0), divide by 2,    (10Mhz/2 = 5000000hz)
   ETIMER_2.CH[4].COMP1.R = 65500; // Compare value for 1u second delay ((1/5000000Hz)*65500 = 0.0131 sec)
   ETIMER_2.CH[4].CCCTRL.R = 0x0264; // compare on COMP1 when counting up, CAPT1 on rising edge,

 

   ETIMER_2.ENBL.R = 0xffff; // Enable Timer1 channel

 

   ETIMER_2.CH[2].CCCTRL.B.ARM = 1;
   ETIMER_2.CH[3].CCCTRL.B.ARM = 1;
   ETIMER_2.CH[4].CCCTRL.B.ARM = 1;
}

RPM is calculated using captured values below.

{

U_R = ETIMER_2.CH[2].CAPT1.R; 
U_F = ETIMER_2.CH[2].CAPT2.R; 
V_R = ETIMER_2.CH[3].CAPT1.R;
V_F = ETIMER_2.CH[3].CAPT2.R;
W_R = ETIMER_2.CH[4].CAPT1.R;
W_F = ETIMER_2.CH[4].CAPT2.R;

}

 

RPM didn't calculated well. So I checked CNTR values for each channel.

And I found that CNTR vaule of three Etimer channel were different at certain point.

ETIMER_2.CH[2].CNTR  = FEE3

ETIMER_2.CH[3].CNTR  =  2D53

ETIMER_2.CH[4].CNTR  = 5C22

 

How can I synchronize three Etimer channel?

Outcomes