Jump to content

Bitbanging MIDI?

Recommended Posts



Is midi possible with software only?

I want to make a few simple MIDI transport controllers ( An encoder and 4 or 6 buttons) and i want to keep to cost


down to minimum ( the encoder and the buttons cost 1euro and i found a suitable case for 2 euro) so i would like to

do it witch a cheap MCU like the MSP430g2201 But it does not have any serial communication peripheral.


I'm not really good in serial communications, i do understand how SPI and shift registers, i know what I2C is but i

have no idea how to implement MIDI OUT from the msp430 and there aren't any tutorials for the msp430 as far as i know.

I have looked at other midi Code on the forum but it always seemed to convoluted for me to learn from (i.e I'm too

stupid to understand) and they always used USI or USCI.


Can someone give me some examples or a tutorial on clock-less serial communication (MIDI is clock-less isn't it)?

How to set it up, so i can send midi massages, I have already figured out what messages i want to send, I just don't

know how.


Thanks for any help in advance!

Link to post
Share on other sites

Yes, it is.

I would suggest using msp430g2203 though, it is almost as cheap as 2201 and has USCI module.


When working with asynchronous communications protocol (clock-less,) the most important thing is timing.

You will need to use timer to make sure your timing is correct.

Here's how you can implement MIDI out.

1. Create ring buffer with functions to read from and write to.

2. Configure Timer to interrupt every 32us.

3. In Timer's ISR, use tx buffer and tx counter variables to keep track of what bit to send and set output pin as required. When you are done sending start bit, data byte, and then stop bit, check ring buffer for new data and if there is one, start sending another byte.

4. Your main loop (or port's ISR) will check the state of encoder and switches and add appropriate MIDI message bytes to the ring buffer.

Link to post
Share on other sites

Thanks for the replay!

I already have 10 of the MSP430g2201 so i would like to use those, and it is a good learning experience anyway.


I have a few more questions:

I have to send a single bit every 320us? (for a full byte takes 3200us)? or i have to send a full byte every 320us?

I have to send a start and a stop bit for every byte or for every instruction?

If for every byte i have to send a start and a stop bit, how do i separate instructions that made up of 3 bytes?

Is there any special requirement for midi?


sorry if my questions are stupid.

Link to post
Share on other sites

Single bit every 32us (little typo in the original post,) so the whole start bit, byte, and stop bit will take 320us.

Start and stop for every byte, so you check buffer if there is new data, if there is, pull pin low (start bit.) Next cycle, start sending data byte bit by bit. After all 8 bits are sent, pull pin high (stop bit.) The next interrupt, you check buffer again, and repeat cycle with start bit. If there is no new data in the buffer, keep pin high.


When you want to send 3 byte MIDI message, you just write all 3 bytes to tx buffer.

Timer's ISR will read tx buffer byte after byte and send them in order. Stop bit and start bit separate bytes and you don't have to send each byte back to back, you can have slight delay between status byte and data bytes. MIDI receiver will know how to handle that.


No special requirement for MIDI.


One more thing, 2201 comes with only one calibrated DCO frequency, 1MHz. At 1MHz, making sure your timing is correct is going to be very tricky or even impossible (interrupt every 32us with 1us clock cycle.) Your software should run at higher frequency, 16MHz for example (62ns clock cycle.) That means you should calibrate each chip to get your clock as accurate as possible.

2203 comes with 16MHz calibrated DCO frequency, plus if you use USCI, you pass your data to the module and you have 320us to do whatever and you don't have to worry about timing.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...