AnsweredAssumed Answered

Writing TPM Registers During Interrupt - KL03 Freedom Board

Question asked by Adam Carlson on Jun 19, 2015
Latest reply on Jun 22, 2015 by Adam Carlson

I have been playing with doing interrupts on my KL03 Freedom board.  I have it set up such that as it gets an interrupt on the PTB5 pin (not set in NMI mode) that it should change the duty cycle of the PWM to the Tri-Color LED.  This is shown in the code snippet below.

 

/*PORTB_IRQHandler*/
void PORTB_IRQHandler()
{
    unsigned int delay;
    unsigned long delayMax = 6500000;

    TPM0_C0V = 65000;
    TPM0_C1V = 500;
    TPM1_C0V = 500;

    for(delay = 0; delay <= delayMax; delay++);

    PORTB_ISFR=0xFFFFFFFF;
}

 

I initially thought that it was not getting into the ISR as I was not seeing a change in the LED color, though when running in debug mode, I could see that it was actually entering into the ISR.  As I stepped through lines 7-9, it was not changing the register value for these, I would have expected that the LED would change color through each step from 7-9, but it did not do that either.

 

Is there something that I am missing?

 

While I am at it, I notice that these pins seem to have an IRQ number listed next to them.  In the case of PTB5, the IRQ that is shown in the schematics is IRQ_12.  From what I can gather in the Reference Manual for the KL03, it seems that these are not so much as that they have their own ability to generate an interrupt on their own, but that it will set a flag specific for that pin, and that with the Port interrupt set, then I can go and search for this bit flag to determine which pin generated the interrupt even if the event that generated the interrupt was transient and is no longer present.  Is this a correct understanding?

 

Adam

Outcomes