Raspberry Pi Enters Microcontroller Game With $4 Pico – Hackaday

Our quick take: the RP2040 is an extremely well thought-out microcontroller, with myriad great style touches throughout, enough power to get most jobs done, and a innovative and extremely hacker-friendly software-defined hardware I/O peripheral. Its backed by good documentation and many working examples, and at the end of the day it runs a pair of familiar ARM MO+ CPU cores. We can see it ending up being the go-to board for numerous tasks that do not require wireless connection if this strikes the shelves at the proposed $4 rate.

You want more information? Read on.

Just like the Raspberry Pi Linux devices, the emphasis is on getting you up and running rapidly, and there is generous paperwork: from “Getting Started” type guides for both the C/C++ and MicroPython SDKs with code examples, to serious datasheets for the Pico and the RP2040 itself, to hardware design notes and KiCAD breakout boards, and even the contents of the on-board Boot ROM. The Pico appears developed to make a friendly introduction to microcontrollers utilizing MicroPython, however theres adequate guidance readily available for you to go as deep down the rabbit hole as you d like.

Raspberry Pi was associated with single-board Linux computer systems. No longer. The $4 Raspberry Pi Pico board is their attempt to burglarize the congested microcontroller module market.

The microcontroller in concern, the RP2040, is likewise Raspberry Pis very first foray into customized silicon, and its got a dual-core Cortex M0+ with elegant quantities of SRAM and some very interesting custom-made I/O peripheral hardware that will likely indicate that you never ever need to bit-bang once again. But a bare microcontroller is no fun without a dev board, and the Raspberry Pi Pico includes 2 MB of flash, USB connectivity, and nice power management.

The Specs and the Luxuries

The twin ARM M0+ cores run of PLLs, and are specced approximately 133 MHz, which is pretty quickly. There are different clock dividers for nearly every peripheral, and they can be switched on and off individually for power cost savings, as with most other ARM microcontrollers. It runs full-out at around 100 mA @ 5 V, and has full-memory-retention sleep modes under 1 mA.

There are various small hardware-level benefits. All of the setup registers are 32 bits broad, and so you may not wish to need to define all of them, or maybe you wish to avoid the read-modify-write dance. Like many of the STM32 chips, there is a special memory map that lets you set, clear, or XOR any bit in any of the config registers in a single atomic command. There are likewise 30 GPIOs, so they all fit inside a single 32-bit register– none of this Port B, Pin 7 stuff. This likewise suggests that you can read or write them at one time, while setting private pins is easy through the above atomic gain access to.

So the Pico/RP2040 is a proficient modern dev board with some thoughtful touches. It gets better.

As the ESP8266 and ESP32 modules do, it utilizes external flash ROM to shop programs, and can run code directly from the flash as if it were internal memory. The Pico board features a good 2 MB QSPI flash chip, but if youre helpful with a soldering iron, you can fit up to 16 MB. It has 264 kB of SRAM, which is certainly comfortable. The RAM is divided up internally into 4 striped 64 kB banks for fast parallel access, but theyre also accessible singly if you d like. Two extra 4 kB banks are non-striped and suggest utilizing themselves as per-core stack memory, however nothing forces you to utilize them that method either.

In many ways, the Pico is a well-appointed “regular” microcontroller board. The Pico has a 12-bit ADC, although its linked to only four pins, so youve got to be a little careful there.

The power guideline onboard is a boost-buck configuration that takes an input from 1.8 V to 5 V. This is a good variety for lithium batteries, for example, which can be a hassle since they run both above and listed below the ICs 3.3 V, so its great to have a boost-buck regulator to eject the last couple of milliamp-hours. Or you might run your project on 2 AAs. Thats great.

When you plug the Pico in holding down the BOOTSEL button, it reveals up as a USB mass storage gadget, and you can simply copy your code throughout, with no developer, and Raspberry even provides an all-zeros file that you can copy across to completely clean-slate the machine. If you copy the Picos MicroPython binary throughout, nevertheless, youll never require the bootloader once again.

The PIO: Never Bitbang Again

The PIOs are indicated to have a lot of the flexibility of a CPLD or FPGA, but be much easier to program. Each state maker can only take a “program” that is 32 directions long, however the “pioasm” language is very thick. For example, the command to set pin states also has an argument that states how long to wait after the pins are set, and additional “side-set” pins can be twiddled in the exact same instruction. So with one direction you can raise a clock line, set up your data, and hold this state for a defined time. A basic SPI master TX application is two lines.

To run PIO code from C, the assembler is called at put together time, the program is developed into maker language and kept as a matrix in a header file, and after that this can be composed to the PIO device from within primary() to initialize it. In Python, its even much easier– the @asm_pio decorator turns a function into PIO code. You simply need to write the “Python” function utilizing the nine PIO assembly directions and then hook it approximately GPIO pins. After that, you can call it from your code as if it were a typical peripheral.

Or take the example of the WS2812 LED protocol. To send out a sensible 1, you hold the self-clocked data line high for a long duration and low for a short period. To send out a sensible 0, the information line is held high for a brief duration and low for a long one. Developing the routines to do this with affordable speed in the CPU, without glitches, needed a non-trivial shedding of hacker tears. With the PIO peripheral, writing a routine to move out these bits with outright cycle precision is basic, and once thats done your code can simply compose RGB values to the PIO and the rest is looked after.

Having played around with it only a little bit, the PIO is the coolest function of the Pico/RP2040. Its simply a little bit of cycle-correct programmable reasoning, however the majority of the time, thats all you require. And if you do not feel like discovering a new assembly language– although its just 9 guidelines– there are a heaping handful of examples already, and definitely folks will establish more once the boards struck the streets.

