USBMIDI on Blue Pill board...

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
Post Reply
Angr77
Posts: 11
Joined: Sat Dec 01, 2018 9:05 pm

USBMIDI on Blue Pill board...

Post by Angr77 » Sun Dec 16, 2018 11:01 pm

Hi!

First, I am quite new to this forum...but I have managed to get my blue pill board programmed over ST Link from Ardunio IDE 1.8.8. First I tried the blink example...and it working great on the Blue Pill.

But what I want to try is to see if the I can get the internal micro USB connector to run a small application that sends core midi information over the USB port. What I wanted to see if I can plug in the Blue Pill board to ipads, PC and see if the sequencer programs is able to handle Core Midi and get the info. I have tried this on a Ardunio Pro Micro...and it works great. Just plug in the Ipad or PC and it will receive the midi information sent by the Ardunio boards...

The code I have been trying is the following:

Code: Select all

#include 
#include 
MIDI_CREATE_DEFAULT_INSTANCE();
void setup() {
  MIDIUSB.begin(10);
  pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
  // play notes from F#-0 (0x1E) to F#-5 (0x5A):
    MIDIUSB.sendNoteOn(0x5A, 0x45, 0x90);   //(note, velocity, channel)  
    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(2000);
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    delay(2000);
}
But when trying to compile...the IDE just states…
Exit status 1
Error compiling for board Generic STM32F103C series.

Looking on the deatils in the logs...

Code: Select all

#error MIDIUSB can only be used with an USB MCU.
 #error "Unsupported architecture"
Do any body have any hints..? Is it my environment? Is not MIDIUSB supported? Or what…

Best Regards

Anders

203null
Posts: 8
Joined: Mon Jul 23, 2018 6:52 pm

Re: USBMIDI on Blue Pill board...

Post by 203null » Sat Dec 22, 2018 9:54 pm

That's the libary for avr arduinos, use this libary instead
https://github.com/arpruss/USBComposite_stm32f1

Angr77
Posts: 11
Joined: Sat Dec 01, 2018 9:05 pm

Re: USBMIDI on Blue Pill board...

Post by Angr77 » Mon Dec 24, 2018 4:10 pm

Great advise! Big thanks!

There was a code example describing the midi-out function in the library. I tried this and added a blink function when the midi notes was triggered.

Code: Select all

#include 
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() {
pinMode(LED_BUILTIN, OUTPUT);
    USBComposite.setProductId(0x0031);
    midi.begin();
    delay(1000);
}
void loop() {
  for (int i=0;i
Results? - My goal was to try the Blue Pill board and if the STM32duino library did support usb-midi class compliant devices) :-)



Best Regards

Anders

Post Reply