-->
Page 1 of 1

Basic question about interruption

PostPosted: Fri Jun 08, 2018 8:00 am
by Antori91
Assuming that your Arduino code doesn't use interruptions at all, can your code nevertheless be interrupted by someone else (By someone, I mean a low level routine like WiFi for example).

Re: Basic question about interruption

PostPosted: Fri Jun 08, 2018 11:55 am
by QuickFix
No, yes... sort of...

Your WiFi-stack needs to have some processing time every once in a while, you can allow this by putting in some yields or delays in your code.
However if you don't, a watchdog will time-out and reset your ESP.

So no: the WiFi stack won't interrupt the flow of your code, but if you don't give it some processing time yourself, it will "Force a giant interrupt" (ie. a reset). 8-)

But, you're asking this question for a reason, so please enlighten us with some context. ;)

Re: Basic question about interruption

PostPosted: Fri Jun 08, 2018 1:04 pm
by Antori91
I know that the low level routines (like WiFi and others) must run from time to time (if not the watchdogs will bite you). From what I've read, these low level routines are called when your code calls delay() for example and they are also called automatically at the beginning of each new loop() iteration.
To come back to my question, assuming
- first, a (short) part of my code must not be interrupted,
- secondly my code doesn't use at all interruptions,
do I have to use noInterrupts() ?

Re: Basic question about interruption

PostPosted: Fri Jun 08, 2018 10:11 pm
by McChubby007
Antori91 wrote:I know that the low level routines (like WiFi and others) must run from time to time (if not the watchdogs will bite you). From what I've read, these low level routines are called when your code calls delay() for example and they are also called automatically at the beginning of each new loop() iteration.
To come back to my question, assuming
- first, a (short) part of my code must not be interrupted,
- secondly my code doesn't use at all interruptions,
do I have to use noInterrupts() ?

It's more complicated than that - interrupts occur whether your code 'uses' them or not. Timer (sys clock), possibly device i/o such as uart or wi-fi, which are not necessarily triggered by your code.