Electronic – MIDI – clockless serial with TI MSP430 MCU software

midimsp430

I'm planning to make a small MIDI transport box ( an encoder plus 6 buttons) but i don't have a lot of experience in serial communications( I have used shift registers but that's all) I would like to implement it in software because the device i'm using have no serial peripheral.
I tried to look at software examples on the net , but i didn't find anything that would make everything clear. I'm planning to use a TI MSP430G2201.

Could someone help me understand how to transmit midi data? with something like pseudo code.

I know what i want to transmit, that part is clear, i understand how MIDI messages work, but i don't understand how to set up protocol for midi.

Best Answer

You say that you know how to implement a software UART and that you understand the format of MIDI messages. Your question suggests that you just want to transmit MIDI data using six buttons - perhaps to transmit control-change or program-change messages. There is no protocol as such to do this, you just need to transmit the data bytes in the correct order.

The simplest way would be to implement a bit banging UART transmitter. This would need to toggle one of the processor's IO port pins. First, the pin is driven low for 32us to represent the start bit. Next the pin is driven high or low to represent each of the 8 data bits in the byte you wish to transmit with the least-significant-bit sent first. The pin is driven to the appropriate level for 32us for each bit. Finally, the pin is driven high for at 32us to represent the stop bit. You might like to view wikipedia's article on asynchronous serial communications.

For instance, to transmit a control change message to set "Effect Control 1" (Controller number 0C) to the value 7 on channel 3, you would need to transmit 3 data bytes - 0xB3, 0x0C, 0x07 in sequence.

(Be aware that this "bit banging" technique may not be suitable if your processor is going to be doing a lot of other work simultaneously).

Of course you will also need the standard opto-isolated interface as recommended by the Midi Manufacturers' Association which also has several useful free pdfs containing message formats etc.