Arm Mbed OS support forum

Nucleo-H743zi2 as an USBMIDI device on win10

Hello all,
I’m new to MBED, and I have a strange issue.
first some information:

  • The blinky example is working fine.
  • Drivers and firmware are up to date
  • I tried many USB cables

I make a new program using USBMIDI and when I upload the compiled code on to the board, it seems to behave normal but no USB device is popping in Windows, and therefore no MIDI device is available.

the program only refers to mbed and only contains one main.cpp as follows :

#include "mbed.h"
#include "USBMIDI.h"
USBMIDI midi;
int main() {
   while (1) {
       for(int i=48; i<83; i++) {     // send some messages!
           midi.write(MIDIMessage::NoteOn(i));
           ThisThread::sleep_for(250ms);
           midi.write(MIDIMessage::NoteOff(i));
           ThisThread::sleep_for(500ms);
       }
   }
}

Also I noticed that when flashed and restarted, the board LD1 is blinking green with a neverending sequence of 4 short, 4 long. for what it means, i found nothing anywhere about this.

if I comment lines where you find ‘midi’, so #3, #7 and #9, then the blinking sequence don’t happen at all. Maybe we can consider that something wrong is happening with the USB init and prevents the program from running further.

I tried so many things that I would have hard times to list them all.

Do you have the start of an idea where I should look at in order to solve this ?

thanks

Hi,
really no one has even a start of an idea ?
I’m lost, please help !
thanks

I just tested a simple USB audio device based on STM32Cube instead of mBED and it works, device is detected properly. Thus I guess the board itself is not broken.
what I had to do was to disbale the VBUS to make it work. i found no way to do this with mBED. I found no configuration file where i would be able to decide whether i want it on or off.

Hello,

I know that will not help you but I tested that on F767Zi and it is working, so I agree it is about settings.
Maybe @jeromecoutant can verified that, if he will have a time.

BR, Jan

Hello Jan,
thanks for your test. i’m now even more disappointed. Maybe I should look at timers, but opposite to Cube I have no idea where to look at within mBED at the moment.
BR

If you want to check the HAL you can visit the github>MbedOs> targets>STM>H7 or when you have use a desktop IDE app you will find it under same folder tree.

BR, Jan

how did you compile your test program? I’ve tried on a Chinaboard with H743VI, but I get linker errors, the
USBMIDI class is not present. The same when I compile for NUCLEO_H743ZI2 with current mbed-os master branch.
Also USBSerial gives linker errors of undefined references for constructor/destructors.
And also for the TARGET=NUCLEO_F767ZI

Edit:
trapped myself, I used a bare-metal config. When I remove this, it compiles fine.
But the NUCLEO_H743 has no USBDEVICE defined. Usually, this is necessary. Without, the clock config is not prepared for the USB hardware.

#if DEVICE_USBDEVICE
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
    PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
        return 0; // FAIL
    }

    HAL_PWREx_EnableUSBVoltageDetector();
#endif /* DEVICE_USBDEVICE */