http://www.ulisp.com/show?3KN3 * Home * Reference * Forum Logo uLisp [ ] [Search] Getting started * Lisp for microcontrollers * Performance * Using uLisp * Using uLisp from a terminal * Debugging in uLisp * Using the program editor * SD card interface * I2C and SPI serial interfaces * Lisp Library * Download uLisp * uLisp Sensor Library * Forum Self-contained Lisp computers * Tiny Lisp Computer * Lisp Badge * Pocket Op Amp Lab 8/16-bit platforms * Arduino Uno * Arduino Mega 2560 * ATmega1284 * ATmega4809 boards * AVR DA and DB series boards 32/64-bit platforms * Arduino Zero * Arduino MKRZero * Adafruit M0 boards * Adafruit QT-Py and Seeduino XIAO * Adafruit M4 boards * Adafruit PyGamer and PyBadge * Adafruit nRF52840 boards * Raspberry Pi Pico * BBC Micro:bit * Calliope mini * ESP32 boards * ESP8266 boards * Maxim MAX32620FTHR * Sipeed MAiX RISC-V boards * Teensy 4.0 and 4.1 Simple examples * Blinking primes * Tweetmaze * Mood light * LED 8x8 dot-matrix display * Simon game * I2C clock * Data logging * Ringing the changes * Driving DotStar RGB LEDs * LCD character display * DDS signal generator * Temperature sensor * Simple data plotter * Thermocouple interface * Benchmarks Games * Animals * Eliza chatbot * Simple arcade game * Bulls & Cows game * Mini text adventure game Larger examples * Route finder * Calculating with fractions * Infinite precision arithmetic * Scrolling text display * Dot-matrix clock * Graphics display interface in Lisp * Plotting to a colour TFT display * Ray tracing with uLisp * GPS mapping application * Query language * uLisp GSM server * A LoRaWAN node using uLisp * Solving resistor networks * Fast Fourier Transform * Sudoku solver * Prime number spiral * Wi-Fi examples * Automatic uLisp to C converter * Simple object system Assemblers * AVR assembler overview * AVR assembler examples * AVR NeoPixel driver using assembler * ARM assembler overview * ARM assembler instructions * ARM assembler examples * ARM NeoPixel driver using assembler * RISC-V assembler overview * RISC-V assembler instructions * RISC-V assembler examples * Mandelbrot set using assembler * Returning a floating-point result Tutorials * Getting started * Lists * Expressions * Defining functions * Variables * Strings * Testing a result * Manipulating lists * Processing items in a list * Recursion * Returning functions * Lisp for C programmers * Thinking in a Lispy way Reference * Language reference * Floating-point extensions * Graphics extensions * Wi-Fi extensions * Programming AVR registers New! * Programming ARM registers New! * Error messages * Adding useful functions to uLisp Implementation * Implementation * Objects * Symbols * Built-in symbols * Strings * Arrays * Read, Evaluate, Print * Garbage collection * Tail-call optimization * Saving and loading images * Assembler and defcode * Debugging uLisp * Adding your own functions * Converting between C and uLisp * Porting uLisp to a new platform * uLisp Builder * uLisp Zero Other information * About me * Contact * Legal stuff RSS Feed uLisp news! Raspberry Pi Pico 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. Saving 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. Raspberry Pi Pico The Raspberry Pi Pico ^[1] is about the same size as Adafruit's feather boards: RaspberryPiPico.jpg 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: Pico-Pinout.gif 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: (scale 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: FeatherRP2040.jpg There's currently no Arduino core for the Feather RP2040, but you can use the board with the Arduino Mbed OS RP2040 Boards core. --------------------------------------------------------------------- 1. ^ Adafruit ItsyBitsy M0 Express on Adafruit. --------------------------------------------------------------------- Previous: Adafruit nRF52840 boards Next: BBC Micro:bit Copyright 2022