2 years, 12 months ago.

Non-blocking interrupts


I am using the FRDM-KL25Z to read data from two sensors but I appear to be running into an interesting problem. When the sensors FIFO are full it sends an interrupt to the FRDM-KL25Z, the issue is that I appear to be missing interrupts. My interrupt routines are just long enough to set a flag for the main function to check and then read the FIFO data. Is there away use interrupts in a non-blocking manner, if so I would be happy to hear how so that I do not miss any interrupts from the sensors I am monitoring.

Thankfully Kas

Question relating to:

Comment on this question

1 Answer

2 years, 12 months ago.

What do you mean by a non-blocking interrupt? And why do you think that is causing you to miss interrupts?

Isn't it simply that it takes too much time before your main function checks that flag? Can't you let your sensor set the interrupt before its FIFO is full?

Hello Erik,

I guess I was looking for the ability of nested interrupts. I think I have resolved this issue (can't quite recall how, it's been too many hours on a seemingly simple project). As for your suggestion I have a 32 deep FIFO and I am setting an interrupt after 20 slots are used :)

Thank you for your prompt and helpful answer :) hopefully I can get the sensors to spit out meaningful data and then this should be done.


posted by Kasriel Lewis 21 Jul 2015

You can set a priority on an interrupt but because different parts have different levels of control it's not going to be cross platform and so isn't a core part of the mbed library. For a K22F you could set interrupts from port A to be highest priority and then port B next by using

     NVIC_SetPriority(PORTA_IRQn, 0);
     NVIC_SetPriority(PORTB_IRQn, 1);

The full list of defined interrupts for that CPU can be found in the mbed libraries in mbed\targets\cmsis\TARGET_Freescale\TARGET_K22F\MK22F51212.h

posted by Andy A 21 Jul 2015

In addition to Andy's comment: By default all interrupts are at the highest priority. So you need to set others to a lower priority if you want one to have higher priority than the others.

If you have many interrupts of which you want to change the priority to be lower, have a look at:

posted by Erik Olieman 21 Jul 2015

To post an answer, please log in.