STM32 based USB to MIDI or RS-232 Interface

back to menue

USB to MIDI or RS-232 Interface with STM32 Nucleo-L476

A DIY project is described for for a USB to MIDI (or RS-232) interface based on the STM32 Nucleo-L476 module .The additional hardware is built on a Veroboard as a kind of shield (or better say "base board").

Originally this project was developed for the STM32F042 processor. An STM32F042 interface on a small PCB and another one on a Veroboard are described in parallel at this website.

The basic mode of operation is "transparent" bidirectional transfer of a byte streamthe device works as a standard MIDI interface or as an external RS-232 port. A simple combined MIDI and RS-232 port hardware is provided on the board. Differing from earlier hardware, the USART Tx output is inverted inside the STM32L476 chip and needs no external inverter. It supports standard baud rates up to 115200 Baud plus 31250 Baud(MIDI). It works reliably together with standard MIDI inputs, too (modified MIDI OUT wiring see HwDiy manual). A dual red/green LED signals presence of power and data traffic.

Supported by the provided firmware, the new hardware supports up to 9 potentiometers and 7 pushbuttons (or less potentiometers and more pushbuttons, total max.16), which can be be attached at the long brown connectors at the the board edge. Additionally the User Button of the Nucleo works as active pushbutton. Input changes trigger user programmable ASCII or MIDI messages merged over the transparent data transfer. This feature is switched ON and OFF with a DIP switch.

Nucleo Veroboard assembly photo
Assembly of the Nucleo Veroboard (top and solder side view).

The USB interface is "full speed USB2.0" grade. The device may be operated USB bus powered or with an external power supply as it is supported by the Nucleo hardware. The Nucleo module scales 5V supply internally down to 3.3V which supplies the complete board except the serial output driver. The supply current is in the order of 60-80 mA including the ST-LINK part and 30-35 mA when it is cut off. Particularly each LED of the ST-LINK part uses about 10mA! The MIDI and RS-232 driver hardware on this board is powered with 5 Volt.

Individual USB Vid/Pid, baud rates and format of input change messages are user configurable. During RS-232 operation, a special configuration mode gets activated with fast keyboard sequence '+++'. Separately for RS-232 and MIDI operation - the baud rate is configured individually. For RS-232 as well as for MIDI baud rates 9600, 19200, 38400, 57600, 115200 and 31250(=MIDI) are supported. This way, the device may work as a data bridge between MIDI and RS-232 "worlds".
The user setup can be stored nonvolatile in the microcontroller flash.

The STM32L476 processor is driven by a free running oscillator (MSI clock) which is locked with the 32kHz quartz crystal available on the Nucleo board (LSE clock) and provides very good stability.

The ST-LINK module on the Nucleo provides a serial port, too. But its baud rate is fixed at 115200 baud, so it is not useable as MIDI interface and needs a specifically compiled firmware (additionally uses USART2 for communication via ST-LINK). But for practical use, the ST-LINK part can be cut off the Nucleo board. On the Veroboard a connector is provided for an external ST-LINK (e.g. the cut part from the Nucleo).

A detailled construction manual and an operation manual is available (PDF files).


Downloads:
The subsequently downloadable material is copyrighted (c)2016-24 by Wolfgang Schemmert.
Assembly of the devices, programming and use of the software is permitted for free by everybody for any purpose ("freeware"). For commercial use, restrictions of third-party software contributors (Segger GmbH, STM) must be respected.
All information is based on best knowledge, but "as is" and without any warranty. Any responsibility is excluded. Use for dangerous, life-threatening and medical applications is forbidden.

Veroboard layout for STM32L476 Nucleo "base board"
(1:1 TIF format, view "from component side". May be etched as PCB too)

Firmware "usbmidicom-l476.hex" for the Nucleo "base board" with the ST-LINK part cut off:
User communication works via user built USB (PA11,PA12) or via RS-232 or MIDI interface (PA10=RxD, PB6=TxD)
Bugfix Nov2024: to save updated user setup into Flash, now command code is '~'.
(21 November 2024)

Firmware "usbmidicom-l476-orig.hex" for an unmodified NucleoL476:
User communication works via Nucleo USB (internally uses PA2,PA3 of Nucleo) or via RS-232 or MIDI interface (PA10=RxD, PB6=TxD)
Bugfix Nov2024: to save updated user setup into Flash, now command code is '~'.
(21 November 2024)

Source code "usbmidicom-l476v7.zip" for the Nucleo "base board"
(state 21 November 2024) This source code is provided as complete "Segger Embedded Studio" project (ZIP file, 354 kB).
Parts published by Segger GmbH are under license of Segger&|Rowley, parts published by STM are under license of STM, parts programmed by me are provided under GNU GPL3 license.


back to menue


* State of information November 2024.
* Right of technical modifications reserved. Provided 'as is' - without any warranty. Any responsibility is excluded.
* This description is for information only. No product specifications are assured in juridical sense.
* Trademarks and product names cited in this text are property of their respective owners.