Multi Thread Coding on the Raspberry Pi Pico in MicroPython - Threads, Locks and problems!

Published: 19 April 2022
on channel: Bytes N Bits
39,320
1k

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


On this page of the site you can watch the video online Multi Thread Coding on the Raspberry Pi Pico in MicroPython - Threads, Locks and problems! with a duration of hours minute second in good quality, which was uploaded by the user Bytes N Bits 19 April 2022, share the link with friends and acquaintances, this video has already been watched 39,320 times on youtube and it was liked by 1 thousand viewers. Enjoy your viewing!