stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post here all questions related to LibMaple core if you can't find a relevant section!
517002650
Posts: 12
Joined: Mon Jul 10, 2023 10:37 pm

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by 517002650 »

Hello, thank you for your answer. I have deleted - DSERIAL according to your statement_ USB, restarted the PC and downloaded the code again. The development board was connected to the PC USB port but still did not respond. I tested the USB data cable and development board to see if they were working properly. I don't know if there is anything wrong with loading the MIDI driver. It's strange that stm32f103C can load MIDI drivers normally
517002650
Posts: 12
Joined: Mon Jul 10, 2023 10:37 pm

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by 517002650 »

Yes, I used this example to write the MIDI program from the beginning. Initially, I used the development version of STM32F103C and it worked properly. Now I plan to replace STM32F103RCT6, but I found that the MIDI driver cannot be loaded, and STM32F103ZET6 cannot load and recognize MIDI drivers properly






#include <USBComposite.h>

const uint8_t notes[] = {60, 62, 64, 65, 67, 69, 71, 72, 61, 63, 66, 68, 70};
const int numNotes = sizeof(notes)/sizeof(*notes);

USBMIDI midi;

void setup() {
USBComposite.setProductId(0x0031);
midi.begin();
while (!USBComposite);
}

void loop() {
for (int i=0;i<numNotes;i++) {
midi.sendNoteOn(0, notes, 127);
delay(200);
midi.sendNoteOff(0, notes, 127);
}
}
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by ag123 »

add a blink code in the MIDI sketch

Code: Select all

#include <USBComposite.h>

const uint8_t notes[] = {60, 62, 64, 65, 67, 69, 71, 72, 61, 63, 66, 68, 70};
const int numNotes = sizeof(notes)/sizeof(*notes);

uint8_t ledpin = PUT_YOUR_LED_PIN_HERE; //e.g. PAxx, or PC13 etc

void setup() {

pinMode(ledpin, OUTPUT);

USBComposite.setProductId(0x0031);
midi.begin();

// turn on the led, I'm assuming that HIGH is on
digitalWrite(ledpin, HIGH)l;
while (!USBComposite);

//turn off the LED
digitalWrite(ledpin, LOW)l;

}

void loop() {
for (int i=0;i<numNotes;i++) {
	midi.sendNoteOn(0, notes, 127);
	delay(200);
	midi.sendNoteOff(0, notes, 127);
	// blink the led
	digitalWrite(ledpin, ! digitalRead(ledpin) );
	}
}

this is so that the led should turn on before that

Code: Select all

while (!USBComposite);
if it get past this, the led goes off and it should start blinking.

if the LED is constantly on maybe it is stuck before

Code: Select all

while (!USBComposite);
, if the led blinks and nothing is seen at the USB side.
There may be a problem at the USB connector. or there is another possibility, that your system clock is running at the wrong frequency, this
has to do with the crystal on the board, the core codes expect a 8 Mhz crystal. If it is different, you would need to dig into the core codes to setup the PLL multipliers for HSE for that different frequency crystal.

If the LED did not even turn on, the sketch did not even reach after midi.begin(), it is stuck before that.

Then move that

Code: Select all

// turn on the led, I'm assuming that HIGH is on
digitalWrite(ledpin, HIGH)l;
further up until it turns on. If you get to the top, i.e. void setup() and the LED did not turn on.
your sketch did not run, something is stuck trying to initialize pheriperials or even just the cpu.

one common problem for boards that is not in prior use is the crystal frequency etc, it can get stuck and unable to start the clock (i.e. HSE)
this would require fixes for the PLL multipliers or even the board crystal circuit in worse cases.
Search for the schematic (e.g. google) for your board and post it. So that others can help to review and comment.

if you can't find the schematic take a look here to see if you can find your board
https://stm32-base.org/boards/

or even take a photo of the board (top and bottom), and maybe post it in imgur.com and link it here. Take close up especially the crystal find out what is the Mhz of the crystal, the usb connector circuit etc. There are some nasty boards where the usb connector is just use to supply power and they did not connnect even the usb pins.
Last edited by ag123 on Fri Jul 14, 2023 2:20 am, edited 1 time in total.
517002650
Posts: 12
Joined: Mon Jul 10, 2023 10:37 pm

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by 517002650 »

Unexpectedly, according to your code download, the LED light did not flash, indicating that the MIDI program is dead and unable to run. This indicates that the MIDI code driver for the STM32F103R development board is not suitable for this library code. Unfortunately
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by ag123 »

what if you add update code

Code: Select all

