Raspberry Pi · SC0915

Raspberry Pi Pico

Raspberry Pi Pico: an RP2040 (two Cortex-M0+ cores) with 2 MB of flash.

EmbassyZephyrRaspberry Pi
Raspberry Pi PicoRaspberry Pi · RP2040 · 2 × Cortex-M0+ · 133 MHz · 264 KB · bare metalRP204012345671can0 CANCAN (an MCP2515 on SPI0) · sck PIN_18, mosiPIN_19, miso PIN_16, cs PIN_17, int PIN_202uart0 UARTUART0 · tx PIN_0, rx PIN_13usb USBMicro-USB4pwr Power5 V USB or VSYS5v3v3 Power3V3(OUT), pin 366vbus PowerVBUS, pin 40 (5 V from USB)7i2c0 I²CI2C0 (GP4, GP5) · sda PIN_4, scl PIN_51 GPIO pins, each a port (led, …)

In short

RP2040 board: two 133 MHz Cortex-M0+ cores, 264 KB SRAM, 2 MB flash, 26 GPIOs. No CAN controller: CAN goes through an MCP2515 on SPI0 (a common add-on board).

Clock133 MHz
Flash2 MB
RAM264 KB
GPIO26
Logic3.3 V

Specs

From the board’s model in the store.

Processor
RP2040 · 2× Cortex-M0+ · chip "rp2040"
Clock
133 MHz
Flash
2 MB
RAM
264 KB
GPIO pins
26
ADC
ADC 3 ch 12-bit
Logic level
3.3 V
Power
5 V USB or VSYS (in); 3V3(OUT), pin 36: 3.3 V (≤ 300 mA); VBUS, pin 40 (5 V from USB): 5 V
Current per pin
not in the board’s model yet
Buses
UART ×2, I²C ×2, SPI ×2, USB ×1
Runs
bare metal (no OS)

Pin map

Each pin by what it does. Hover or tap a pin to see what else it can be.

  • Power 3
  • Digital 9
  • Analog 2
  • Bus 15
  • PIN_0GP0
  • PIN_1GP1
  • PIN_2GP2
  • PIN_3GP3
  • PIN_4GP4
  • PIN_5GP5
  • PIN_6GP6
  • PIN_7GP7
  • PIN_8GP8
  • PIN_9GP9
  • PIN_10GP10
  • PIN_11GP11
  • PIN_12GP12
  • PIN_13GP13
  • PIN_14GP14
  • PIN_15GP15
  • PIN_16GP16
  • PIN_17GP17
  • PIN_18GP18
  • PIN_19GP19
  • PIN_20GP20
  • PIN_21GP21
  • PIN_22GP22
  • PIN_26GP26
  • PIN_27GP27
  • PIN_28GP28
  • pwr5 V USB or VSYS
  • v3v33V3(OUT), pin 36
  • vbusVBUS, pin 40 (5 V from USB)

Watch out

What archec checks for this board, from its data. Each one names the check that catches it.

  • Its pins work at 3.3 V. A 5 V sensor’s output on one of them needs a level shifter between them.

    check pin-level

  • The board already uses PIN_25 (LED). Something else wired there fights with it.

    check pin-conflict

  • The 3V3(OUT), pin 36 gives at most 300 mA at 3.3 V. Add up what you power from it.

    check board-current

  • It gives 3.3 V (3V3(OUT), pin 36), 5 V (VBUS, pin 40 (5 V from USB)). Power each part from a rail at its own voltage.

    check board-supply

  • It has 2 UART, 2 I²C, 2 SPI. One more bus of a kind than that is an error.

    check board-peripheral

  • Each bus goes on the pins that can carry it (see the pin map). Another pin is an error.

    check pin-function

First model

A blink for this board: the board, an LED and a part that turns it over every 500 ms. archec checks it, then writes the code on the right.

main.archeOpen in the playground
project Blink "Blink" {
  version "0.1.0"
  edition "1.0"
  uses arche-hw-store "^0.1"
}

include "arche-hw-store/boards/raspberry-pi-pico/raspberry-pi-pico.arche"
include "arche-hw-store/devices/led/led.arche"

/// Turns the LED over at each step.
component Blinker "Blinker" {
  out led: requires Led
  fn blink "Blink" {
    ```arche
    led.toggle()
    ```
    wcet 50us
  }
}

/// The board, an LED on the board's LED (PIN_25), and the blinker.
system Hw "Blink" {
  part board:   RaspberryPiPico
  part led:     GpioLed { in pin { pins { pin PIN_25 } } }
  part blinker: Blinker
  blinker.led -> led.led
}

/// The firmware: the blinker every 500 ms.
deployment OnBoard "On the board" {
  system Hw
  platform Hw
  binary blink on board {
    thread main "Blink" { runs blinker; period 500ms; step blink }
  }
}
archec gen --target embassyblink/src/app/blinker.rs
//! Your code: the state and behaviour of this part. Write it between the USER CODE markers:
//! when the model changes, `archec gen` writes this file again around them (a new function, a
//! new input) and keeps them. Edit outside them and the file is yours: it is left as it is,
//! and the compiler says what to add (a new trait method).

#[allow(unused_imports)]
use crate::arche::*;

// @arche blinker main.arche:25 part
/// blinker
#[derive(Default)]
pub struct Blinker {}

impl BlinkerBehaviour for Blinker {
    // @arche blinker.blink main.arche:13 fn
    async fn blink(&mut self, _out: &BlinkerOut) {
        // Blink: from the model (```arche)
        _out.call_led_toggle().await;
    }
}

blink/src/app/blinker.rs, one of the 16 files archec writes.

Open in the playground

Parts on the board

What each numbered part is. Click a number to find it on the board.

1 2 3 4 5 6 7 8 9 10

Find the part

The quiz names a part: click it on the board. A first try scores a point.

Compare every board