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 */

Hi,
sorry for the delay, I was off for some days.
How can I make this board declared with USBDEVICE? is this something to be done on MBED side or on my side (desktop version) ?
thanks,

you can add

"target.device_has_add": ["USBDEVICE"]

to target_overrides inyour mbed_app.json.
I’m curious if it works, I still could not get USB working on the H743.

I restarted from scratch with an empty mBED OS6 program.
here is what I have now in my ‘mbed_app.json’.

{
    "config": {
        "usb_speed": {
            "help": "USE_USB_OTG_FS or USE_USB_OTG_HS or USE_USB_HS_IN_FS",
            "value": "USE_USB_OTG_FS"
        }
    },
    "target_overrides": {
        "*":{
            "target.device_has_add": ["USBDEVICE"]
        }
    }
}

the USB device now pops up as ‘not recognized’ by Windows 10, which is definitely a progress.

i had similar issue when using STM32Cube and I was able to overcome this by using PLL instead of HSE timings. maybe this is something to look at, but for the moment i don’t know how to do this in mBED as in Cube it’s point & click.

thats were I’m also stuck, I tried many many things and opened an issue alredy. I tried also HSI48, this doesn’t work at all. Only PLL3Q as clock source gives some result.
The clock configuration has no options for the USB source yet. There is a very new merged PR with some changes in the clock settings.
I have only the older H743ZI board, but this is no longer supported in the current Mbed6 and I have tried with some modified settings, but USB does not work.
Hope @jeromecoutant will have some time to check this issue.

ok, then i’m afraid I have to wait. if tests are needed, feel free to ask, I’ll do it with pleasure.

Hi
Note that discussion is now followed with: