<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Texte brut Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
span.TextebrutCar
{mso-style-name:"Texte brut Car";
mso-style-priority:99;
mso-style-link:"Texte brut";
font-family:"Calibri","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR-CA link=blue vlink=purple><div class=WordSection1><p class=MsoPlainText><span lang=FR style='mso-fareast-language:FR-CA'>Hi all,<o:p></o:p></span></p><p class=MsoPlainText><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>Happy to see this list still alive in these dark moments of COVID19..<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>Anyway I wanted to share with you the actual coding I worked on<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>on the last weeks. This is the actual MIDI Rx interrupt c code I managed<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>to tweak and this gives very good results. Fast, efficient and reliable.<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>I tested my 6 voices poly M100 <a href="http://www.arcenson.com/projects/Modular/M100_MIDI_Interface/Module_pictures/M100_MIDI_interface_assembled_front.jpg">MIDIDAC</a> module’s MIDI reception using an external sequencer (Cakewalk SONAR X3)<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>through a MIDI cable, running at a rate of around 180bpm! with a polyphonic Bach song MIDI file.<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>And this with 4 added continuously changing MIDI layers (velocities, after touch, Breath, CC)<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>The result was great ! No losses at all. All the notes clearly received with no stuck notes.<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>Please note this code IGNORES ALL THE INCOMING REAL TIME or SYSEX bytes.<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>Only MIDI voice messages commands are processed. This is what I only needed.<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>The complete MIDIDAC C code is available <a href="http://www.arcenson.com/projects/Modular/M100_MIDI_Interface/Hitech_C_code_files/MIDIDAC_MPLAB_X_code_files/">here</a>.<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>I wish I had these code lines many months ago and hope this will help new MIDI developers like me..<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>Here is my interrupt lines:<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>//////////////////////////////////<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>// ---------------------------- //<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>// interrupt service routine //<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>// ---------------------------- //<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>////////////////////////////////// <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>void interrupt tmr0_USART_isr (void) <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> {<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> unsigned char x; // intermediate byte value<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> // RS232 receive interrupt <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> if (RCIF == TRUE && RCIE == TRUE) <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> { <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> if (OERR == TRUE) // overrun, reset UART<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> { <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> CREN = FALSE; // disable UART<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> CREN = TRUE; // re-enable UART<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> } <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> else<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> { // Good Rx byte<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> x = RCREG; <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> //////////////////////////////////////////////////////<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> ///////////////// Manage Status Byte /////////////////<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> //////////////////////////////////////////////////////<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> if(x & 0x80) // Bit 7 = 1 (Status byte)<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> {<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> if((x != 0xF6) & // Not a Real Time Message neither Tune Request <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> </span></b><b><span style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>(x != 0xF8) & <o:p></o:p></span></b></p><p class=MsoPlainText><b><span style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> (x != 0xFA) & <o:p></o:p></span></b></p><p class=MsoPlainText><b><span style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> (x != 0xFB) & <o:p></o:p></span></b></p><p class=MsoPlainText><b><span style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> (x != 0xFC) & <o:p></o:p></span></b></p><p class=MsoPlainText><b><span style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> (x != 0xFE) &<o:p></o:p></span></b></p><p class=MsoPlainText><b><span style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> (x != 0xFF))<o:p></o:p></span></b></p><p class=MsoPlainText><b><span style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> </span></b><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>{<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> PendingMIDIStatusByteVal = x; // Here SYSEX Status (0xF0 & 0xF7) can also be stored as PendingMIDIStatusByteVal<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> MIDIThirdByteFlag = FALSE; // to change the last active 'current' MIDI Status. <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> } // Doing so the SYSEX trailing data bytes will be differentiated<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> // from other recognized data bytes then ignored..<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> } // Bit 7 = 1 (Status byte) <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> //////////////////////////////////////////////////////<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> ///////////////// Manage data Bytes //////////////////<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> //////////////////////////////////////////////////////<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> else // Bit 7 = 0 (data byte)<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> {<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> if(!MIDIThirdByteFlag) // MIDIThirdByteFlag = 0 ?<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> {<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> if(PendingMIDIStatusByteVal) // MIDI_Status greater than 0<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> {<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> // Checking for 0x8n, 0x9n, 0xAn, 0xBn, 0xEn channel messages <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> if ( (PendingMIDIStatusByteVal < 0xC0) || <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> ( (PendingMIDIStatusByteVal >= 0xE0) && (PendingMIDIStatusByteVal <= 0xEF)) ) // Messages that have 2 data bytes after Status<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> {<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> MIDIThirdByteFlag = TRUE; // 2 data bytes Status here<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> PendingMIDISecondByteVal = x; // Store second byte.. <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> } <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> // Checking Status byte range: 0xC0 to 0xDF (Status with only one data byte)<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> else if (PendingMIDIStatusByteVal < 0xE0) <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> { <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> PendingMIDISecondByteVal = x; // Store second byte.. No third byte <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> write_ring_buffer(PendingMIDIStatusByteVal);<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> write_ring_buffer(PendingMIDISecondByteVal);<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> PendingMIDISecondByteVal = 0; // Ready for next Status Message or trailing Running Status 2 bytes chunk..<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> } <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> else if (PendingMIDIStatusByteVal == 0xF2) // Song Position Pointer (followed by 2 data bytes..)<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> { // Here we must catch the Status, data1, data2 then throw them away<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> MIDIThirdByteFlag = TRUE; // after the third byte is received<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> PendingMIDISecondByteVal = x; <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> } <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> } <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> }<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> else // MIDIThirdByteFlag = 1.. Third byte received here<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> {<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> MIDIThirdByteFlag = FALSE; <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> PendingMIDIThirdByteVal = x; <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> write_ring_buffer(PendingMIDIStatusByteVal);<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> write_ring_buffer(PendingMIDISecondByteVal);<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> write_ring_buffer(PendingMIDIThirdByteVal); <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> PendingMIDISecondByteVal = 0; // Ready for next Status Message or trailing Running Status 2 bytes chunk.. <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> PendingMIDIThirdByteVal = 0; // And keep the PendingMIDIStatusByteVal in case it's a Runing Status not finished <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> } <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> } // Bit 7 = 0 (data byte) <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> MIDI_ACTIVITY_LED = ON; //RC0 = 0; // Set led MIDI ACTIVITY to ON<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> TMR0 = 0; // restart timer0<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> T0IE=1; // Activates overflow interrupt of TMR0 register<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> RCIF = 0; // Erase MIDI RX flag<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> } // Good Rx byte<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> <o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> }<o:p></o:p></span></b></p><p class=MsoPlainText><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></b></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>I’m sure someone in the list will see something I did not see (maybe not) so.. let me know if it’s the case.<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'> Cheers !<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-CA style='color:black'>Jean-Pierre</span><b><span lang=EN-CA style='font-size:8.0pt;font-family:"Courier New";color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'><o:p></o:p></span></b></p></div></body></html>