Monday, March 10, 2014

Testing the MIDI I/O

Next it was time to test the MIDI I/O. I soldered the appropriate components on the PCB to get the MIDI working. Then I wrote a simple program which turned on and off the pins which would be used for MIDI output for each of the MIDI ports. I checked the outputs with an oscilloscope and everything was fine. 0-5V output signal with sharp transitions between the 0 and 1 binary states. Happy times!

Then I plugged the MIDI output to my computer's MIDI input. No signal. What?!?

Feverishly I browsed through midi specifications, my PCB design and everything in between. Eventually I noticed that the MIDI connector pin order was inverse in the Eagle library component I was using. I have no idea what has gone through the mind of that person who committed this crime against all the engineers out there. Why on earth would anyone want to create a library component, name it "MIDI connector" and then reverse the pin order?

Luckily I wouldn't have to redesign the board before I could test its MIDI capabilities. The MIDI connector's pin layout is symmetrical and it uses Through-Hole pins. This means that if I just soldered the MIDI connectors on the bottom side of the board (instead of the top as I had designed it), everything should work just fine. I spent a good 20 minutes trying to remove the MIDI connectors from the PCB. No such luck. I would have to solder a new board…

After about an hour, I finally had a new board soldered together. Quick power up and my IDE recognised the board again. I plugged the board's MIDI out to the MIDI in of my computer and hey presto, there were MIDI notes appearing on my screen!

Next evening I studied the microcontroller's data sheets some more to get the MIDI input working. It wasn't much different from the MIDI output. The NXP microcontroller's architecture has been designed so that everything works in similar fashion. Just flip a couple of extra bits here and there and suddenly you can receive MIDI data.

I was quickly becoming a fan of NXP. At this point I decided not to move forward with the STM32 any longer. The LPC4330 was doing great job.



Above is a picture of the "brain PCB" with NXP LPC4330 microcontroller and one MIDI in and MIDI out ports attached to the bottom side of the board. The grey box is the JTAG programmer.


The test program configures the main clock to use a 12 MHz crystal and uses the PLL to run the system in 204 MHz. Next it configures the main buses to use the same PLL as the main clock, just to keep things nice and tidy.

Then there's the UART I/O configuration. And finally quick and dirty MIDI input / output routines. The test doesn't use any interrupts or DMA.


No comments:

Post a Comment