Main Content

Dual Cores & Interrupts on  Pi Pico

The new Raspberry Pi Pico offers Dual Cores and Interrupts if you use MicroPython. I thought I would give it a go and try explain some of the pitfalls to avoid.
This project keeps the action running on the two cores very simple, so that we can concentrate on new aspects of the code:
setting up and activating the coresshutting down the cores in sequence using interrupts
The video shows this simple example, with a rapid, on screen, count running on Core 0 and blinking/ moving LEDs on Core 1. The first core begins counting but does not start the second core until the count has got to 30, so we can see that it does not slow down as the LEDs start moving. The two buttons offer control. The first button changes the direction of movement of the blinking LED each time it is pressed. The second halts both cores when we have had enough.
Each time a button is pressed an interrupt service routine changes a global value which is shared by both cores. running changing to from True to False halts the program while led-dir has values of +1 or -1 to specify the direction of the moving-led.

Supplies:
- Raspberry Pi Pico microcontroller
- Pimoroni Pico Display screen
- Pimoroni .UF2 file for Pico
- Thonny Editor
- Pico Decker
- USB cable
- Stripboard or Breadboard
- 2 x momentary button switches
- 4 x LED
- 4 x 330 Ohm resistors
- Connection jumper wires”

Link to article