If you wish to configure another UART, for instance, its unimportant. So is Manchester-encoded UART, or a grey code encoder/decoder, or even fancier tricks. Among the example applications is a DPI video example, with one state device dealing with the scanline timing and pixel clock, while another presses out the pixel data and run-length encodes it. These are the sort of simple-but-fast tasks that can slow down a CPU, resulting in timing problems, so devoted hardware is the best option.

The genuine standout peripheral on the RP2040 and the Pico is the Programmable I/O (PIO) hardware, which allows you to specify your own digital interaction peripheral. There are 2 of these PIO units, and each one has 4 programmable state machines that run sequential programs composed in an unique PIO assembly language.

SDKs and ides: C and MicroPython

And having a Raspberry Pi SBC on hand makes a lot of the most hardcore microcontrollering simpler. If you desire to do debugging on-chip, youll require to link over the SWD interface, and for that you generally require a programmer. Of course, you can also bit-bang a SWD controller with the GPIOs of a Raspberry Pi SBC, but youll have to set up OpenOCD simply right to do so.

If that all sounded like gibberish, do not stress– all of this is taken care of by a basic pico_setup. It not just installs all of the collection and debugging environment, it likewise (optionally) pulls down VScode for you.

If youre a command-line addict, the C SDKs build system is based upon CMake and runs simply great from the command line if youve currently got the ARM toolchain set up. And as with all SDKs, theres a particular quantity of boilerplate required to start up a new coding session. This is taken care of by the pico job generator, so you do not have to.

USB for power, UART for communication, and SWD for programs and debugging.

The Raspberry Pi single-board computers (SBCs), when integrated with their documentation and examples, typically manage a good mix of being simple enough for the rookie while at the exact same time not concealing too much. The outcome is that, rather than having the underlying systems Linuxiness abstracted away, you get introduced to it in a friendly way. That seems to be what the Raspberries are targeting at with the Pico– an intro to microcontrollers thats made friendly through documents and MicroPythons ease of usage, but thats also not pulling any punches when you turn to take a look at the C/C++ code.

And you will wish to set it over the SWD eventually. The cycle of unplugging USB, holding down a button, and re-plugging USB gets old real quick.

In the “Getting begun” guides, youll find instructions for setting up your environment on a Raspberry Pi SBC, Windows, Mac, or desktop Linux maker. There are combination instructions as well if you choose Eclipse as an IDE.

Two Cores: Here be Dragons

We composed the Raspberries and asked if they were preparing to port over an RTOS, which supplies a little more structure to the issue, and they responded that was really very first on their plate after they get through the release. Were truthfully looking forward to an RTOS getting the Raspberry Pi documentation-and-tutorial treatment when it happens.

With the Pico, Raspberry Pi is entering a crowded field. Theyve got the name acknowledgment, a cool hardware trick, an excellent value proposal, and a performance history of strong documentation. If I were coding up a GPIO-heavy application without the need for wireless, the Pico would be a solid choice, specifically if I could use the extra core.

Its not every day that you see a brand-new player enter the microcontroller market, not to mention one with the hacker-friendly qualifications of Raspberry Pi. For that alone, this board is noteworthy. However the function set is also solid, there are numerous creature conveniences in both the support and the silicon, and it brings one genuinely brand-new ability to the table in the form of the PIO units. Add to all this a price tag of $4, and you can picture it ending up being folks go-to board– for those times when you do not need wireless connectivity.

If theres one area that strikes me as not yet completely developed, its the dual-core aspect of the system. Now, if you compose either C or Python code, its running on Core 0, while Core 1 is simply sitting idle. Both the C and Python SDK documentation tell you how to begin up a thread on the other core, and theres example code readily available as well, but the directions are sparse.

The $4 Raspberry Pi Pico board is their effort to break into the congested microcontroller module market.

When you plug the Pico in holding down the BOOTSEL button, it reveals up as a USB mass storage gadget, and you can just copy your code throughout, with no programmer, and Raspberry even offers an all-zeros file that you can copy throughout to completely clean-slate the machine. Were truthfully looking forward to an RTOS getting the Raspberry Pi documentation-and-tutorial treatment when it occurs.

Of course, for somewhat less cash, one can get one of the STM32-based “Black Pill” boards, with yet another set of cons and pros. Options, options!

Indeed, the only real rival for this board in regards to price/performance ratio are the different ESP32 boards. But theyre also very different animals– one offers less GPIOs however has comprehensive cordless functions, and the other has more (and more versatile) Host, gpio and device USB, however no radio. Power consumption while running full-out, with wireless turned off, is a slight benefit for the ESP32, however the sleep modes of the Pico are slightly thriftier. Both SDKs get the job done in C, and both run MicroPython. ESP32s dual cores run FreeRTOS, but we envision it will not be really long prior to that playing field is levelled. So generally its down to WiFi vs USB.


Its not every day that you see a brand-new gamer get in the microcontroller market, let alone one with the hacker-friendly qualifications of Raspberry Pi. With the Pico, Raspberry Pi is entering a congested field.

Ill leave you with a teaser: On page 9 of the RP2040 datasheet, they set out what “2040” represents: two cores, type M0+, more than 256 kB RAM, and no kB flash. Does that mean well ultimately see designs with more RAM, onboard flash, or various ARM cores? RP2050? RP2048? Speculate hugely in the comments.

Leave a Reply

Your email address will not be published. Required fields are marked *