I imagine that almost everyone knows by now that the RPi Pico is dual-core and probably you also know that the FreeRTOS stack is available to enable multitasking. What I didn’t know until this morning is that there’s a super-simple, super-easy way of taking advantage of both cores without having to go down the RTOS rabbit hole (although FreeRTOS isn’t that difficult, it can, like many other things, be a wee bit daunting to the beginner).
This is a biggie! This apparently simple change just opened up the world of multitasking, multicore programming to absolutely everyone. This neat idea, centred on the Arduino IDE and with the added popularity of the Raspberry-Pi community, is going to be a huge boon to hobbyists everywhere.
So what is this multiprocessor trick? It couldn’t be much simpler. Using the Raspberry Pi Pico Arduino core (“Arduino-Pico”), use these two functions:-
That’s it! That’s essentially all you need to know.
By default, Arduino-Pico will use the normal
setup() call to initialize core-0 of the processor, but if it finds that a
setup1() function exists, it will initialize core-1 of the processor with the contents. This happens more or less simultaneously at start-up.
Likewise, while core-0 will run code contained in the default
loop() function, core-1 will run the code contained within the
There are also a couple of other calls in there which will help you communicate between the two cores and which are also really simple to use. Rather than trying to describe them, I’ll just leave you with a link to a demo program (which will run a WiFi network scan on core-0, while simultaneously running a fader on the on-board LED using core-1).
Hopefully, this change will be picked up on other platforms (ESP32 anyone?) and become an integral part of the Arduino IDE; in the meantime, have fun running multicore on the Pico, quickly and easily!
The Arduino-Pico core is available from Earle F. Philhower’s GitHub repository.