Hey,
I would like to know what happens when external event does occure while Serial.println() function is writing something on the Serial Port ?
I really thank all of you for the help !
Hey,
I would like to know what happens when external event does occure while Serial.println() function is writing something on the Serial Port ?
I really thank all of you for the help !
Interrupt events can occur at any time, and most are remembered by setting an interrupt flag inside the processor and if more than one flag is set at a given time, then the ISR associated to the one with the highest priority is being called first.
Serial
is using interrupts but they don't have the most urgent priority setting. So if an external event occurs at the same time an USART interrupt, your external interrupt will take precedence. (check the priority order for your target architecture and the interrupt you have attached to your event).
As most code for interrupts does not enable interruption (I think it's the case for Serial) if you are in the Serial interrupt then it won't be interrupted and you'll have to wait until this ISR completes its work before the processor checks flags and call the ISR associated to the highest priority event.
That's a good reason to keep ISR very short
Hi =)
So what you are explaining is that interrupt priorities only matter when different interrupts
happen together.
But when an ISR is running, it can't be interrupted before its end, isn't it ?
Thank's !!
Unlike AVRs, when the processor (Sam3x8e) is executing an exception handler, an exception can preempt the exception handler if its priority is higher than the priority of the exception being handled (a lower priority number means an higher urgency).
When one exception preempts another, the exceptions are called nested exceptions.
If you want Serial.print ( UART) to be interrupted by another peripheral (e.g. ADC), you will have to set UART a higher priority number than ADC.
After a reset, all prirority numbers are set to 0.
To increase priority control in systems with interrupts, the NVIC supports priority grouping. This divides each interrupt priority register entry into two fields:
* an upper field that defines the group priority
* a lower field that defines a subpriority within the group.