Saturday, November 10, 2012

Ask google

For a while now I've been working on the MPG-200 (Midi enabled PG-200). One of the challenges is that while midi is 8 bit serial, the PG-200 runs 9 bit. Because of this, I've been trying to use a normal output pin for transmitting data to the JX-3P, while reading midi using the built-in UART on the microcontroller (PIC 18F series).

Aside from some rather ugly code, I've had some trouble getting the "bit banging" to work fast enough - I tried to send one bit at the time through an interrupt routine, but even with almost no code in the interrupt handler, the minimum delay between invocations was higher than I needed to achieve 31.25kHz transmission.

I did successfully implement a method where data was sent in one go, with NOP instructions in between bits for timing, but that takes a full 1/4000 of a second for each byte, in which time the microcontroller cannot do anything else.

So, to try to figure out how everybody else do their bit banging (...), I asked Google. The first post I found was this: http://www.embedded.com/design/embedded/4006445/Tricks-with-PICs. Here, I discovered something cool. The PIC family can actually transmit 9 bit while still receiving 8 bit! All my problems suddenly vanished :-D

The moral of the story is: Ask google, there's always someone who has done what you want to do before you :-)

No comments:

Post a Comment