Silicon ChipRaspberry Pi Pico - December 2021 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Making kits is not easy!
  4. Feature: Big Brother is Tracking You! – Part 2 by Dr David Maddison
  5. Project: Hummingbird Audio Amplifier by Phil Prosser
  6. Feature: SMD Soldering – tips and tricks by Tim Blythman
  7. Project: SMD Trainer Board by Tim Blythman
  8. Feature: El Cheapo Modules: 35MHz-4.4GHz Signal Generator by Jim Rowe
  9. Review: Raspberry Pi Pico by Tim Blythman
  10. Project: Digital Lighting Controller Translator by Tim Blythman
  11. Serviceman's Log: A mixed bag of odds, sods, ends and bobs by Dave Thompson
  12. Product Showcase
  13. Project: USB Cable Tester – Part 2 by Tim Blythman
  14. Vintage Radio: Restoring a Sony 5-303E Micro-TV by Dr Hugo Holden
  15. Subscriptions
  16. PartShop
  17. Ask Silicon Chip
  18. Market Centre
  19. Advertising Index
  20. Notes & Errata: Tele-com Intercom, October 2021; Hybrid Lab Supply with WiFi, May & June 2021
  21. Outer Back Cover

This is only a preview of the December 2021 issue of Silicon Chip.

You can view 40 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • Big Brother is Tracking You! – Part 1 (November 2021)
  • Big Brother is Tracking You! – Part 1 (November 2021)
  • Big Brother is Tracking You! – Part 2 (December 2021)
  • Big Brother is Tracking You! – Part 2 (December 2021)
Items relevant to "Hummingbird Audio Amplifier":
  • 4-way Loudspeaker Protector PCB [01101222] (AUD $5.00)
  • The Hummingbird Audio Amplifier PCB [01111211] (AUD $5.00)
  • 6-way Loudspeaker Protector PCB [01101221] (AUD $7.50)
  • Hard-to-get parts for the Hummingbird Amplifier (Component, AUD $15.00)
  • Multi-Channel Speaker Protector PCB patterns (PDF download) [01101221-2] (Free)
  • The Hummingbird Audio Amplifier PCB pattern (PDF download) [01111211] (Free)
Items relevant to "SMD Trainer Board":
  • SMD Trainer PCB [29106211] (AUD $5.00)
  • Kit for the SMD trainer (Component, AUD $20.00)
  • SMD Trainer PCB pattern (PDF download) [29106211] (Free)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
