cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746G Discovery USB MIDI

misterstarshine
Associate III
Posted on October 28, 2016 at 18:55

Hi.

Is there a library out there or an example for the STM32F7 Discovery board that deals with simple MIDI over USB? I want to be able to both receive and send note commands. I would prefer to use an IRQ routine rather than polling a register in order to detect an incoming message.

#stm32f746g-discovery-usb-midi #usbmidi-example-code
9 REPLIES 9
Christopher Pappas
Senior II
Posted on October 29, 2016 at 04:51

I wrote a USBMidi project built on Keil for the Nucleo STM32F7xx boards. It should be easily adapted to the STM32F746-discovery board. I use it to receive MIDI only, but it is simple to write code to send MIDI as well (all the subroutines are in usbh_midi.c).

misterstarshine
Associate III
Posted on October 29, 2016 at 18:32

Thanks Chris.

Seems to be a bunch of broken dependencies such as usbh_core.h but I think I can sort that out.

Christopher Pappas
Senior II
Posted on October 30, 2016 at 02:15

Yes, the include directories may be off since I stored the project in a subdirectory, but once they are set to your working directory it should compile okay. Also, you can add in any F7-Discovery BSP files as well, and modify MX-Constants to point to the proper ports on your Discovery board.

misterstarshine
Associate III
Posted on October 30, 2016 at 23:25

How do I know the corresponding port names for the F746 Discovery board?

Christopher Pappas
Senior II
Posted on October 31, 2016 at 01:30

The fastest way to get all the ports and BSP setup automatically is just to build a new project using the STM32CubeMX application. Just choose your board type, add in USB-OTG-FS, assign USB-Host-Audio to the USB interface, and then generate code. Then, as you see, I just added the USBH_Midi files and pointed all the code from USB-Audio to USB-MIDI. Unfortunately, I no longer own an F7-Discovery board, so I have nothing to test my code on now. Google ''stm32 synthesizers'' many other people have begun projects and added USBMidi,

misterstarshine
Associate III
Posted on November 01, 2016 at 16:33

Could you send all the usb related files? I've tried to get the missing ones myself but they all come in different versions. For example the file usbd_core.h is different from the usbh_core.h where the latter is supposed to mean ''host''? These files do not seem to be generated by STM32CubeMX. I did as you said and got me a mxconstants.h although the names don't seem to correspond to those in the files you supplied.

So far this challenge has proven to be the hardest so far. With that said to get the audio part to work was really tough not to mention the UART. The only project I can find that explicitly supports USB MIDI for the F746Discovery is ''fluidsynth'' but although all initialization routines are called successfully I cannot see the device listed by the ''lsusb'' command. I saw in other threads that you've struggled with this.

Christopher Pappas
Senior II
Posted on November 01, 2016 at 17:48

These files are supplied by ST as firmware for the F7 series of boards. I am currently using STM32Cube_FW_F7_V1.5.0 as my base structure for all my projects. I usually leave the directory structure intact (as ST originally created it) so that the project templates for each different compiler finds the files (i.e. - the drivers, middleware, BSP, etc.)

Did you download the firmware for F7 boards from ST? What compiler are you using to build the project?

misterstarshine
Associate III
Posted on November 01, 2016 at 18:14

Thanks Chris.

Hopefully these files will make this work for me.

I rarely use the generated code from STM32CubeMX (except system clock config) since it doesn't look the same as the firmware examples. Also it isn't coupled to the BSP libraries that I use. The BSP libraries seem to work for me while the CubeMX generated code rarely does. I've got the STM32Cube_FW_F7_V1.4.0 but maybe I should upgrade to V1.5.0

I'm using Ac6 System Workbench in Ubuntu as my development IDE.

Edit: Another important question I have is about ''host'' and ''device'' mode. I see there are different libraries for these two situations. How is your device configured? I'd like to use it as ''host'' if an OTG adapter is hooked to it and ''device'' if hooked to a pc. How can I make it autodetect this? Seems counterintuitive to hardcode the device into host or device making the OTG adapter useless?

Christopher Pappas
Senior II
Posted on November 01, 2016 at 21:48

I am using USB Host only since I am creating a

https://community.st.com/0D50X00009bMM4jSAG

. This way I can just plug any Class-compliant keyboard/controller directly to the board and play or edit parameters in real-time without needing to worry about device/product id's and external device drivers.