void setup() {

pinMode(ledpin, OUTPUT);

for(int i=0; i< 10; i++) {
	digitalWrite(ledpin, ! digitalRead(ledpin) );
	delay(100)
	}
... //the rest of the code is unchange
i.e. blink the LED 10 times when it enter setup.
if this works, then the hang / freeze / stall is after this part of code.

if it still doesn't blink, there is some problem initializing the board, it could be the clocks (crystal) HSE or something related.
e.g. that you need to select the appropriate 'upload method' e.g. st-link, because that upload method is connected to the .ld script, which needs to compile the firmware for start address 0x8000000 (start of flash).

the ld script matters, it configure where is the start address and the size of the flash memory and sram size, and many other stuff.
517002650
Posts: 12
Joined: Mon Jul 10, 2023 10:37 pm

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by 517002650 »

I have switched to a new stmM32F103R development board from a different merchant. By downloading it directly, I can recognize MIDI drivers. For some unknown reason, if the development board cannot recognize MIDI drivers and downloads other programs separately, it can run normally. If the MIDI program is downloaded, it will die. Unfortunately, the reason cannot be found.
517002650
Posts: 12
Joined: Mon Jul 10, 2023 10:37 pm

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by 517002650 »

Where can I modify the name of the MIDI driver recognition in the WINDOWS10 system by modifying the following code




#include <USBComposite.h>

const uint8_t notes[] = {60, 62, 64, 65, 67, 69, 71, 72, 61, 63, 66, 68, 70};
const int numNotes = sizeof(notes)/sizeof(*notes);

USBMIDI midi;

void setup() {
USBComposite.setProductId(0x0031);
midi.begin();
while (!USBComposite);
}

void loop() {
for (int i=0;i<numNotes;i++) {
midi.sendNoteOn(0, notes, 127);
delay(200);
midi.sendNoteOff(0, notes, 127);
}
}
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by ag123 »

I'm not familiar with MIDI and hence won't be able to help much.

But that in normal USB terms, USB devices are identified by the VID (vendor ID) and PID (product ID), and you have done that for the product ID in the code.

In addition to that, an important aspects of USB is their USB device classes.
https://www.usb.org/defined-class-codes
e.g. that if a device is USB CDC ACM (Abstract control model), then the computer think it is a modem.
These days this is simply called USB Serial, i.e. a virtual com port, and anything that falls into this particular class works like being connected to a USB uart dongle.

MIDI is likely hidden deep within HID.

For the other parts, you would likely need to review the codes to see if you can change them.
Note that not all devices is supported by the OS, e.g. Windows. Some, including HID (e.g. MIDI) may need a separate custom driver or app on the host side.

Commonly in 'arduino' land, some even didn't bother with all that and simply use a virtual com port (i.e. USB Serial)
and on the desktop side maybe use
https://processing.org/
or even
https://nodered.org/
to process the data received from the board.

HID i.e. MIDI would conform to certain HID specs so that some programs written for HID MIDI would recognize and detect them, and use them as like a MIDI keyboard. This is normally driven by the USB and HID device class.

What is quite likely with a custom board and firmware is that you can likely do things that is 'non standard', but that'd likely mean having custom software / app on the host side as well.
517002650
Posts: 12
Joined: Mon Jul 10, 2023 10:37 pm

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by 517002650 »

https://github.com/rogerclarkmelbourne/ ... midiin.ino
https://github.com/rogerclarkmelbourne/ ... /USBMIDI.h
Thank you for your answer. I would like to ask a question about MIDI input. The instance on this link. How to modify the ability to support midi input and make judgments to output other information, such as turning on an LED
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by ag123 »

the original author and repository is probably here
https://github.com/arpruss/USBComposite_stm32f1
viewtopic.php?p=11468&hilit=composite#p11468

there is a pretty old spec for MIDI here
https://www.usb.org/sites/default/files/midi10.pdf
I'm not sure if MIDI is conforming to that spec or some other implementations that has evolved over time and that is actually informal, i.e. there is no spec, but just that some (well known) companies did their MIDI in a particular way, and others reversed engineered the protocol, possibly based on HID.

there is another very large class that we casually denoted as HID - commonly used for keyboards and mouse
the page about it is here
https://www.usb.org/hid
the HID class device spec is here
https://www.usb.org/document-library/de ... on-hid-111

and highly related to HID is the usage tables is here:
https://usb.org/document-library/hid-usage-tables-14
the list of usages is *huge*, and I don't think 'standard' drivers on the desktop side support them all.
only the most common e.g. keyboard and mouse is supported, and maybe some others

I casually did some searches in the usage tables for 'MIDI' as a keyword and found nothing there.
i.e. MIDI use of HID is potentially custom and proprietary. and that some of the implementations found floating out there is potentially reversed engineered if it is done by a 3rd party and that it use HID.

for HID the starting point is to understand the HID device class specs, it is a pretty steep learning curve.
e.g. that for a keyboard (the standard computer keyboard), the report descriptors describe how the inputs and outputs are structured.
and that the inputs and outputs are linked to the *usage tables*, for specific usages e.g. computer keyboards and/or mouse, there are standard usage tables. This is so that if the device (e.g. your board) sends codes as specified and according to the usage tables. Maybe the driver in the host (e.g. Windows) would recognize it and treat it as keys presses sent from the keyboard, or button presses from the mouse etc.

Those are actually beyond what is normally in the scope of 'stm32duino'.

and that I'd just like to say that support for even 'standard' USB devices classes is not necessary always 'standard' in the OS.
i.e. that some custom drivers and/or app is likely required. E.g. Microsoft mentions what they support
https://learn.microsoft.com/en-us/windo ... sb-classes
Post Reply

Return to “General discussion”