Items relevant to "Digital Lighting Controller Translator":
  • Flexible Digital Lighting Controller main PCB [16110202] (AUD $20.00)
  • Flexible Digital Lighting Controller Micromite Master PCB [16110201] (AUD $5.00)
  • Flexible Digital Lighting Controller CP2102 Adaptor PCB [16110204] (AUD $2.50)
  • Flexible Digital Lighting Controller LED slave PCB [16110205] (AUD $5.00)
  • PIC16F1705-I/P programmed for the Flexible Digital Lighting Controller [1611020A.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC32MX170F256B-50I/SP programmed for the Flexible Digital Lighting Controller Micromite master [1611020B.hex] (Programmed Microcontroller, AUD $15.00)
  • PIC16F1455-I/P programmed for the Flexible Digital Lighting Controller WS2812 Slave [16110205.HEX] (Programmed Microcontroller, AUD $10.00)
  • Si8751AB 2.5kV isolated Mosfet driver with integral power supply (Component, AUD $10.00)
  • Micromite LCD BackPack V3 complete kit (Component, AUD $75.00)
  • Hard-to-get parts for the Flexible Digital Lighting Controller (Component, AUD $100.00)
  • Flexible Digital Lighting Controller front panel PCB [16110203] (AUD $20.00)
  • Firmware and software for the Fiexible Digital Lighting Controller (Free)
  • Firmware and PC software for the Digital Lighting Controller [1611010A.HEX] (Free)
  • Flexible Digital Lighting Controller mains slave PCB patterns (PDF download) [16110202-3] (Free)
  • Flexible Digital Lighting Controller Master PCB patterns (PDF download) [16110201, 16110204] (Free)
  • Flexible Digital Lighting Controller LED slave PCB pattern (PDF download) [16110205] (Free)
  • Drilling and cutting diagrams for the Flexible Digital Lighting Controller Micromite master (PDF download) (Panel Artwork, Free)
  • Cutting diagram for the Flexible Digital Lighting Controller mains slave rear panel (PDF download) (Panel Artwork, Free)
  • Cutting diagrams and front panel artwork for the Flexible Digital Lighting Controller LED slave (PDF download) (Free)
  • Digital Lighting Controller Translator PCB [16110206] (AUD $5.00)
  • PIC16F1705-I/P programmed for the Digital Lighting Controller Translator [1611020F.HEX] (Programmed Microcontroller, AUD $10.00)
  • Firmware for the Digital Lighting Controller Translator [1611020F.HEX] (Software, Free)
  • Digital Lighting Controller Translator PCB pattern (PDF download) [16110206] (Free)
  • Drilling/cutting diagrams and lid panel artwork for the Digital Lighting Controller Translator (Free)
Articles in this series:
  • Flexible Digital Lighting Controller, part 1 (October 2020)
  • Flexible Digital Lighting Controller, part 1 (October 2020)
  • Flexible Digital Lighting Controller, part 2 (November 2020)
  • Flexible Digital Lighting Controller, part 2 (November 2020)
  • Flexible Digital Lighting Controller, part 3 (December 2020)
  • Flexible Digital Lighting Controller, part 3 (December 2020)
  • Digital Lighting Controller Translator (December 2021)
  • Digital Lighting Controller Translator (December 2021)
Items relevant to "USB Cable Tester – Part 2":
  • USB Cable Tester main PCB [04108211] (AUD $7.50)
  • PIC16F18877-I/P programmed for the USB Cable Tester [0410821C.HEX] (Programmed Microcontroller, AUD $15.00)
  • Relay - 1A DPDT 5V DC coil (EA2-5NU) (Component, AUD $3.00)
  • IPP80P03P4L-07 high-current P-channel Mosfet (Component, AUD $2.50)
  • Short form kit for the USB Cable Tester (Component, AUD $110.00)
  • USB Cable Tester front panel PCB [04108212] (AUD $5.00)
  • Laser-cut acrylic bezel for USB Cable Tester (PCB, AUD $2.50)
  • Firmware and bezel laser cutting files for the USB Cable Tester [0410821A.HEX] (Software, Free)
  • USB Cable Tester PCB patterns (PDF download) [04108211/2] (Free)
Articles in this series:
  • USB Cable Tester – Part 1 (November 2021)
  • USB Cable Tester – Part 1 (November 2021)
  • USB Cable Tester – Part 2 (December 2021)
  • USB Cable Tester – Part 2 (December 2021)

Purchase a printed copy of this issue for $11.50.

Hands-on with Tim Blythman Raspberry Pi is a trademark of the Raspberry Pi Foundation The Raspberry Pi Pico Microcontroller The Raspberry Pi Foundation (www.raspberrypi.org) is well known for its range of inexpensive single-board computers, firmly aimed at the educational market but used by many others. Now they have released a very low-cost microcontroller board with an interesting set of peripherals. O ver the last ten or so years, the Raspberry Pi Foundation has continued to surprise us (in a good way) with their range of Raspberry Pi SBCs (single-board computers). These tiny boards have been used from embedded applications through to fully-fledged desktop machines. Over 30 million units have been sold since they were introduced, undoubtedly helped by very attractive pricing. We have reviewed several of these, including the model 3B+ (July 2018; siliconchip.com.au/Article/11141) and the 4B (August 2019; siliconchip. com.au/Article/11772). These boards can run the Raspberry Pi Foundation’s Linux-based desktop operating system, now known as Raspberry Pi OS. Earlier versions were known as ‘Raspbian’ as a nod to their Debian Linux roots. In addition, other third-party operating systems have been produced and ported to the various Raspberry Pi computers. Some operating systems turn these boards into media centres or retro gaming consoles. However, the boards’ target price of US$35 (currently about $46) also means that they are well suited for their primary intended use as an educational computer. The minimalist Raspberry Pi Zero boards can be had for under $10; we used one in our Speech Synthesiser 48 Silicon Chip from July 2019 (siliconchip.com.au/ Article/11703). It’s incredible that something as powerful as a desktop computer from around twenty years ago can be so small and cheap. Pico board However, the new Raspberry Pi Pico cannot be used as a desktop computer; it is a microcontroller board featuring the Raspberry Pi Foundation’s own RP2040 microcontroller. Still, it echoes the philosophy of other Raspberry Pi products. The claimed target price is US$4, and we purchased our units from DigiKey and Core Electronics for roughly the equivalent in Australian currency (excluding shipping) of about $5.25. Unfortunately, being so cheap has meant that there have been minor delays in obtaining the Pico, presumably due to high demand as well as the ongoing chip shortages. They are also now available from Altronics. The low price also means that it should find a good following in the educational sector and various Like many other microcontroller boards, the Pico is suited to breadboard use, although it does not come with header pins. This is a cost-saving measure that we have seen on other Raspberry Pi products like the Pi Zero. We have fitted the three-pin SWD header with right-angled pins at the opposite end to the microUSB socket. Australia’s electronics magazine siliconchip.com.au Board Used in Clock RP2040 ESP8266 ESP32 PIC32MX470 SAMD21 Pico D1 Mini Various modules Micromite Plus Arduino MKR 133MHz 160MHz 240MHz 120MHz 48MHz RAM 264kB 80kB 520kB 128kB 32kB Flash external (2MB) external (4MB) up to 4MB 512kB 256kB Cores 2 x ARM 1 x Tensilica 2 x Xtensa LX6 1 x MIPS 1 x ARM Pins 56 32 48 64 48 GPIO 30 11 34 45 22 UART 2 1 3 4 1 SPI 2 1 4 2 1 I2C 2 software only 2 2 1 PWM 16 software only 16 5 12 ADC 4 x 12-bit 1 x 10-bit 18 x 12-bit 28 x 10-bit 7 x 12-bit USB host/device no OTG host/device host/device no WiFi WiFi & Bluetooth no no Radio Table 1: how the Raspberry Pi Pico (RP2040) compares to other ‘similar’ microcontroller chips. other diverse fields, as we have seen with the other Raspberry Pi products. The RP2040 chip The basic specs of this chip are shown in Table 1, compared to some other familiar parts. The Pico’s RP2040 microcontroller was designed internally by the Raspberry Pi Foundation. This not only helps to keep the cost down, but it also allows the chip to be customised, and we will elaborate later on the interesting and unusual peripherals that have been incorporated as a result. The RP2040 is based on the ARM Cortex M0+. Boards such as the Arduino Zero and MKR series also sport such a processor; it is well-established. It is a 32-bit processor and, as is fairly typical for those, runs from 3.3V. The chip does not have internal flash memory, instead needing an external serial flash chip. Thus, various flash memory sizes can be provided by simply changing the external flash. An internal cache means that the flash speed does not typically limit the processor’s operating speed, and there is an option to copy and run code from RAM. The chip does have 16kB of internal boot mask ROM. This includes ‘bootstrap’ code which initialises the chip siliconchip.com.au and can download firmware to the flash chip via USB flash drive emulation. It also provides some optimised floating-point, bit manipulation and memory functions. You can download the full (600+ page) data sheet which explains all this from siliconchip.com.au/link/abab Peripherals The RP2040 features a single-cycle hardware multiplier, dual processor cores and a DMA peripheral. All of these are handy for implementing signal processing type applications, amongst other things. While there are 36 pins that could be used for general-purpose I/O (GPIO), six of these are generally used for the flash memory interface (in four-bit QSPI mode), leaving 30 for practical use. Four of these remaining pins are connected to the analog-to-digital converter (ADC) peripheral, and can be used as analog inputs. Broadly, any of these 30 pins can be used with just about any digital peripheral (such as SPI, I2C, PWM or UART), but each pin only in specific roles and grouped as such. This is similar to the PIC32 peripheral pin select (PPS) system. Each physical pin also has so-called ‘pad’ settings that control features such as drive strength, slew rate, Australia’s electronics magazine The Tiny 2040 board (shown at triple actual size) might be worth considering if you need a smaller device with fewer pins. Despite its smaller size (18 x 21mm), it was more expensive than the Pico due to the way the Raspberry Pi Foundation discounts its products. input levels, pull-ups and pull-downs. These work independently of the peripheral that is driving the pin. There is a USB peripheral that supports both device (full-speed) and host (full-speed and low speed) modes. At the Pico’s price, we can see it being used simply as a USB ‘widget’; for example, emulating a keyboard, mouse or other simple devices such as a serial port. PIO Probably the most interesting peripheral is the PIO or programmable input-output block. It could almost be considered to be a unique microprocessor optimised for input and output functions. Rather than having its function set by registers, each PIO block is controlled by a state machine with a small program that can be changed at runtime. We’ve already seen people using the PIOs to generate HDMI-compatible DVI video signals (with some processor overclocking), so it is very versatile. There are examples at https://github. com/raspberrypi/pico-examples/tree/ master/pio, including driving devices like WS2812 serial LEDs and HUB75 LED matrices. There are also examples to reproduce standard peripheral functions such as SPI and UART. December 2021  49 The Pico board The Pico board measures 51 x 21mm, with a micro-USB socket at one end and a 3-pin serial wire debug (SWD) header at the other. The two sides are lined with 20-way castellated vias. As expected at the price point, none of the headers are populated. Apart from the RP2040 IC and its surrounding passive components, a 3.3V switchmode regulator (surrounded by the necessary passives) provides power for the board. The dual-mode (PWM/PFM) regulator can be controlled by the micro via GPIO23. A tactile pushbutton is used to enter bootloader mode at reset. There are no other buttons to effect a reset, so the simplest way to start the bootloader is to hold the button while plugging in the board. A solitary LED and its series resistor are connected to GPIO25, while you can use a divider connected to GPIO24 to detect the presence of USB power. Thus the full complement of I/O pins are not brought out to external headers. A 12MHz crystal and the flash chip in an 8-pin leadless package round out the component list. There are six test pads on the back of the PCB, along with a QR code, which appears to be a serial number. The back of the PCB also has the I/O pin labels. Four holes to suit M2 machine screws are present. The board is suitable for use with a breadboard by soldering on headers, mounting in an enclosure via the holes or even soldering to a larger carrier board. In short, the board is not overly adorned but has been well-designed to suit a wide range of purposes and end-users. For the price, we cannot complain. But wait, there’s more In addition to the Pico, the Raspberry Pi Foundation is also making bare RP2040 chips available for sale. In addition to this, several other boards are available with the same microcontroller, including some made by Sparkfun and Adafruit. Many of these boards have opensource schematics (the Pico’s is in its 30-page data sheet), so creating your own variant won’t be too hard, if you don’t mind soldering QFN parts! There is also an Arduino “Nano RP2040 Connect” board, including a WiFi chip. It isn’t as cheap as the Raspberry Pi Pico, but it’s good to see such broad support for the new chip. Programming As noted earlier, the bootloader ROM on the RP2040 provides a USB interface when the Pico is started with the bootloader button pressed. This shows up as a virtual USB drive, as seen in Fig.1. It’s not a real drive that can load and save files, but it does provide two small files for reference. We saw a similar system on the Curiosity Nano AVR128DA48 board we reviewed (January 2021; siliconchip. com.au/Article/14696). This allows programming (or uploading firmware) by a simple drag-and-drop process. The Pico is the same, although it uses the so-called UF2 file format rather than the HEX file that is otherwise commonly used. The UF2 format has been designed by Microsoft to make uploading simple for both the user and the microcontroller. It is documented at https://github.com/ microsoft/uf2 Probably the most significant consequence of this arrangement is that it is practically impossible to ‘brick’ the Pico. The USB interface is defined in an immutable ROM and can be accessed by keeping the bootloader pin low at reset or power-up. More info can be found at www. raspberrypi.org/documentation/ rp2040 including guides to getting started and various data sheets. Much of the software is open source, and there are also third-party tools becoming available; we’ll mention those that we found useful. Silicon Chip When we first obtained our boards, there were two main ways of programming the Pico provided by the Raspberry Pi Foundation. The first of these is Micropython. The Python language is provided with many Raspberry Pi OS distributions. It’s also possible to set up a compiled C environment. This is a bit more involved, both regarding setup and use, but it appears some people have created an installer to simplify the setup process. Even so, a lot of command-line interaction is needed. More recently, there is now also an Arduino Boards Manager add-on which means that the Pico (and other RP2040-based boards) can be programmed through the Arduino IDE. Micropython Micropython is a subset of the Python 3 programming language that is optimised for microcontrollers. Programming with Micropython is a bit like programming with MMBasic on the Micromite. It includes a read-evaluate-print loop (REPL) prompt, similar to many older home computers. You can type single commands and see their immediate effect or enter complex programs and run them. You can also develop code in a PC-based IDE (integrated development environment) and then run the program on the Micropython hardware. The Pico is not the only board that can run Micropython; many 32-bit boards (especially those with ARM processors) can do so, as can the ESP8266 and ESP32. One advantage of Micropython (and other Python variants) over BASIC is that the Python language is standardised, so it is easier to find and write libraries that can be imported. This, in turn, makes it potentially more powerful, versatile and portable. Micropython implements a simple filesystem on the flash chip to allow user programs to be installed and extra Fig.1: when the Pico’s bootloader is active and it’s plugged into a USB port, it appears as a virtual drive to which you can copy a firmware file. The bootloader code is in a mask ROM baked into the RP2040 microcontroller at the factory, so all RP2040-based boards should have this feature. The Raspberry Pi Pico is built on a tiny 51 x 21mm board and is shown at actual size above. 50 Software Australia’s electronics magazine siliconchip.com.au libraries and other files to be loaded. With ample flash available, the Pico is well-suited to this role. Getting started with Micropython on the Pico is a simple case of loading the UF2 firmware file and then opening a serial terminal program to interface to the serial port, where the REPL prompt and interaction occur. Fig.2 shows several commands being issued at the prompt, including one to list the included modules. A module is what might be called a library file in other languages. For example, the “machine” module supports various I/O functions, including the ADC, pulse-width modulation (PWM) and communication peripherals such as SPI and I2C. You can find more information about Micropython and the UF2 files needed to run Micropython on the Pico at https://micropython.org/download/ rp2-pico/ Example Micropython code for the Pico can be found at https://github. com/micropython/micropython/tree/ master/examples/rp2 Note that the RP2 designation is the superset of microcontrollers which includes the RP2040 used in the Pico. Fig.2: Micropython will run on the Pico. It has an interactive prompt and a flash-based filesystem that can hold user programs and libraries. Although the language is a subset of Python, the overall feel is similar to BASIC computers like the Micromite. Fig.3: utilities like the Project Generator make C development quite easy once the environment is set up. Many compiler options are hidden by simply using the “nmake” command to initiate the compilation process. C language SDK Most of the microcontroller programming that we do is in the C language, typically on PIC microcontrollers using the MPLAB X IDE, so we were keen to see how useful and easy this would be. It is very much dependent on working with a command prompt. We found a few GUI tools to help set up projects, but you need to provide your own text editor. The documentation page has links for the C SDK (software development kit) in a GitHub repository and a script for setting this up on a Raspberry Pi and other Linux computers. It also includes several example programs. The SDK requires various other programs to be installed to provide a complete development environment, and we were not able to set this up successfully on a Windows PC. However, this appeared to be a problem with just one of the necessary programs, which hopefully has been fixed by the time this article is published. Fortunately, someone has bundled together all the necessary components in a simple installer, which you can find at https://github.com/ndabas/ pico-setup-windows siliconchip.com.au We recommend this alternative for those who are comfortable programming in an IDE, unless you are familiar with manually setting up compiler toolchains. This also installs some example programs and a project generator utility. This utility is used to set compiler options beyond what can be configured by the source code. This is shown in Fig.3; it is started with the “pico_project.py –gui” command from the pico-project-­generator folder. Australia’s electronics magazine There is also a “pico-env.cmd” file that can be used to set up a prompt with the appropriate environment variables. We found it handy to create shortcuts to these two utilities, as we were accessing them often. After doing that, we had no trouble copying bits and pieces from the example code into our generated C file. Then, to compile it, we changed to the “build” subdirectory and ran the “nmake” command. This resulted in a UF2 file in the build subdirectory, ready for uploading. December 2021  51 We haven’t tried it but we expect that for those who have installed the SDK on a Raspberry Pi or other Linux machine, the experience will be much the same, perhaps except for the use of “make” instead of Microsoft’s “nmake”. Arduino The Arduino Team has recently released the Arduino Nano RP2040 Connect board, although we have not tested it yet. We think this will be a handy board, as it will incorporate the NINA-W102 WiFi and Bluetooth radio module, as seen in several other Arduino boards. That includes the MKR Vidor, which we reviewed in March 2019 (siliconchip.com.au/ Article/11448) They also announced that the Arduino IDE (specifically, the Boards Manager) would support other RP2040 based boards, including the Pico. In fact, this support is already available, so we were able to test out programming the Pico using the Arduino IDE. This is as simple as searching for “RP2040” in the Boards Manager and installing the “Arduino Mbed OS RP2040 boards”. Mbed OS is a platform for developing on ARM microcontrollers. We found an interesting catch-22 while trying to use this board profile. It assumes that each board is assigned a serial port for programming. This is not necessarily the case with a new Pico and definitely not in bootloader mode. Once a sketch has been uploaded, it includes a serial port, but the difficulty is in performing the first upload. We found the easiest way to get around this was to use the Sketch → Export Compiled Binary option to generate a UF2 file, then use the bootloader to install it. After this, we could see and select a serial port as for other Arduino boards. Sometimes the port number changed, but that was easy to fix. As an aside, we found another board variant at https://github.com/ earlephilhower/arduino-pico which also circumvents this problem. It is a third-party board profile that builds the binary using the C SDK that we mentioned earlier. Cleverly, it does not require a serial port for uploading, but can detect the presence of the virtual USB drive that the Pico’s bootloader creates and 52 Silicon Chip uploads the file that way. Thus it’s another handy way to rescue boards that the Arduino IDE otherwise can’t recognise. You can install it by adding a link to https://github.com/earlephilhower/ arduino-pico/releases/download/ global/package_rp2040_index.json in the Boards Manager Preferences. The window shown in Fig.4 includes the two board profiles that we tried. This version also includes support for some Picoprobe boards, as well as a board from Adafruit. Picoprobe A Picoprobe is essentially a Pico programmed with firmware that allows it to behave like an ARM SWD debugger and a USB-serial converter. As we noted in our review in June 2021 (siliconchip.com.au/Article/14890), the Arduino 2.0 IDE can perform in-circuit debugging, but requires a probe; it appears that the Picoprobe can fill that role. There are examples showing how one Pico can be used to debug another. Since many debugging interfaces can also be used for programming, the Picoprobe variants described use the Picoprobe interface instead of the serial port for programming. Other boards Apart from the Arduino Nano RP2040 Connect that we mentioned, there is also the Adafruit Feather RP2040, plus variants from Sparkfun and Pimoroni. We managed to get one of the Pimoroni boards, called the Tiny 2040, as seen in our photo. But it appears that demand is high for these very cheap boards, and supplies are being snapped up as soon as they become available. No doubt, these circumstances aren’t helped by current chip shortages. Conclusion Like the Raspberry Pi single-board computers, the Pico microcontroller board offers exceptional value and ease of use. The sheer number of ways that it can be easily programmed is pleasing to see. Assuming that supply can keep up with demand, we do not doubt that the Pico and other RP2040 variants will be used not just for education, but just about anywhere that a 32-bit microcontroller is needed. With HDMI-compatible video already being coaxed from the chip and native USB support, it is not a stretch to imagine people tacking this board onto a project for these peripherals alone. So like the Raspberry Pi, it will see a variety of uses. The Pico, as well as numerous other RP2040-based boards and accessories, are available (subject to supply constraints) from: • Altronics: siliconchip.com.au/ link/aba8 • Core Electronics: siliconchip. com.au/link/aba9 • Digi-Key: siliconchip.com.au/ SC link/abaa Fig.4: we tried two different Arduino board profiles for working with RP2040 boards like the Pico. The Arduino team has also announced the Arduino Nano RP2040 Connect board, which will include a WiFi chip like many other recent Arduino boards. Australia’s electronics magazine siliconchip.com.au