Hello all,
I've been trying to learn everything I can about interrupts, and I think I have them figured out (preempt priority/sub-priority/priority grouping). I want to make sure that my uart has priority over my other Ticker interrupts, so I put the following code at the top of my main function. It seemed to work and fixed a bug where sometimes I missed bytes from the uart, so that is great.
However, now when I get uart interrupts, sometimes it stops other parts of my program from working. So I'm wondering if I need to handle nested interrupts differently??? When an interrupt interrupts an interrupt, do I need to save any registers/etc. or does the CPU handle all of that? If I allow interrupts to preempt other interrupts, does anyone know if I need to write the isr differently or will the cpu/mbed handle all the saving/restoring of variables/registers? Thanks!
NVIC_SetPriorityGrouping(4); //all bits for preempt
for(int i=0; i<86; i++)
NVIC_SetPriority((IRQn_Type)i, 2);
NVIC_SetPriority(USART1_IRQn, 1);
Hello all,
I've been trying to learn everything I can about interrupts, and I think I have them figured out (preempt priority/sub-priority/priority grouping). I want to make sure that my uart has priority over my other Ticker interrupts, so I put the following code at the top of my main function. It seemed to work and fixed a bug where sometimes I missed bytes from the uart, so that is great.
However, now when I get uart interrupts, sometimes it stops other parts of my program from working. So I'm wondering if I need to handle nested interrupts differently??? When an interrupt interrupts an interrupt, do I need to save any registers/etc. or does the CPU handle all of that? If I allow interrupts to preempt other interrupts, does anyone know if I need to write the isr differently or will the cpu/mbed handle all the saving/restoring of variables/registers? Thanks!