Multi Thread Coding on the Raspberry Pi Pico in MicroPython - Threads, Locks and problems!
Bytes N Bits Bytes N Bits
26.4K subscribers
34,173 views
0

 Published On Apr 19, 2022

The Raspberry Pi Pico uses the RP2040 microcontroller chip which has two ARM Cortex M0+ cores. Usually when we code we only use a single core. This leaves half of the processing power idle.

In this tutorial I'll show you how to run code in parallel on the second core and how to correctly manage and share resources between the two threads.

I'll also show you how I got around some of the bugs in the threading package, which is still in the experimental stage.

Don't forget to check out my project page for more details and links to all the code used in the video.
https://bytesnbits.co.uk/pi-pico-mult...

You can also access the code at the project GitHub repository at
https://github.com/getis/pi-pico-spi-...

0:00 Introduction
1:56 Multi thread coding
3:26 Threading Package
6:06 Simple dual core example
8:50 Using global variables to share data
12:03 Using classes to share data
15:56 Using Locks or Semaphores
19:02 Lock example code
23:07 Polling the Lock
26:32 SPI LCD example
28:59 Bug in thread package
30:27 Running second thread on demand
36:00 Conclusion

show more

Share/Embed