Skip to content
You Start with one site
Amounts in Start with one site
Engineering · Embedded Systems & Electronics

Embedded Programming: RPi Pico

Program the RP2040 in C where its hardware keeps the timing: state machines for exact pulses, two cores, and DMA that misses no sample. Eight projects on a 4 USD board, from a USB keyboard to a Wi-Fi LED display.

Found this useful?
The ping-pong time line of the audio sampler at 8 kHz, to scale. The DMA fills buffer A from 0 to 128 ms, B from 128 to 256 ms, then A and B again. The CPU saves each full buffer while the other fills: buffer A, with a sector erase, in about 51 ms; buffer B, a write only, in about 6 ms. The CPU finishes A about 77 ms before the DMA needs it again.

A strip of colour LEDs reads each bit from the length of a pulse, and a pulse 150 ns too long turns a 0 into a 1: one interrupt in the wrong place and the strip flickers. Two jobs on one processor delay each other, so the tone clicks or a press is missed. A recorder that fetches each sample itself cannot be away for more than 125 microseconds, yet a write to flash takes milliseconds.

The RP2040 has hardware for each of these faults. In this course you write a PIO program that makes every LED pulse, give each core its own job, let two DMA channels fill two buffers in turn, and build USB devices that need no driver. Then you rebuild a project in MicroPython, measure what it costs, and put a Pico W on your Wi-Fi network.

How each lesson goes
  1. 1Start from a faultTwo cores add 1 to the same counter. It ends at 6, not 7.
  2. 2See how the chip does itTwo cores, 12 DMA channels and the bus fabric that joins them.
  3. 3Let the hardware do the workTwo DMA channels start each other, and the CPU only saves full buffers.
  4. 4Measure itThe same ADC loop: 480,000 readings a second in C, 18,000 in Python.
You will be able to
  1. Build, load and debug Pico SDK programs in C, and know what the chip does at boot
  2. Move exact timing to PIO and DMA, and split work safely across two cores
  3. Make USB and Wi-Fi devices, and choose between C and MicroPython by measurement

New to this? Know C and new to the Pico? Start with lesson 1: install the SDK and build a USB keyboard.

You need A Raspberry Pi Pico (about 4 USD), a micro USB cable and a breadboard. Later lessons add a WS2812B strip, a piezo, buttons, a microphone module, a flash module, a joystick and a Pico W.

The engineering behind it

Precise timing on a low-cost chip, for signals too fast for ordinary code.

More about this course

Every number has a reason

A timing on this chip is not chosen because it sounds right. Each one comes from the signal, the sound or the computer at the other end.

  • 1.25 µsone WS2812B bit: ten PIO cycles of 125 ns, high for 875 ns for a 1 and 250 ns for a 0, with no CPU in the wayPIO
  • 125 µsone sample at 8 kHz; the DMA keeps that pace, and the CPU finishes a buffer about 77 ms before it is needed againDMA
  • 8 wordsthe depth of each queue between the cores; a loop that must keep its timing only looks and never waitsMulticore
  • 8 mshow often the computer collects a gamepad report: the device waits to be askedUSB
  • Status 3means the access point accepted the board; it promises nothing about the internet or the next minuteWi-Fi

Python to try it. C and PIO to keep the timing.

MicroPython
Fast to change
  • About 3 s from edit to test
  • About 27 times slower on the ADC loop
  • Short pauses for garbage collection

The test: is it a trial, a menu or a test rig?

C SDK and PIO
Even timing
  • About 40 s from edit to test
  • Every loop at the same pace
  • Pulses exact to the cycle from PIO

The test: must every sample and pulse be on time?

Why the RP2040

PIO state machinesEight tiny processors that only move pins, each instruction one cycle.
Two coresHardware queues and locks between them.
DMA that chainsChannels start each other with no CPU between.
A ROM that cannot changeHold BOOTSEL and a Pico can always be loaded again.
Copy one fileA UF2 file onto a USB drive; no programmer to buy.
C SDK and MicroPythonThe same hardware from both, measured side by side.

