On the 21st of January, 2021, the Raspberry Pi Foundation released its own [microcontroller] board called the __[Raspberry Pi Pico|RaspberryPiPico]__. Despite its name, the Pico is a __microcontroller__, not a small __microcomputer__ (i.e., a Single Board Computer or SBC) like the [Raspberry Pi], uses a different CPU chipset (the __RP2040__, a proprietary design by the Raspberry Pi Foundation), and is significantly smaller and cheaper than any Pi at ''US$4''.

It comes with a C SDK, a GCC-based toolchain, Visual Studio Code integration, and can be programmed in __[Micropython]__. The RP2040 CPU is currently available in the Pico form factor as released by the Raspberry Pi Foundation, but announcements have been made by many vendors like Adafruit and Pimoroni for Feather, Itsy Bitsy, QT, Tiny, and other familiar designs.


!!! Specification

[{Image src='attach/RaspberryPiPico/pico-oblique-800x.jpg' link='attach/RaspberryPiPico/pico-oblique-800x.jpg' caption='The Raspberry Pi Pico (click to enlarge)' align='right' width='300' class='imgFloatRight'}]

* 21 mm × 51 mm form factor
* RP2040 microcontroller chip designed by Raspberry Pi in the UK
* Dual-core Arm Cortex-M0+ processor, flexible clock running up to 133 MHz
* 264KB on-chip SRAM
* 2MB on-board QSPI Flash
* 26 multifunction GPIO pins, including 3 analogue inputs
* 2 × UART, 2 × SPI controllers, 2 × I2C controllers, 16 × PWM channels
* 1 × USB 1.1 controller and PHY, with host and device support
* 8 × Programmable I/O (PIO) state machines for custom peripheral support
* Supported input power 1.8–5.5V DC
* Operating temperature -20°C to +85°C
* Castellated module allows soldering direct to carrier boards
* Drag-and-drop programming using mass storage over USB
* Low-power sleep and dormant modes
* Accurate on-chip clock
* Temperature sensor
* Accelerated integer and floating-point libraries on-chip

From the ''[Pico release announcement|https://www.raspberrypi.org/blog/raspberry-pi-silicon-pico-now-on-sale/]'':
%%blockquote

And this isn’t just a powerful chip: it’s designed to help you bring every last drop of that power to bear. With six independent banks of RAM, and a fully connected switch at the heart of its bus fabric, you can easily arrange for the cores and DMA engines to run in parallel without contention.

For power users, we provide a complete C SDK, a GCC-based toolchain, and Visual Studio Code integration. 

As Cortex-M0+ lacks a floating-point unit, we have commissioned optimised floating-point functions from Mark Owen, author of the popular [Qfplib|https://www.quinapalus.com/qfplib.html]  libraries; these are substantially faster than their GCC library equivalents, and are licensed for use on any RP2040-based product.

With two fast cores and and a large amount of on-chip RAM, RP2040 is a great platform for machine learning applications. You can find Pete Warden’s port of Google’s  [TensorFlow Lite|https://www.tensorflow.org/lite] framework [here|https://github.com/raspberrypi/pico-tflmicro]. Look out for more machine learning content over the coming months.

For beginners, and other users who prefer high-level languages, we’ve worked with Damien George, creator of [MicroPython|https://micropython.org/], to build a polished port for RP2040; it exposes all of the chip’s hardware features, including our innovative PIO subsystem. And our friend Aivar Annamaa has added RP2040 MicroPython support to the popular
 [Thonny|https://thonny.org/] IDE.
%%


!! Pinout
 
[{Image src='attach/RaspberryPiPico/Raspberry-Pi-Pico-pinout-diagram.svg' link='attach/RaspberryPiPico/Raspberry-Pi-Pico-pinout-diagram.svg' caption='Pico Pinout (click to enlarge)' align='center' width='1200'}]


!! I2C 

The RP2040 has two [I2C] controllers (0 and 1), both accessible via the Pico's GPIO pins, where the selection of SDA and SDL pins used for each controller is configured in software as per the following table:

|| I2C Controller || GPIO Pins
| I2C0 – SDA      | GP0/GP4/GP8/GP12/GP16/GP20
| I2C0 – SCL      | GP1/GP5/GP9/GP13/GP17/GP21
| I2C1 – SDA      | GP2/GP6/GP10/GP14/GP18/GP26
| I2C1 – SCL      | GP3/GP7/GP11/GP15/GP19/GP27

The I2C controller can run in master or slave mode (default slave address is 0x55); a choice of three speeds: Standard (0-100kB/s), Fast (up to 400kB/s) and Fast Plus (<=1000kB/s). The Raspberry Pi's default I2C frequency is 100kB/s, unless altered in /boot/config.txt. It can be used in either interrupt or DMA mode and includes transmit and receive buffers to 
improve performance. There are [some I2C examples in Micropython|https://github.com/raspberrypi/pico-micropython-examples/tree/master/i2c] on github.

! Example Code

This sets the SCL and SDA pins for I2C Controller 0 to pin 9 and 8 (resp.), then reads and writes from the address 0x76.
{{{
  from machine import Pin, I2C
  
  i2c = I2C(0, scl=Pin(9), sda=Pin(8), freq=100000)
  i2c.scan()
  i2c.writeto(76, b'123')
  i2c.readfrom(76, 4)

  i2c = I2C(1, scl=Pin(7), sda=Pin(6), freq=100000)
  i2c.scan()
  i2c.writeto_mem(76, 6, b'456')
  i2c.readfrom_mem(76, 6, 4)
}}}


!! Links

*From __Raspberry Pi Foundation__:
** [Meet Raspberry Silicon: Raspberry Pi Pico now on sale at $4|https://www.raspberrypi.org/blog/raspberry-pi-silicon-pico-now-on-sale/] (release announcement)
** [Pico Specification|https://www.raspberrypi.org/products/raspberry-pi-pico/specifications/]  
** [Getting Started|https://www.raspberrypi.org/documentation/rp2040/getting-started/]  
** [Pico Product Brief|https://datasheets.raspberrypi.org/pico/pico-product-brief.pdf]
** [RP2040 Datasheet|https://datasheets.raspberrypi.org/rp2040/rp2040-datasheet.pdf] (4.9MB PDF)
* local documentation copies
** [Raspberry Pi Pico Python SDK|attach/RaspberryPiPico/raspberry-pi-pico-python-sdk.pdf] (2.8MB PDF, local copy)
** [Getting Started with Raspberry Pi Pico|attach/RaspberryPiPico/getting-started-with-pico.pdf] (34.6MB PDF, local copy)
** [Hardware design with RP2040|attach/RaspberryPiPico/hardware-design-with-rp2040.pdf] (19.7MB PDF, local copy)
* [Pico Micropython Examples|https://github.com/raspberrypi/pico-micropython-examples] on github (adc, blink, i2c, irq, multicore, pio, pwm, spi, uart/loopback)
* [RP2040|https://en.wikipedia.org/wiki/RP2040] on Wikipedia
*[An Introduction to the Raspberry Pi Pico with MicroPython|https://makersportal.com/blog/raspberry-pi-pico-tests-with-micropython], MakerPortal blog post by Joshua Hrisko, 28 Jan 2021

----

[{Tag Pico}]