Seeed Studio XIAO nRF52840

The Seeed Studio XIAO nRF52840 [1] and XIAO nRF52840 Sense [2] are each based on the Nordic Semiconductor nRF52840 ARM Cortex-M4 microcontroller running at 64 MHz, and with 1 Mbyte of flash program memory and 256 Kbytes of RAM. They also include 2 Mbytes of DataFlash that uLisp uses to allow you to save and reload the Lisp image. They also include an RGB LED, and a BQ25101 battery charge management chip. There's a tiny reset button to the left of the USB-C connector

XIAOnRF52840.jpgXIAOnRF52840Sense.jpg

The Sense version (above right) also includes two additional on-board sensors:

  • An MSM261D3526H1CPM digital microphone which interfaces with the Pulse Density Modulation (PDM) module on the nRF52840 chip. It can receive audio data in real-time which allows it can be used for audio recognition.
  • An LSM6DS3TR-C [3] 6-axis Inertial Measurement Unit (IMU).

Install the ARM version of uLisp for use with these boards.

Installing uLisp from the Arduino IDE

Install the Raspberry Pi Pico/RP2040 core

  • Add the following URL to the Additional Boards Manager URLs list in the Arduino IDE Preferences dialog box:
https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json
  • In the Arduino IDE search for the Seeed nRF52 Boards core in Boards Manager and install it.

I tested the boards with core version 1.1.1.

  • Select Seeed nRF52 Boards from the Board menu, and the appropriate board from the submenu.

You can leave all the other options at their defaults.

Upload uLisp

  • Download the latest ARM version of uLisp from the Download uLisp page.
  • Upload uLisp to the board.

You should then be able to select the USB port from the Port menu, select Serial Monitor from the Tools menu, and enter Lisp commands.

Pin connections

XIAOnRF52840Pins.gif

Digital inputs and outputs

The XIAO nRF52840 boards provide 11 digital inputs/outputs, on pin numbers 0 to 10.

RGB LED

The XIAO nRF52840 boards have an RGB LED on pins 11 (red), 13 (green), and 12 (blue). You can access the red LED with the keyword :led-builtin. For example, you can flash it 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)

Exit from the program by entering ~.

These pins can also be used as analogue output pins, so you can pulsate the green LED slowly on and off with the program:

(defun pulse ()
  (let (down)
    (loop
     (dotimes (x 256) 
       (delay 5) 
       (analogwrite 13 (if down (- 255 x) x)))
     (setq down (not down)))))

Run it by typing:

(pulse)

Exit from either program by entering ~.

Analogue inputs

There are six analogue inputs on pin 0 to 5.

Serial

The XIAO nRF52840 boards have one accessible serial port: Serial1 on pin numbers 20 (TX) and 5 (RX).

SPI

The XIAO nRF52840 boards have one accessible SPI port on pin numbers 9 (MISO), 10 (MOSI), and 8 (SCK).

I2C

The XIAO nRF52840 boards have two I2C ports: port 0 on pin numbers 4 (SDA) and 5 (SCL), and port 1 on pin numbers 17 (SDA) and 16 (SCL) which are used for the on-board sensors. In addition, the LM6DS3 uses pin 15 for power and pin 18 for interrupts.

PDM

There is a PDM (Pulse Density Modulation) interface on pins 19 (PWR), 20 (CLK), and 21 (DIN).


  1. ^ XIAO nRF52840 on Seeed Studio.
  2. ^ XIAO nRF52840 Sense on Seeed Studio.
  3. ^ LSM6DS3TR-C Datasheet on Seeed Studio.