jimmie
Junior Member
Posts: 86
|
Post by jimmie on Aug 12, 2019 4:34:27 GMT
I realize that loop() runs after setup(), loop1() after setup1, and loop2() after setup2() completes.
But the completion time of each setup() function is not known as it depends on the contents of each setup().
How can I prevent ALL loops from running until all setup() functions have been completed? This is important because in some scenarios, a function in the loop() may depend on parameters that are calculated in another core .....
Thanks in advance.
|
|
|
Post by Admin on Aug 12, 2019 10:24:24 GMT
This shows how to make sure all the cores are synchronised. SyncStart.ino (3.81 KB) We will include this in the next release as a standard feature.
|
|
jimmie
Junior Member
Posts: 86
|
Post by jimmie on Aug 12, 2019 13:58:12 GMT
Thank you very much.
Glad it will be included as a standard feature as that, IMHO, it is very important for a multi-core board.
|
|
jimmie
Junior Member
Posts: 86
|
Post by jimmie on Aug 12, 2019 16:27:54 GMT
I implemented your code above. I t seems to work.
But, I also placed the following single statement in loop2()
SerialASC.println("------------------------------------>>>> Loop2 looping ");
The statement above executes even before any setup() has completed?
|
|
bigal
New Member
Posts: 12
|
Post by bigal on Sept 7, 2019 8:53:23 GMT
This shows how to make sure all the cores are synchronised. We will include this in the next release as a standard feature. Why so complicate? I tried the following (and it works): declare a global variable setupDone: volatile bool setupDone[3] = {}; In each setup at the end I put the following code: setupDone[0] = true; // 0 = core 1, 1 = core 2 and 2 = core 3 while (!setupDone[1] && !setupDone[2]); // put here the other cores... That's it. In this case I have the possibility to wait for individual cores. Semaphores are not necessary, because each slot is only influenced by the associated core... Am I wrong? Is there any drawback using this method? Alex
|
|