8 years, 7 months ago.

Getting USBMIDI to work on Nucleo F401

Hey,

I'm new to mbed and C++ (coming from arduino), sorry if I make a noob mistake here. I'm trying to send MIDI messages over USB from my Nucleo F401re to a multieffects pedal (Zoom B3). Using an arduino with USB host shield I've managed to send program changes, and I'm trying to do the same (and hopefully more) using the F401.

The problem is that when I connect the +5V USB line to PA9 the pedal gets no power. When I connect it to the 5V output on the F401 it does get power, but it won't receive any messages. Also, my mac doesn't recognise the F401 as a MIDI device.

This is the code that I tried:

Code

#include "mbed.h"
#include "USBMIDI.h"

USBMIDI midi;

int main() {             
    while (1) {    
            midi.write(MIDIMessage::ProgramChange(10,1));
            wait(1);
            midi.write(MIDIMessage::ProgramChange(11,1));
            wait(1);
    }
}

It gives the following errors, but it still compiles:

Warning: C4017W: msg may be used before being set in "main.cpp", Line: 10, Col: 11

Warning: C4017W: msg4 may be used before being set in "main.cpp", Line: 10, Col: 11

What is going wrong?

Thanks!

Question relating to:

USB device stack with Nucleo F401RE support. NOTE: the default clock config needs to be changed to in order for USB to work. device, Nucleo, USB

1 Answer

8 years, 7 months ago.

It seems to me you need a USBMIDI Host for the MIDI pedal rather than USBDevice code which you currently use. So this would not work. Maybe you can use the Arduino USB shield as a host when it has its own onboard intelligence. Otherwise you need to find USBHost code for the F401.