AnsweredAssumed Answered

S32K116 LPIT high frequency interrupt

Question asked by Rui Almeida on Sep 23, 2019
Latest reply on Sep 30, 2019 by Victor Jimenez

Hi, i'm trying to toggle a pin at a frequency higher than 1MHz using the LPIT. I've configured the Sys, Bus and peripheral clock to the SOSC @ 40MHz configured frequency (as seen on printscreen). The issue appears when  I try to configure the LPIT to interrupt every 40 ticks (or periods). The frequency of the pin toggle should be 1MHz but it goes down to 500kHz (approx). And when I put values lower than 40, the frequency slowly goes up from the 500kHz, at every lower value. Am I missing something? Below is my configuration inside main function and the ISR.


int main(void) {
     /* Write your local variable definition here */
     /* Initialize system and peripheral clocks */
     CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
               g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
     /* Initialize Pin settings*/
     PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
     /* Install interrupt */
     INT_SYS_InstallHandler(LPIT0_IRQn, &LPIT_ISR, (isr_t *) 0);
     /* Enable interrupt */
     /* Initialize LPIT Timer */
     LPIT_DRV_Init(INST_LPIT1, &lpit1_InitConfig);
     LPIT_DRV_InitChannel(INST_LPIT1, 0U, &lpit1_ChnConfig0);
     LPIT_DRV_StartTimerChannels(INST_LPIT1, (1 << 0U));

     for (;;){}

  return exit_code;

void LPIT_ISR(void)
PTB->PTOR = (((uint32_t)(((uint32_t)((1 << 13U)))<<GPIO_PTOR_PTTO_SHIFT))&GPIO_PTOR_PTTO_MASK);
/* Clear LPIT channel flag */
LPIT0->MSR = (1 << 0U);

Thanks in advance