I have a project where I have 3 inputs into PORTB - I must be able to respond to an interrupt from any of these three pins. In a previous version of the same project, we have the interrupts working just fine, but since then, MQX has changed to using LWGPIO which handles one pin at a time. I need to write the ISR so that when the ISR is called, I can very quickly detect which pin was set to interrupt, and then I set the appropriate global variable to 1. That's it. I tried using the LWGPIO functions within the ISR, but that is too much latency.
A previous version of the same project, which was non-RTOS, used the Processor Expert to handle the interrupts and it did fine. I need the RTOS due to the existence of Ethernet, USB, Bluetooth, and WiFi on the same system (along with an RS-232 port). In all ways, the RTOS makes life easier.
已解决! 转到解答。
Hi Kevin,
If I understand your problem, using the lwgpio code below in your ISR to check which pin was used and to clear it isn't fast enough?
if(lwgpio_int_get_flag(&btn1))
{
lwgpio_int_clear_flag(&btn1); //Clear interrupt flag
//do more stuff
}
Those lwgpio API calls are just modifying the PORTx_ISF register to read and clear, and should be very fast. If it's still too slow, you could setup a kernel ISR with _int_install_kernel_isr instead of using the normal _int_install_isr which has some RTOS overhead involved. There are some extra steps to use that, see this thread for some information on it: K60 and MQX installed ISR not called, why?
Also be aware that kernel ISRs cannot use any MQX features like starting a task, setting a semaphore, etc.
Hi Kevin,
If I understand your problem, using the lwgpio code below in your ISR to check which pin was used and to clear it isn't fast enough?
if(lwgpio_int_get_flag(&btn1))
{
lwgpio_int_clear_flag(&btn1); //Clear interrupt flag
//do more stuff
}
Those lwgpio API calls are just modifying the PORTx_ISF register to read and clear, and should be very fast. If it's still too slow, you could setup a kernel ISR with _int_install_kernel_isr instead of using the normal _int_install_isr which has some RTOS overhead involved. There are some extra steps to use that, see this thread for some information on it: K60 and MQX installed ISR not called, why?
Also be aware that kernel ISRs cannot use any MQX features like starting a task, setting a semaphore, etc.
I was using different code than what you have listed there, and I tried it and it does work correctly. Now I have something else going on in the system now that I have solved the interrupt question. Thanks!