cancel
Showing results for 
Search instead for 
Did you mean: 

Hello ! I want to use a MIDI interface with my stm32 board. I found some codes but so complex that I failed to extract what I wanted. Does anyone know how to do a simple MIDI communication ?

GMich.2
Associate II

I have two boards, STM32F303K8 and STM32F411RE, and I'm using the HAL librairie with CubeIDE 1.3.1. I don't know if these information are useful but we never know...

If my question lacks information, do not hesitate to ask me what is missing in my question.

Thanks in advance.

5 REPLIES 5
gregstm
Senior III

Midi is pretty easy - set up a uart with 31.25Kbaud (eg. 1MHz divided by 32, or 4MHz/128), 8 data bits. Depending on what voltage your system is using, you only need a few resistors. eg. at 3.3V you only need a 33 and 10 ohm resistors (download the updated midi electrical specs from the midi org). The receiver in midi includes a 220 ohm resistor in series with an optocoupler and was originally designed for 5volts, so you have to adjust the resistors if your board uses lower voltages. You only need to connect two wires to a midi connector for transmit. I have had it working with our synth, but I was only interested in transmitting to the synth, not receiving - I didn't progress beyond a simple note-on note-off test program.

GMich.2
Associate II

Okey, so if I understand well, I need a midi connector, like a SDS-50J for example, if I want to make the communication with your method ? And thanks to that, the connection between the board with the midi connector and the computer will be easy...

Okey, so if I understand well, I need a midi connector, like a SDS-50J for example, if I want to make the communication with your method ? And thanks to that, the connection between the board with the midi connector and the computer will be easy...

(I didn't click on the "reply" button first, so maybe you will have the same 2 answers)

gregstm
Senior III

Just had a look at my test hardware. Since I was running off a 3volt battery, I just connected pin 4 of the midi connector to 3V, and pin 5 to the UART Tx pin (but better if you use a minimum of 3.3V and use the resistors and surface mount ferrite beads suggested by the updated Midi org electrical standards - I used no resistors at 3Volts to ensure that I got the minimum 5milliAmp through the receiver's 220ohmresistor+optocoupler )

MIDI is intended to transmit as a current loop rather than voltage levels. Have a look at this page for help on the hardware:

 https://learn.sparkfun.com/tutorials/midi-tutorial/hardware--electronic-implementation