MKE04VTG4 Timing Issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MKE04VTG4 Timing Issue

837 Views
TEMCEFF
Contributor IV

In my application, iam using 16 MKE04VTG4 controllers. Same firmware and Hardware for all.

All the health LEDs are sinking with another for some time around 2 minutes only. Later all Health LEDs are unable sink with  one to another.

May I Know what is the reason.

Below is the code in all controllers for health LED.

void PIT_CH0_IRQHandler()
{
 PIT->CHANNEL[0].TFLG = 0x01;      // Disable Interrupt
 PIT->CHANNEL[0].TCTRL = 0x00;     // Disable timer & Stop timer
 PIT->CHANNEL[0].TCTRL = 0x03;       // Start Timer & Interrupt Enable
 count_l++;
    if(count_l >= LED_TOGGLE_VALUE)
    {   
     flag = flag^1;                                                                               
      GPIO_PortToggle(kGPIO_PORTB, 0x20);  // toggle led for every 500msec
      count_l = RESET;
     } 
 ADC_SetChannelConfig(ADC,&sADC_Config_1);
}

void pit_init()
{
pit_config.enableRunInDebug = false;
PIT_Init(PIT, &pit_config);   // PIT PERIPHERAL RUNS ON BUS CLOCK, AS PER USER MANUAL
 PIT->MCR              = 0x00;                            // Enable clock for PIT
 PIT->CHANNEL[0].LDVAL = 240000;//(BUS_CLOCK*(PIT_INT/1000));      // LOAD VALUE FOR EVERY 10MSEC INTERRUPT
 PIT->CHANNEL[0].TCTRL = 0x03;                            // Start Timer & Interrupt Enable
 NVIC_EnableIRQ(PIT_CH0_IRQn);
 NVIC_SetPriority(PIT_CH0_IRQn,0);
 }

It is also observed that PIT Interrupt is triggering below count down register becomes zero.

3 Replies

718 Views
TEMCEFF
Contributor IV

Hi XiangJun Rong,

   Thanks for your concern. from ur code it is understand that no need of restart of PIT, once initialised, is it sir..?

Also, iam using 16 controllers parallely in my application, but there is no synchronisation of health leds, of all controllers.

May I know what is the reason. firmware & hardware are same for all controllers.

Thanks & Regards,

K Chandu

0 Kudos

718 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Muralidhar,

As you know that the frequency of  clock source of different KE04 is a little different, which leads to the issue that the LED on different boards can not synchronize. I suggest you use ONE KE04 as master, it can generate a GPIO signal and trigger all the other slave KE04, the triggering signal from master KE04 can be captured by the slave KE04, the capturing  event can be used to reset the PIT counter of slave KE04, in this way, the LED on all KE04 boards will synchronize.

Hope it can help you

BR

XiangJun Rong

718 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Muralidhar,

I remember that there is a bug for the PIT for Kinetis, user has to read the PIT control register beside clearingf the flag in PIT->CHANNEL[0].TFLG .

Pls use the code and have a try.

BR

XiangJun Rong

void PIT_CH0_IRQHandler()
{
 //PIT->CHANNEL[0].TFLG = 0x01;      // Disable Interrupt
 //PIT->CHANNEL[0].TCTRL = 0x00;     // Disable timer & Stop timer
 //PIT->CHANNEL[0].TCTRL = 0x03;       // Start Timer & Interrupt Enable

 PIT->CHANNEL[0].TFLG = 0x01;      // Disable Interrupt

PIT->CHANNEL[0].TCTRL;
 count_l++;
    if(count_l >= LED_TOGGLE_VALUE)
    {   
     flag = flag^1;                                                                               
      GPIO_PortToggle(kGPIO_PORTB, 0x20);  // toggle led for every 500msec
      count_l = RESET;
     } 
 ADC_SetChannelConfig(ADC,&sADC_Config_1);
}