STM32 boards

The STM32 is a series of ARM processors from the French-Italian semiconductor manufacturer STMicroelectronics.

uLisp supports the popular Maple Mini and Blue Pill STM32-based boards which are widely available at low cost on sites such as eBay, AliExpress, and Banggood. The STM32 version supports 32-bit floating-point and integer arithmetic, and it allows the Lisp workspace to be saved to the STM32's non-volatile flash memory.

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

Arduino cores

A source of potential confusion, not helped by confusing and inconsistent naming of the cores, is that there are two Arduino cores for the STM32:

Roger Clark's Arduino STM32 core

This core is a development of the original LeafLabs core for the Maple Mini. It is now maintained by Roger Clark and is called STM32F1 Boards (STM32duino.com) in the Boards menu.

It's installed by dragging the download into your Arduino hardware folder, and is available from GitHub here:

https://github.com/rogerclarkmelbourne/Arduino_STM32

If you want to use the Maple Mini via the USB port, using an on-board bootloader, you must use Roger Clark's core, as the STMicroelectronics core doesn't support this. I also recommend this core for the Blue Pill board.

STM32 Cores by STMicroelectronics

This is the "official" Arduino core from STMicroelectronics for their Nucleo and Discovery boards. It is called STM32 Boards (selected from submenu) in the Boards menu.

It's installed via the Arduino Boards Manager and is available from GitHub here:

https://github.com/stm32duino/Arduino_Core_STM32

Maple Mini

The Maple Mini was a board based on the STM32F103 ARM Cortex-M3 processor made by LeafLabs and released in 2011. The original Maple Mini is no longer available, but clones with identical functionality are now widely available at budget price [1]:

MapleMini.jpg

It features an STM32F103CBT6 running at 72 MHz, 128 Kbytes of flash, and 20 Kbytes of RAM. It provides 34 I/O lines including nine 12-bit analogue inputs and 12 16-bit PWM analogue outputs.

The board comes with the original Maple bootloader which allows you to program the board via the USB interface. To do this requires Roger Clark's core.

Programming the Maple Mini

Using Roger Clark's core, from the Arduino IDE Board submenu select:

Board: “Maple Mini”
Optimize: "Smallest (default)"
Bootloader version: "Original (17k RAM, 108k Flash)"
CPU Speed(MHz): "72Mhz (Normal)"
Port: The port corresponding to your FTDI board.

Press the but=32 button before uploading, and press the reset button after uploading.

LED

The Maple Mini has a blue LED connected to PB1 (Arduino pin 33) which you can flash with the following program:

(defun blink (x)
  (pinmode 33 t)
  (digitalwrite 33 x)
  (delay 1000)
  (blink (not x)))

Run it by typing:

(blink t)

Exit by entering ~.

Button

There's a button labelled but=32 connected to Arduino pin 32. You can read it with the following program:

(defun button ()
  (loop
   (print (digitalread 32))
   (delay 1000)))

Blue Pill

Blue Pill is the nickname given by the STM32 community to a popular, low-cost STM32F103 ARM Cortex-M3 board that's widely available:

BluePill.jpg 

It's based on an STM32F103CB and has a similar specification to the Maple Mini: 72 MHz, 128 Kbytes of flash, and 20 Kbytes of RAM.

Note that there's also a version with 64 Kbytes of flash, based on a STM32F103C8; uLisp won't fit on this.

The board does not include a bootloader and there is no USB to serial chip on the PCB. You can program the board using an external USB to Serial interface, using either Roger Clark's core, or the ST Microelectronics Arduino core.

Programming the Blue Pill

You will need an FTDI USB-to-serial interface to connect between your PC and the Blue Pill board. Then make the following connections:

  • Connect Tx from the FTDI board to RX1 (A10) on the Blue Pill.
  • Connect Rx from the FTDI board to TX1 (A9) on the Blue Pill.
  • Connect GND between the FTDI board and Blue Pill.
  • If your FTDI supplies 5V connect it to the 5V pin of the Blue Pill board. If it’s 3.3V connect to the pin marked 3.3.
  • Connect the FTDI board USB input to your PC via a suitable USB cable.

Note that the RX1 and TX1 lines are 5V safe. This is not true of all I/O pins.

If you're using Roger Clark's core, from the Arduino IDE Board submenu select:

Board: “Generic STM32F103C series”
Optimize: "Smallest (default)"
Upload method: “Serial”
Variant: "STM32F103CB (20k RAM. 128k Flash)"
CPU Speed(MHz): "72Mhz (Normal)"
Port: The port corresponding to your FTDI board.

If you're using the STMicroelectronics core, from the Arduino IDE Board submenu select:

Board: “Generic STM32F103 series”
Board part number: “BluePill F103C8”
Serial interface: “Enabled with generic serial”
Optimize: "Smallest (-Os default)"
C Runtime Library: "Newlib Nano (default)"
Upload method: “Serial”
Flash Memory Size: “128k”
Port: The port corresponding to your FTDI board.

In either case, each time you want to upload:

  • Connect the Boot0 jumper (the one nearest the edge of the Blue Pill board) to 1 (leave the Boot1 jumper connected to 0).
  • Press the Blue Pill Reset button.

You should now be able to upload uLisp.

Connect the Boot0 jumper back to 0 once you’ve installed uLisp.

Arduino pins

The following table gives the relationship between the board pin markings, and the Arduino pin numbers assigned by Roger Clark's core that you need to use in functions such as digitalwrite, digitalread, analogwrite, analogread, and pinmode:

Arduino 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Pin PA0 PA1 PA2 PA3 PA4 PA5 PA6 PA7 PA8 PA9 PA10 PA11 PA12 PA13 PA14 PA15
Arduino 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Pin PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 PB8 PB9 PB10 PB11 PB12 PB13 PB14 PB15
Arduino 32 33 34                          
Pin PC13 PC14 PC15                          

LED

The Blue Pill has a green LED connected to PC13. On Roger Clark's core this is Arduino pin 32. You can flash it with the following program:

(defun blink (x)
  (pinmode 32 t)
  (digitalwrite 32 x)
  (delay 1000)
  (blink (not x)))

On the STMicroelectronics core this is Arduino pin 17 so change the two occurrences of 32 to 17 for that core.

Run it by typing:

(blink t)

Exit by entering ~.


  1. ^ STM32F103CBT6 Maple Mini on AliExpress