EYE ON NPI - Raspberry Pi RP2040 #EYEonNPI #DigiKey #Adafruit @Raspberry_Pi @digikey
Channel: Adafruit Industries
Date: 03/06/2021

This week's EYE ON NPI is easy-as-pie: it's the Raspberry Pi RP2040 microcontroller (https://www.digikey.com/en/products/detail/raspberry-pi/SC0908-7/14306009), finally available for purchase in tape and reel for manufacturing. The RP2040 is one of the most hotly-anticipated EYE ON NPI's of the year - it's been a few months since we've been enjoying the RP2040 in devboards. Adafruit has featured it in many popular dev boards like the QT Py RP2040 (https://www.adafruit.com/product/4900), Feather RP2040 (https://www.digikey.com/en/products/detail/adafruit-industries-llc/4884/14000603) and ItsyBitsy RP2040 https://www.digikey.com/en/products/detail/adafruit-industries-llc/4888/14115610).
Thanks to the Raspberry Pi Foundation, Adafruit got a few early reels so we could develop our layouts and board designs - that whetted the appetites of a lot of developers who saw the massive number of designs available from Sparkfun, Pimoroni, Seeed and others and wanted to join in the fun! Well, now you can because Digi-Key is stocking the chips in reels for anyone to purchase.  They're available in 7" reels (https://www.digikey.com/en/products/detail/raspberry-pi/SC0908-7/14306009) with 500 chips in a spool, or in 13" reels (https://www.digikey.com/en/products/detail/raspberry-pi/SC0908-13/14306010) with 3400 chips. At a cost of $1 each pre-quantity (quantity pricing is not yet determined)

For that $1, you get a lot of technology:
RP2040 Chip features:

Dual ARM Cortex-M0+ @ 133MHz
264kB on-chip SRAM in six independent banks
Support for up to 16MB of off-chip Flash memory via dedicated QSPI bus
DMA controller
Fully-connected AHB crossbar
Interpolator and integer divider peripherals
On-chip programmable LDO to generate core voltage
2 on-chip PLLs to generate USB and core clocks
30 GPIO pins, 4 of which can be used as analog inputs
Peripherals
2 UARTs
2 SPI controllers
2 I2C controllers
16 PWM channels
USB 1.1 controller and PHY, with host and device support
8 PIO state machines
The RP2040 uses the Cortex M0+ core, which is is good for microcontroller projects. It's not fast enough or capable of running Linux like a Raspberry Pi computer but it can run Arduino/MicroPython/RTOS pretty easily. To make up for the M0 core, the chip is run very fast, at ~130MHz, much faster than many of the Cortex M0's we've worked with that tend to run at 48 Mhz or so. Since it is an M0 chip, it does not have a floating point unit or DSP hardware support - so if you're doing something with heavy floating point math, it will be done in software and thus not as fast as a Cortex M4.

For peripherals, there are two I2C controllers, two SPI controllers, and two UARTs that are generously multiplexed across the GPIO - check the pinout for what pins can be set to which. There are 16 PWM channels, each pin has a channel it can be set to (ditto on the pinout). While its not a full crossbar-type chip, it's easy to find pins for your peripherals.

You'll note there's no I2S peripheral, or SDIO, or camera, what's up with that? Well instead of having specific hardware support for serial-data-like peripherals like these, the RP2040 comes with the PIO state machine system which is a unique and powerful way to create custom hardware logic and data processing blocks that run on their own without taking up a CPU. For example, NeoPixels - often we bitbang the timing-specific protocol for these LEDs. For the RP2040, we instead use PIO object that reads in the data buffer and clocks out the right bitstream with perfect accuracy. Same with I2S audio in or out, LED matrix displays, 8-bit or SPI based TFTs, even VGA! In MicroPython and CircuitPython you can create PIO control commands to script the peripheral and load it in at runtime. There are 2 PIO peripherals with 4 state machines each.

While the RP2040 has lots of onboard RAM (264KB), it does not have built-in FLASH memory. Instead, that is provided by the external QSPI flash chip. You will need to provide external FLASH memory using QSPI NOR memory. The flash chip is shared between the program it's running and any file storage used by MicroPython or CircuitPython. We like this GigaDevice chip (https://www.digikey.com/en/products/detail/gigadevice-semiconductor-hk-limited/GD25Q80CSIGR/9484688) but just about any QSPI flash memory will work just fine. You'll also need a 12 MHz crystal and lots of capacitors and some passive components to finish off the design.

With top-notch documentation, lots of board examples, firmware-aplenty, and of course a rock-bottom price, its an excellent chip to use for just about anything. Especially with the PIO peripherals, this chip can 'punch up' quite a bit and perform tasks or process data that normally would require much more powerful chips or advanced peripherals - things like cameras, TFT displays, motor drivers, PDM/I2S/PCM encoding and more. Sign up to be notified the moment the RP2040 chips are in stock at Digi-key here (https://www.digikey.com/short/8mt22d38)