Honest limits. With Wi-Fi, a message that was published is not one that was received. A remote command must never be what keeps a device safe: that stays in the firmware on the board.

Before you start

  • C: pointers, structs and bit operations
  • GPIO and a breadboard, from any first microcontroller course
  • A computer with the Pico SDK on Windows, Mac or Linux
  • A Raspberry Pi Pico and a micro USB cable
The full course notes

The RP2040 is unlike any other microcontroller. Programmable I/O state machines let you implement custom hardware protocols in software. Two Cortex-M0+ cores give you real parallel processing. And it costs about 4 USD. This course focuses on what makes the Pico unique, not just another GPIO tutorial. Each lesson builds something that showcases these capabilities. #RaspberryPiPico #RP2040 #EmbeddedSystems

Keep the RP2040 Datasheet open as you work through this course. For the Pico board itself, the Raspberry Pi Pico Datasheet covers pinout, power supply, and mechanical drawings. The Pico W Datasheet adds CYW43439 wireless details for Lesson 8.

Why the RP2040?

PIO: Custom Hardware in Software

Programmable I/O state machines can implement WS2812B, VGA, UART, SPI, I2S, or any custom protocol without using CPU cycles. No other microcontroller in this price range offers anything like it. Lesson 3 teaches PIO assembly from scratch.

True Dual-Core

Two independent Cortex-M0+ cores with hardware FIFOs and spinlocks for synchronization. Run audio generation on one core and UI on the other. Lesson 4 covers multicore patterns in depth.

DMA That Chains

DMA channels with chaining, pacing timers, and ring buffer modes. Build pipelines where ADC feeds DMA feeds PIO with zero CPU involvement. Lesson 5 shows how.

C SDK and MicroPython

The Pico C SDK is clean, well-documented, and CMake-based. MicroPython runs natively with hardware access. Lesson 7 compares both approaches on the same hardware, so you know when to use each.

Course Structure

Each lesson follows a consistent cycle:

  1. The Unique Problem A project that specifically leverages RP2040 capabilities. Not generic embedded tasks, but things this chip does better than others.

  2. RP2040 Architecture How the relevant subsystem works: PIO instruction set, core interconnect, DMA channel architecture, USB PHY.

  3. Implementation Write firmware using the Pico C SDK (or MicroPython in Lesson 7). CMake build system, UF2 flashing.

  4. Build and Demonstrate Wire it up, flash via USB drag-and-drop or picotool, and verify the project works.

  5. Performance Analysis Measure timing, CPU usage, or throughput. Understand where the RP2040 excels and where it has limitations.

Lessons

Lesson 1: Pico SDK and RP2040 Architecture

Pico SDK and RP2040 Architecture. Install the Pico SDK, understand CMake build flow, dual Cortex-M0+ cores, bus fabric, and UF2 boot process. Build a USB text injector that types a predefined message when plugged in. Build: USB text injector. Parts: Raspberry Pi Pico, micro USB cable.

Lesson 2: GPIO, PWM, and Analog I/O

GPIO, PWM, and Analog I/O. Explore GPIO functions, PWM slice architecture, the 12-bit ADC, on-chip temperature sensor, and hardware interpolators. Build an LED brightness controller with analog knob and serial feedback. Build: LED brightness controller. Parts: LEDs, potentiometer, resistors.

Lesson 3: PIO: Programmable I/O State Machines

PIO: Programmable I/O State Machines. Learn PIO assembly from scratch: instruction set, state machine architecture, FIFOs, clock dividers, and sideset. Write a WS2812B LED driver entirely in PIO. Build: WS2812B LED strip driver. Parts: WS2812B LED strip (8 pixels).

Lesson 4: Multicore Programming

Multicore Programming: Dual Core. Launch code on Core 1, communicate through hardware FIFOs, use spinlocks and shared memory safely. Build a dual-core synthesizer where one core generates waveforms and the other handles button input. Build: Dual-core tone synthesizer. Parts: Piezo or small speaker, buttons.

