The Raspberry Pi Pico is a board based on the RP2040, a brand new microcontroller chip designed by Raspberry Pi in the UK. The RP2040 is a dual-core ARM Cortex M0+ running at 133 MHz which provides 16 MB of off-chip flash and 246 KB on-chip RAM. It has 30 GPIO pins, 4 of which can be used as analogue inputs, two UARTs, two SPI controllers, two I2C controllers, and 16 PWM channels.
Other manufacturers, including Adafruit, Sparkfun, and Pimoroni, have also designed boards based on the RP2040. These boards all have similar performance when running uLisp; for example, they run the Tak benchmark in 8 secs; see Performance.
Featured Content Ads
add advertising hereSaving the workspace
The Raspberry Pi Pico and other RP2040 boards allow you to save the entire workspace using save-image, using the external QSPI flash.
ARM assembler
The ARM version of uLisp includes an ARM assembler that allows you to generate machine-code functions, integrated with Lisp, written in ARM thumb code. The assembler itself is written in Lisp to make it easy to extend it or add new instructions. For more information see ARM assembler overview.
Installing uLisp from the Arduino IDE
- First download the latest ARM version of uLisp from the Download uLisp page.
- In the Arduino IDE install the Arduino Mbed OS RP2040 Boards core from Boards Manager.
You need version 2.1.0 or later. There are problems running uLisp on 2.0.0.
- Select Raspberry Pi Pico from the Board menu.
- Select the Raspberry Pi Pico from the Port menu.
- Upload uLisp to the Raspberry Pi Pico board.
You should then be able to select Serial Monitor from the Tools menu, and enter Lisp commands.
Featured Content Ads
add advertising hereRaspberry Pi Pico
The Raspberry Pi Pico [1] is about the same size as Adafruit’s feather boards:
To install uLisp use the Raspberry Pi Pico board definition in the Arduino Mbed OS RP2040 Boards package.
Pinout
The following diagram shows the pinout of the peripherals available from uLisp with the Raspberry Pi Pico:
Featured Content Ads
add advertising here
LEDs
The Raspberry Pi Pico has a green LED connected to the digital pin 25 which you can flash with the following program:
(defun blink (&optional x) (pinmode 25 t) (digitalwrite 25 x) (delay 1000) (blink (not x)))
Run it by typing:
(blink)
All pins can also be used for analogue (PWM) output, so you can pulsate the LED slowly on and off with the program:
(defun pulse () (let (down) (loop (dotimes (x 256) (delay 5) (analogwrite 25 (if down (- 255 x) x))) (setq down (not down)))))
Run it by typing:
(pulse)
Exit from either program by entering ~.
Analogue inputs
The Raspberry Pi Pico has three analogue inputs which you can access on digital pins 26, 27, and 28. By default they have 10-bit precision, but you can increase the precision to 12 bits with:
(analogreadresolution 12)
Analogue outputs
You can generate an analogue output using PWM on any of the digital pins 0 to 28. By default the precision is 8 bits.
Playing notes
You can use the note function to play tunes on any pin. For example, the following function scale plays the scale of C on the specified pin:
(defun scale (pin) (mapc (lambda (n) (note pin n 4) (delay 500)) '(0 2 4 5 7 9 11 12)) (note))
For example, connect a piezo speaker between digital pin 10 and GND, and evaluate:
(sca 10)
Adafruit Feather RP2040
Adafruit have made an RP2040-based board in their Feather format. It includes a NeoPixel LED and an 8 MByte DataFlash chip:
There’s currently no Arduino core for the Feather RP2040, but you can use the board with the Arduino Mbed OS RP2040 Boards core.
- ^ Adafruit ItsyBitsy M0 Express on Adafruit.