Hi! I'm an undergraduate Computer Engineering student at Penn State, and I'm working on designing a MIDI Out controller for a final project. I am doing low-level programming in C using a PIC 18F2520 microcontroller and a simple MIDI Out circuit to send MIDI data to my laptop via a MIDI to USB cable. I would like the to send a MIDI message from the PIC to Max MSP and display the message with their "notein" block (this part is already set up and working- I've tested it with my MIDI keyboard). My issue is that I'm having a hard time getting the correct values to show up in Max MSP. I know I'm getting signal because there is an LED indicator light on my MIDI to USB cable, and it lights up when I run my code. I also get values of 255, 128, and 0 to print in Max MSP, though I'm not trying to send those values. I think my problem is that I'm not sending the data correctly. If, say, I want to send a note on message such as 9A, 45, 45, do I send 9A to the send register (TXREG in my case), poll the TXREG until empty (indicated by TXIF flag bit, see attached code), send 45, poll the TXREG until empty, and send 45, poll the TXREG register until empty? Or do I need to send a start and stop bit as well?
I've attached a picture of my circuit and code for your reference. The circuit is fine, and I've set up the registers/baud rate/clock to send MIDI data serially based on the PIC data sheet and MIDI specs (20MHz clock with a baud rate of 31250bps). I'm not worried about syntax or anything related to the specs of the microcontroller, I'm just inquiring about how to appropriately send MIDI data with serial communication. The IDE I'm using is MPLAB. Any and all help is appreciated, I'm trying to learn as much as I can about serial communication and MIDI! Thanks in advance!