Pimoroni RP2350 boards
Pimoroni started life as a distributor of boards manufactured by other companies, but recently they have developed a range of their own accomplished boards, and two recent ones are these processor boards based on the Raspberry Pi RP2350.
Introduction
Both boards are based on the Raspberry Pi RP2350 running at 150MHz. The Pimoroni Pico Plus 2 has 16MB of flash, and the Pimoroni Tiny 2350 has 4MB flash. They both have 520KB on-chip SRAM, but in addition the Pimoroni Pico Plus 2 has 8MB of PSRAM.
The Pimoroni Pico Plus 2 has an LED, and the Pimoroni Tiny 2350 has an RGB LED.
Saving the workspace
Both boards use the LittleFS flash filesystem supported by the Raspberry Pi Pico/RP2040/2350 core to allow you to save the entire workspace using save-image.
ARM and RISC-V assemblers
You can run uLisp on either the ARM or RISC-V core of the RP2350, and it's therefore possible to run either ARM or RISC-V machine code using the defcode function built in to uLisp.
There are both ARM and RISC-V assemblers that you can use to generate machine code from assembler programs; these are written in Lisp to make it easy to extend them or add new instructions. For more information see ARM assembler overview or RISC-V assembler overview.
Installing uLisp from the Arduino IDE
Install the Raspberry Pi RP2040/RP2350 core
- Add the following URL to the Additional Boards Manager URLs list in the Arduino IDE Preferences dialog box:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
- In the Arduino IDE search for the Raspberry Pi Pico/RP2040/RP2350 core in Boards Manager and install it.
To use the RISC-V core you need version 4.1.0 or later. I used 4.2.0.
- Select Raspberry Pi RP2040 from the Board menu, and Pimoroni PicoPlus2 or Pimoroni Tiny2350 from the submenu.
- With the Pimoroni Plus 2 set Flash Size to the option 16MB (Sketch: 8MB, FS: 8MB).
- With the Pimoroni Tiny 2350 set Flash Size to the option 4MB (Sketch: 3MB, FS: 1MB).
These options allocate enough space for use by LittleFS to save the entire workspace with save-image.
- Set CPU Architecture to ARM or RISC-V to choose which core you want to use.
You can leave all the other options at their defaults.
Use PSRAM
On the Pimoroni Pico Plus 2 you have the option of using the on-board PSRAM to give a larger uLisp workspace at the expense of slightly slower performance. To use the PSRAM:
- You need the Raspberry Pi Pico/RP2040/RP2350 core 4.2.0 or later [1].
- Uncomment the #define BOARD_HAS_PSRAM, so the first two lines of the Pimoroni Pico Plus 2 section read:
#elif defined(arduino_pimoroni_pico_plus_2) #define board_has_psram /* uncomment to use psram */
- Because garbage collections take over a second with PSRAM I also recommend commenting out the printfreespace option as follows:
// #define printfreespace
Otherwise there's a delay before the uLisp prompt is printed each time while the free space is calculated.
Upload uLisp
- Download the latest ARM version of uLisp from the Download uLisp page.
- Select the board's USB port from the Port menu
- Upload uLisp to the board.
Using uLisp
- You may need to select the board's USB port from the Port menu again.
- Select Serial Monitor from the Tools menu.
- Enter Lisp commands.
Putting the board into upload mode
If the upload fails you may need to put the board into upload mode:
- Press and hold the BOOT button.
- Press the RESET button.
- Release the BOOT button.
The upload should then continue to completion.
Error on save-image
If when you call save-image you get the error;
Error: 'save-image' problem saving to LittleFS
the most likely explanation is that you didn't set the Flash Size option to the appropriate value to reserve memory for LittleFS before uploading uLisp.
P2350-E9 Errata
A bug has been reported in the first A2 batch of RP2350 chips that means that in some cases when an input pin is being driven by a weak (high impedance) input, it may not read properly. There are workarounds for most practical applications; see the RP2350-E9 Errata for more details.
Pimoroni Pico Plus 2
The Pimoroni Pico Plus 2 is based on the Raspberry Pi RP2350 running at 150MHz. It has 16MB of flash, 520KB on-chip SRAM, and 8MB of PSRAM.
Pinout
LEDs
The The Pimoroni Pico Plus 2 has a green LED connected to the digital pin 25 which you can flash with the following program:
(defun blink (&optional x) (pinmode :led-builtin t) (digitalwrite :led-builtin 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 :led-builtin (if down (- 255 x) x)))
(setq down (not down)))))
Run it by typing:
(pulse)
Exit from either program by entering ~.
Analogue inputs
The The Pimoroni Pico Plus 2 has three analogue inputs which you can access on digital pins 26, 27, and 28. They have 12-bit precision.
Analogue outputs
You can generate an analogue output using PWM on any of the digital pins 0 to 22 and 26 to 28. By default the precision is 8 bits, but you can change it to a value from 4 to 16 bits by calling, for example:
(analogwriteresolution 16)
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:
(scale 10)
Serial
The The Pimoroni Pico Plus 2 has two serial ports: Serial1 on pin numbers 0 (TX) and 1 (RX), and Serial2 on pin numbers 8 (TX) and 9 (RX).
SPI
The The Pimoroni Pico Plus 2 has two SPI ports: SPI0 on pin numbers 32 (MISO), 35 (MOSI), 34 (SCK) and 33 (SS), and SPI1 on pin numbers 12 (MISO), 15 (MOSI), 14 (SCK) and 13 (SS).
I2C
The The Pimoroni Pico Plus 2 has two I2C ports: Wire0 on pin numbers 4 (SDA) and 5 (SCL), and Wire1 on pin numbers 6 (SDA) and 7 (SCL).
Pimoroni Tiny 2350
The Pimoroni Tiny 2350 is a small board, similar in size to Adafruit's QT Py boards and Seeed Studio's XIAO boards. It's available from several suppliers, including Pimoroni [2] and The Pi Hut [3].
The Pimoroni Tiny 2350 is based on the Raspberry Pi RP2350 running at 150MHz. It has 4MB flash and 520KB on-chip SRAM.
Pinout
LEDs
The Pimoroni Tiny 2350 has an RGB LED connected to digital pins 18 (red), 19 (green), and 20 (blue). You can flash the green LED with the following program:
(defun blink (&optional x) (pinmode :led-builtin t) (digitalwrite :led-builtin 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 :led-builtin (if down (- 255 x) x)))
(setq down (not down)))))
Run it by typing:
(pulse)
Exit from either program by entering ~.
Analogue inputs
The Pimoroni Tiny 2350 has three analogue inputs which you can access on digital pins 26, 27, and 28. They have 12-bit precision.
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, but you can change it to a value from 4 to 16 bits by calling, for example:
(analogwriteresolution 16)
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:
(scale 10)
Serial
The Pimoroni Tiny 2350 has two serial ports: Serial1 on pin numbers 0 (TX) and 1 (RX), and Serial2 on pin numbers 4 (TX) and 5 (RX).
SPI
The Pimoroni Tiny 2350 has two SPI ports: SPI0 on pin numbers 4 (MISO), 7 (MOSI), 6 (SCK) and 5 (SS), and SPI1 on pin numbers 28 (MISO), 27 (MOSI), 26 (SCK) and 29 (SS).
I2C
The Pimoroni Tiny 2350 has two I2C ports: Wire0 on pin numbers 12 (SDA) and 13 (SCL), and Wire1 on pin numbers 6 (SDA) and 7 (SCL).