chipKIT® Development Platform

Inspired by Arduino™

USB MIDI Host

Created Sun, 04 Mar 2012 20:24:03 +0000 by robotmad


robotmad

Sun, 04 Mar 2012 20:24:03 +0000

Having recently bought a Yamaha MIDI keyboard I was disappointed that the latest models only support MIDI via a USB connection which requires it to be connected to a PC as the USB Host. Really I want the flexibility to use the keyboard with existing, older, MIDI equipment which has a conventional 5 pin DIN MIDI connection. So I'm trying to get the Microchip USB MIDI Host code to compile for the ChipKit MAX32 (as received for the DesignSpark ChipKit Challenge), to which I have already connected a USB connector, so that it can be the MIDI USB host.

So far I've been able to update the USB code used in the Digilent USB libraries to the latest version 2.9 from Microchip which includes the MIDI host capability. I've created chipKITUSBMIDIHost.c and .h files and now I am working to construct a suitable application to test everything.


Addidis

Mon, 19 Mar 2012 00:10:43 +0000

The example in the mchpusb stack is actually what you're trying to do. You might be able to compile it for the proper chip and program the chipkit with a pickit3 in mplab and not have to port it. Then you would just need to mimic the hw for the usb jack and add a proper isolated 5pin din.


robotmad

Thu, 12 Jul 2012 23:21:15 +0000

All up and running now - so I'm going to post details of the hardware and software in stages:

Hardware: Digilent Chipkit Max32: http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32

Host USB connection - use the chipKIT Network Shield if you already have one. However, I used an Arduino Protoshield (http://uk.farnell.com/arduino/a000025/kit-arduino-proto-shield/dp/1848696) as a base on which to mount a USB host connector (http://www.sparkfun.com/products/9011) wired to +5V, GND, D+ and D- XIOH27: Port G2 = USBD+ XIOH26: Port G3 = USBD- You could also use the USB Female Type A connector from a USB extension cable. If +5V is connected directly to the USB connector please take care not to overload the +5V rail.

MIDI connection to Serial Port 1 (pins 18,19) and optionally a second interface on Serial Port 2 (pins 16 & 17) via opto isolator = there is a good set of instructions and relevant diagrams for connecting MIDI to a serial UART at http://www.midi.org/techspecs/electrispec.php

UART0 (virtual via the USB connection to the host PC) is used for diagnostics information. UART3 (pins 14 & 15) can optionally be connected to a small "TextStar" LCD (from www.cats-whisker.com) as a simple display.


robotmad

Fri, 23 Nov 2012 21:49:43 +0000

Software:

You will need to download: MPIDE v0.23available from [url]http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32[/url] Digilent libraries for using Shields with chipKIT MPIDE #DSD-0000318 available from [url]http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,942&Prod=CHIPKIT-NETWORK-SHIELD[/url] Microchip "USB Framework" version 2.9e (or newer) as part of the Microchip Application Libraries download 2012-04-03: Latest version available from [url]http://www.microchip.com/MLA[/url]

The new code I have created is available from: [url]http://ardunxt.googlecode.com/files/chipKITUSBMIDIHost.zip[/url]

1 Install the MPIDE as per the instructions. 2 Install the Digilent libraries as per instructions.
3 The Digilent libraries on my installation are installed in c:/MPIDE/hardware/pic32/libraries. They appear to be based on the Microchip USB Framework version 2.7a which did not include Host MIDI. So we need to create it: Create a new library directory "chipKITUSBMIDIHost" and add the C++ source and header files chipKITUSBMIDIHost.c and chipKITUSBMIDIHost.h to it (these are the files I have created). 4 Upgrade the Framework to the latest version (proven with 2.9e) which does include Host MIDI. To achieve this copy files from the Microchip MLA folders to the MPIDE libraries as follows: Microchip/Include/USB/. to chipKITUSBHost/USB Microchip/USB/usb_hal_local .h to chipKITUSBHost/utility Microchip/USB/usb_host.c to chipKITUSBHost/utility Microchip/USB/usb_host_local.h to chipKITUSBHost/utility Microchip/USB/usb_pic32.h to chipKITUSBHost/utility Microchip/Include/struct_queue.h to chipKITUSBHost/utility Microchip/USB/MIDI Host Driver/usb_host_midi.c to ChipKITUSBMIDIHost/utility

Now you have the capability to use USB MIDI Host on the ChipKIT.

In the next post I'll explain the actual demo application that uses this to implement a flexible, bi-directional USB to real, physical MIDI serial port interface.


robotmad

Fri, 23 Nov 2012 23:33:46 +0000

The Demonstration Application "USBMIDIHost", source for ChipKIT Max32 MPIDE available from [url]http://ardunxt.googlecode.com/files/USBMIDIHost.zip[/url] and attached (hopefully).

THis provides an interface between a MIDI device, connected to the USB Host port of the ChipKIT board and real MIDI "serial" ports implemented using the UARTs on the CHiupKIT.

MIDI over USB contains virtual cable numbers - values 0 and 1 are mapped to the two physical cables supported by the UARTs 1 and 2. (A third could be added using UART3 if desired.)

NB if you get a compilation error it is probably due to an error in the "usb_host_midi.h" file from the Microchip USB Framework - there is an extra bracked in a #define statement.