AnsweredAssumed Answered

Having trouble setting NVIC interrupt priority on KL05

Question asked by Jeff Haller on Oct 4, 2017
Latest reply on Oct 4, 2017 by Mark Butcher

I am using a KL05Z32 and I cannot seem to set NVIC priority for two interrupts.  I am trying the same method for the PIT and the I2C interrupt.  When I run the code with a debugger and I directly inspect the NVIC priority, I do not see a change after using the 'set_irq_priority()' function or directly writing to the NVIC_IPR5 register.  Here is a code sample for setting the PIT priority:

 

void PIT_Init(void)
{
// Enable PIT clock
SIM_SCGC6 |= SIM_SCGC6_PIT_MASK; // enable PIT module

/* Enable PIT Interrupt in NVIC*/
enable_irq(INT_PIT - 16);

/* Set PIT priority relatively low so as not to interfere with communication interrupts */
set_irq_priority(INT_PIT - 16, 1);
//NVIC_IPR5 = 0x01;

PIT_MCR = 0x00; // MDIS = 0 enables timer
PIT_TCTRL1 = 0x00; // disable PIT0
// Configure PIT to produce an interrupt every 1ms
PIT_LDVAL1 = 23999; // 24000 - 1 cycles at 24MHz
PIT_TCTRL1 = PIT_TCTRL_TIE_MASK; // enable PIT0 and interrupt
PIT_TFLG1 = 0x01; // clear flag
PIT_TCTRL1 |= PIT_TCTRL_TEN_MASK;
}

Outcomes