Lesson 5: DMA and High-Speed Data Pipelines

DMA and High-Speed Data Pipelines. Configure DMA channels with chaining, pacing timers, and ring buffer modes. Build an audio sampler that captures microphone input via ADC+DMA and stores it to SPI flash. Build: Audio sampler. Parts: Electret microphone module, W25Q SPI flash module.

Lesson 6: USB Device Classes

USB Device Classes. Use TinyUSB to implement HID, CDC, and MSC USB device classes. Build a custom USB gamepad with a joystick and buttons that appears as a standard HID controller on any PC. Build: Custom USB gamepad. Parts: Thumb joystick module, 4 push buttons.

Lesson 7: MicroPython on RP2040

MicroPython on RP2040. Flash MicroPython, use the REPL, access hardware through the machine module, write PIO programs in Python. Rebuild a previous project in MicroPython and compare development speed vs performance. Build: Rapid sensor dashboard (same hardware, fraction of the code). Parts: Reuse existing.

Lesson 8: Wireless with Pico W

Wireless Networking with Pico W. Use the CYW43 wireless driver for Wi-Fi and BLE connectivity. Set up network sockets, run a microdot web server, and serve a control interface. Build a Wi-Fi controlled NeoPixel display. Build: Wi-Fi controlled NeoPixel display. Parts: Pico W (swap from Pico), reuse WS2812B.

Parts Kit

PartQuantityFirst UsedApproximate Cost
Raspberry Pi Pico1Lesson 1~4 USD
Raspberry Pi Pico W1Lesson 8~6 USD
Micro USB cable1Lesson 1~1 USD
Breadboard + jumper wires1 setLesson 13-5 USD
LEDs + 220R resistors4Lesson 2~0.50 USD
Potentiometer (10K)1Lesson 2~0.25 USD
WS2812B LED strip (8 pixels)1Lesson 32-3 USD
Piezo buzzer or small speaker1Lesson 4~0.50 USD
Push buttons4Lesson 4~0.50 USD
Electret microphone module1Lesson 5~1 USD
W25Q SPI flash module1Lesson 51-2 USD
Thumb joystick module1Lesson 61-2 USD

Total estimated cost: 22-30 USD (including both Pico and Pico W)

Skill Progression

SkillLessons 1-2Lessons 3-4Lessons 5-6Lessons 7-8
ArchitectureBoot, GPIO, PWM, ADCPIO assembly, multicoreDMA channels, USB PHYMicroPython VM, CYW43
Unique FeaturesUF2 flashing, interpolatorsPIO state machines, FIFOsDMA chaining, ring buffersPIO in Python, Wi-Fi
ProjectsText injector, LED controlLED strip driver, synthAudio sampler, USB gamepadSensor dashboard, Wi-Fi display
LanguageC (Pico SDK)C (Pico SDK)C (TinyUSB)MicroPython, then C

Prerequisites

Embedded C experience required

You should be comfortable with:

  • C programming (pointers, structs, bit manipulation, basic CMake)
  • Microcontroller basics (GPIO, timers, interrupts, SPI/I2C)
  • Our Embedded Programming: ATmega328P course or equivalent

Helpful but not required:

Getting Started

  1. Get a Raspberry Pi Pico (~4 USD) and a Pico W (~6 USD) for the wireless lesson. Both use micro USB.

  2. Install the Pico SDK and CMake. Lesson 1 covers setup on Linux, macOS, and Windows.

  3. No debugger needed to start. The Pico uses UF2 drag-and-drop flashing over USB. Hold BOOTSEL, plug in, drop the .uf2 file.

  4. Start with Lesson 1. The USB text injector demonstrates the boot process and build system in a fun, immediately useful way.

  5. Lessons 1 through 6 use the standard Pico. Swap to Pico W for Lesson 8 (wireless).

© 2021-2026 SiliconWit®. All rights reserved.

8 lessons, in order.

SiliconWit makes these courses. We also run siliconwit.io, a monitoring service.