2020/09/24 08:41:45
Hello there,
I'm trying to connect a MIDI Keyboard to a PIC24FJ64GB002.
I've successfully managed to compile and run the example in the MLA that allows to connect a Computer Keyboard.
I've been trying to understand how to connect the USB Keyboard now. I've noticed that there is a "driver" for it under framework/usb. I can see a file usb_host_midi.c but that file requires a usb_host_midi.h that is missing from the installation.
Do you have any idea why is missing? Are you aware of any example of USB Host MIDI?
2020/11/17 11:15:05
Hi Soulnafein!
Are you still struggling with this problem?
This is what you are looking for: https://github.com/MicrochipTech/mla_usb . Take a look at the the inc/ directory.
Well, I'm actually trying to do the exact same thing as you, which is getting midi info from a midi keyboard (mine is an akai mpk mini mk2) and output a gate from the PIC, to trigger anything that needs gate (like an envelope for a synth).
I've been searching for a long time example of how to use that code to make a ush midi host that actually works but there's no way I can find an existing example.
I'm new to microcontroller programming so this task is actually a huge challenge to me. What about sharing our progress in this journey?
My roadmap to reach the goal "Parsing midi data from usb midi keyboard" is the following:
1. [OK] Blink LEDs with a PIC
2. [WIP] Connecting an HID mouse to the PIC and blink an LED when pressing the left button.
3. [NOK] Connecting a midi keyboard to the PIC and blink an LED when pressing a pad of the keyboard.
I'm trying to understand if there's some kind of midi parser within the usb_host_midi.c file but no result yet.
Cheers and hope you've not abandoned this project. If the two of us work on it, we could get this thing done.
2020/11/26 10:11:33
Hello there. I've managed to make my project work.  You can find the code here: https://github.com/soulnafein/midi-to-cv
I'm not a PIC expert, nor an electronics expert, nor a C expert, so use it at your own risk.
I'm in the process of adding a schematic to the repository but you should be able to understand what's going on easily.
Most of the application specific usb code is in the keyboard module.
I'm using an external 16mhz crystal with 18pF capacitors.
I've followed this schematic to setup the USB related circuits: https://www.hobbytronics.co.uk/datasheets/usb-host-v2-basic-IC.pdf
In my program you'll find some example of how to read a note from a  midi keyboard, and how to light up an LED when a key is pressed.
2020/11/27 00:22:21
Hey Soulnafein!

Glad to hear you got it working. Good job! And thanks a lot for sharing your contribution.
On my side, my midi keyboard is enumerated by the PIC and the PIC detects when the keyboard is attached or detached (not that amazing but still a step forward).
I'm struggling with sending request from the host to the IN endpoint to read midi data. The endpoint is busy untill I detach the keyboard from the PIC, which is not very interesting.
Here below is my piece app tasks method which is called in the main function. If someone sees a mistake, I'll take any advice.

void APP_HostMIDIKeyboardTasks()
    if (midi_keyboard.device == NULL)
        midi_keyboard.device = USBHostMIDIDeviceDetect();
            if (midi_keyboard.device != NULL)
                midi_keyboard.state = DEVICE_CONNECTED;
                TIMER_RequestTick(&APP_HostTimerHandler, 10);
        case DEVICE_CONNECTED:

        case GET_INPUT_REPORT:
            if (USBHostMIDIRead(midi_keyboard.device,
                // Host may be busy/error -- keep trying
                // USB_SUCCESS received, waiting for TRANSFER_DONE
                midi_keyboard.state = INPUT_REPORT_PENDING;

            if(!USBHostMIDITransferIsBusy(midi_keyboard.device, MIDI_KEYBOARD_ENDPOINT_IN))
                midi_keyboard.state = DEVICE_CONNECTED;

        case ERROR_REPORTED:



I'll take a look at your code to see what you've done for that.
© 2021 APG vNext Commercial Version 4.5

Use My Existing Forum Account