MIDIbox Hardware Platform, CORE_STM32 Module
After 10 years of using the PIC as microcontroller for the MIDIbox Hardware Platform, and living with all the limitations, I decided to switch to a modern 32bit controller in order to develop more powerful applications, and to give other programmers the possibility to realize their own ideas without the need for learning assembly language once performance or memory utilisation does matter.
This module is expired, as the successor MBHP_CORE_LPC17 doesn't require SMD soldering and therefore is more DIY friendly!
At 2008 while I evaluated different microcontrollers, it turned out, that STM32 by ST Microelectronics was the ideal candidate for the MBHP due to following reasons:
- 512k Flash and 64k RAM gives enough freedom for future applications
- Almost the same price as for a PIC (ca. 10..15 EUR); it doesn't cost much money to upgrade multiple MIDIboxes
- Easily available for private persons in small quantities, e.g. at Mouser and Digikey
- ARM Cortex-M3 CPU is widely supported by the GNU toolchain, accordingly source code can be compiled under Windows/Linux/MacOS w/o spending money for an expensive ARM compiler
- Much better performance - compared to PIC or ATMega, the STM32 really plays in a different league because of the higher frequency (72 MHz), higher data width (32bit), hardware multiplier and division unit, etc.
- Very useful integrated peripherals for MIDI and Synthesizer applications, such as UART, SPI, I2C, USB, CAN, Timers, ADC, DAC
- It's easy to interface external components like SD Card, I2S Audio DACs, Ethernet Controller, etc.
- STM32 is supplied at 3.3V, but 5V tolerant inputs allow to access all existing MBHP modules without additional hardware. Even for output functions no level shifters are required when pins are used in Open Drain mode with external Pull-Up to 5V
- Performance boost by using the DMA for background operations, such as scanning DIN/DOUT modules, analog inputs but also I2S transfers (Audio Output) w/o loading the CPU
- Very helpful peripheral driver library provided by STM
- Supported by a free available Realtime Operating System: FreeRTOS
- Supported by OpenOCD for flashing a virgin device and debugging via JTAG
- Fast upload of application code via USB MIDI (ca. 14..17kb/s) - thanks to the MIOS32 Bootloader no JTAG or COM programmer required for common users
- Due to improved performance, it allowed me to program MIOS32 and some first applications completely in C. This finally makes MIDIbox applications portable, e.g. it is possible to emulate a MIDIbox on a PC/Mac.
Ok, enough praises for this nice toy. Here a list of issues/imperfections I don't really like, but which have to be accepted as long as there are no better alternative solutions on the market (update: now it is)
- Chip is only available in fine pitch SMD package, which is hard to solder, especially for Newbies (therefore STM32 presoldered boards will be provided)
- Embedded flash has to be accessed with two wait cycles, which slows down the CPU whenever code isn't already available in the prefetch buffer. This can lead to different timing behaviour of a routine depending on the address the linker located the code.
- USB and CAN interface cannot be used in parallel, since they share the same memory
- no ROM based USB Bootloader, so that the MIOS32 Bootloader can only be flashed via JTAG or RS232
- Pin mapping suboptimal in some cases. E.g., the two DAC outputs overlay SPI1 pins, which are used to access a SD card. SRIO chain has to use SPI1 instead of SPI2 if I2S based DAC should be connected, or JTAG pins have to be used for I2S, which limits the debugging capabilities
- ADCs cannot be supplied at 5V, 3.3V is the limit. This decreases the signal/noise ratio. The MBHP_AINSER64 module helps to overcome this by using an external 5V ADC.
- DMA doesn't support decrement address function, so that SRIO (serial shift register input and output) streams have to be reversed by software.
- I2C peripheral has conceptional flaws which requires the usage of high priority interrupts to prevent corrupted transfers
Please note: in the year 2011 I evaluated current microcontroller solutions again and switched to LPC1769 since it offers more features for almost the same price - see also the MBHP_CORE_LPC17 page.
Following interfaces are provided by the core module:
||No. of pins
||Connection to a powersupply unit (PSU). A 7V-10V transformer, or a wall adapter could be used. At least 500 mA is recommended, especially if a backlit display is connected. AC or DC doesn't matter, since the rectifier behind J1 converts to DC anyhow. Also the polarity has not to be taken into account.
||Alternatively the core module can be supplied via USB.
In addition, this port gives you a "MIDI USB" and/or "Virtual COM" interface. Also protocols like "Mass Storage Device" to access a SD Card directly from a computer are possible, but unfortunately Windows XP and Vista don't allow to use the appr. drivers in parallel, Windows could even crash when the USB cable is connected, therefore only one protocol is activated by default.
However, parallel usage of multiple protocols works fine under MacOS and Linux when explicitely enabled in the MIOS32 configuration.
Applications can be updated via USB port, it's the fastest option.
||This jumper enables power supply via USB. Before closing the jumper, ensure that any other supply sources (e.g. at J1 or J2) are removed to avoid shorts or backcurrents to your PC!
||When used as +5V output: to supply modules which are not connected to a Jxx port which already provides a 5V output. Note that the 7805 gets very hot when it delivers currents above 500 mA. Maximum current drain is 1A!
When used as +5V input: for supplying the core from an external stabilized Power Supply Unit (PSU). The voltage regulator (IC3) doesn't need to be connected, also the rest of the voltage stabilization circuit between J1 and J2 (X1, C8, C9) can be left out. If the core module (and all connected modules to this branch) drains more than 100 mA, it's recommended to mount C8 directly to J2 (a small cable between the outer soldering pads of the left-out 7805 will do this).
||Standard 20 pin interface to JTAG Wiggler, see this page for details.
||IIC port. Interface to BankSticks or to MBHP_IIC_* modules like MBHP_IIC_MIDI.
||Analog sources (like pots) can be connected to this port (12 pots maximum). If more analog pins should be scanned, please use the MBHP_AINSER64 module! There are also some application which use this pin as digital in- or output (mostly described in README.txt file).
||SPI port TODO. J8 is the interface to the DOUT module chain, whereas J9 is the interface to the DIN module chain.
||This port provides two MIDI IOs at TTL level, interface to the LED/Thru/COM module. Can also be used to cascade multiple core modules in a MIDI chain (see MIDIbox Link). Note: It's possible to distribute the Tx (MIDI Out) signal to multiple cores, but it isn't allowed to connect more than one Tx output to a Rx input. Instead, a MIDImerger is necessary to combine multiple MIDI IN sources.
||MIDI OUT port 1 and 2. See the schematic, how to connect a MIDI socket to this port.
||MIDI IN port 1 and 2. See the schematic, how to connect a MIDI socket to this port.
||Interface to one or two LC display module(s).
Please note that the pinout is different compared to the MBHP_CORE module!
||SPI Interface to SD Card and SPI based Ethernet Interface like MBHP_ETC.
Such modules can be easily connected with a single 10-wire ribbon cable and 3 IDC connectors as shown in this picture.
Important: The resistor array R30 shouldn't be connected when a SD Card or ENC28J60 (Ethernet Chip) is used, because pads are configured in Push-Pull mode at 3.3V.
SD Card transfers could work unstable with these Pull-Up resistors!
||CAN interface at TTL level as used by MBNet.
Please note, that STM32 doesn't allow to use CAN and USB at the same time, since these peripherals share the same memory.
||Interface to application specific module extensions like the AINSER64 and AOUT module. Prepared for serial interfaces (although not driven by an integrated SPI), two chip select lines are available, additional select lines can be taken from free pins.
||Boot mode jumpers. See schematic for the 4 available options.
The application is started when these jumpers are NOT connected!
||5V/3.3V supply options for serial ports TODO
||This is the minimum number of components to get a sign of life from a preburned STM32 chip which already contains the MIOS32 bootloader:
Note that J3 socket is only required if you burn the bootloader via JTAG by yourself.
- the USB socket (to supply 5V from a USB port)
- Jumper J17 to connect USB power lines to the 5V rail
- 3.3V voltage regulator IC7
- 100nF/100uF bypass caps C12 and C13
- 10k Resistor Array R2a-d
- Status LED and 470 ohm resistor R15
|Once you plug the USB cable into the socket, the LED will flash three times with a slow PWM modulation. This is because the chip is clocked by the internal HSI oscillator at 8 MHz only.
USB transfers are not possible at this low frequency!
||Disconnect the USB cable, and add the 12 MHz crystal and the two 33 pF caps C1/C2.
Once the chip is powered again, the LED will flash much faster with a period of 1 second.
It will only flash three times, thereafter the (default test) application is started. It's up to the application how the on-board LED is used thereafter.
||Disconnect the USB cable, and add
Connect the USB cable again.
- the two 27 Ohm resistors R9 and R10
- the 1k pull-up resistor R14
After two seconds (LED stopped flashing) your OS should report a new MIDI port.
|Open MIOS Studio, enable the MIOS32 option, push the Query button as described in the Bootloader page - you should get some informations about the chip and the running application.
||Disconnect the USB cable, and add
- the 100 nF bypass caps C3, C4, C5, C6, C7, C16
- the 10 uF cap C17
- the 100k resistor R1
- 4*1k resistor array R33
- Jumper J27
|Close Jumper J27 to test the Bootloader Hold function. The application won't be started, instead the USB port will be available immediately so that you can upload code for the case that the application crashed and doesn't enable USB anymore.
The LED will flicker 7 times in this mode, and thereafter stays on. Whenever a new MIOS32 SysEx code block or query is received, the LED will flash 7 times again.
Remove the jumper to start the application.
You will never need to close J23 as long as you don't use the ROM based RS232 bootloader.
- Jumper J23 (Boot0)
- and MIDI Link port J11 to the board.
Accordingly, following advice is only relevant for the case that you neither own a preprogrammed STM32, nor a JTAG programmer: you are not able to test the MIOS32 bootloader as long as it hasn't been flashed into the chip. Now you have the minimal infrastructure to do this as described on the Experts page.
||Let's stuff the MIDI interface circuit:
- 220 Ohm Resistors R20, R21, R22, R25, R26, R27
- 1k Resistors R18, R23
- 4k7 Resistors R19, R24
- 1N4148 Diodes D2, D3
- two 8 pin IC sockets and 6N138 Optocouplers IC4, IC5
- four PCB MIDI sockets, or optionally J12/J13/J20/J21 headers to external MIDI sockets (mounted on the rear side of your MIDIbox)
||Check each MIDI In/Out port by connecting it via a common MIDI interface to your computer, opening MIOS Studio, selecting the correct MIDI interface, and using the "Query" button. If the core responds with some informative messages, the bidirectional communication is working.
||The LCD interface:
Note that the second LCD (connected to J15B) is only supported by a small number of applications - like MIDIbox SEQ V4. It won't be initialized by default!
- 16 pin socket and 74HC595 (IC2)
- BC337 Transistor T1
- 100 nF cap C14
- two 10k Trimmpots P1, P2
- 10k Resistor R12 and 1k Resistor R13
- two 2x8 DIL headers
||Serial ports consist of:
Pull-Up resistors are only required if a 5V supplied module is connected to a serial port. This is mostly the case for J8/J9, where the SRIO chain is connected by default. It's not required for a SD Card, which is supplied at 3.3V and usually connected to J16.
- 2x5 DIL headers J8/9, J16 and J19
- Pull-Up resistors arrays R30, R32 (4*1k arrays) and R31 (4*220 Ohm array) - note that they only have to be stuffed in special cases (see below)
- 3.3V/5V selection jumpers J24, J25, J26
||For J8/J9 (R31) it is recommended to use 220 Ohm resistors, especially if many DIN/DOUT modules are connected. For other ports 4*1k arrays are sufficient and recommended as long as the 5V option is used (again: leave out the array if 3.3V option is used!).
If you are planning to use the core module for different applications, you can use SIP socket strips for the 3 resistor arrays, so that you are able to remove/replace them whenever required. The 5 pins of the arrays can be extended with cutted resistor legs (yeah - here we need them again)
TODO: provide table with all the options
||Add the components for the remaining ports:
- 2x5 DIL headers for J5A/B/C
- 2 pin header J18, 1k resistor R11, 1N4148 diode for CAN
- 4 pin header J4 and two 2k2 resistors R7/R8 for IIC
||Finally add the 7805 based voltage regulation unit if the core shouldn't be supplied via USB, but by an external PSU or transformer:
Note that USB Power Jumper J17 has to be removed when the core is supplied externally!
- 2200 uF cap C8, 330 nF cap C9
- 47 uF cap C10, 100 nF cap C11
- 7805 voltage regulator IC6
- Bridge Rectifier X1
- AC or DC input J1
- 5V input or output J2
Special Guide: SMD Soldering
This part is directed to people who want to solder the STM32 chip by themself.
You shouldn't try this if you haven't soldered SMD parts before. I recommended to start with a smaller project like MBHP_USB_GM5 to gain your soldering experiences! Especially to ensure that you won't burn 10..20 EUR just because you thought that you could master this job immediately to save money.
In fact, the required equipment is more expensive than buying a board with preasoldered STM32.
Presoldered and bootstrapped chips will be available in SmashTV's shop soon!
Continue at the great surface mount soldering video at curiousinventor.com.
Special Guide: Connecting a 2x40 (or 2x20) LCD
The pinning of the 2x8 LCD connectors J15A and J15B is mirrored to simplify the cabling of common 2x40 displays (and partly due to historical reasons - it's originated from the so called "UltraPCB").
Following pictures illustrate the orientation of the IDC connectors:
A big thank-you goes to nILS for creating the layout, Bugfight and especially StrydOne and This for MIOS32 beta testing, Seppoman for providing the first STM32 presoldered prototype boards to programmers, SmashTV for providing STM32 presoldered PCBs to users, and to everybody else who gave me helpful proposals and mental support.
Last update: 2016-08-12
Copyright © 1998-2016, Thorsten Klose. All rights reserved.