-
You are correct though the ISR only reads the flag. There is a very small probability that the flag will be read by the ISR while the foreground task is setting it. At that point, you disable interrupts around the write operations.
-
Will do
-
What you are talking about are “threads” which can run concurrently. This brings your requirement to an RTOS level, which is being discussed for Spark Core II. You can create cooperative loops in the existing code but there is no parallelism.
-
Main() is a C construct whereas setup() and loop() are Arduino constructs. In the Core, main() is used to run the “background” code whereas setup() and loop() are used for the user code. In this context, you should not consider using main() in any way.
-
You are now looking for an RTOS, which is beyond the capability of the current Spark Core.
HOWEVER, one member did port the NutX RTOS to the Core but with few remaining resources:
@GrtVHecke,my gut tells me that you are over-designing your device! Most, if not all the functionality you require can be done without threads!