<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Sorry, I don't have example code for you, but here is some analysis that I hope might help point you in the right direction:</p>
<p>20MHz / 31,250Hz => ~640 instructions per MIDI data bit, or 6,400 instructions per MIDI data byte.  That's quite a lot of instruction execution time between notes, so I'd be checking the efficiency/optimisation of the code.</p>
<p>How long is it taking to update the analog outputs and do other processing?  If it's updating all 8 CVs via a "slow" protocol like I2C every time it loops then that might be taking a while, and maybe you need a different approach (i.e. only update a CV output when it changes).</p>
<p>How have you implemented the FIFO?  Do you have locking to ensure the interrupt isn't writing to it while the main loop is updating it?</p>
<p>Create a debug version that has checks on the FIFO size in the interrupt, and sets an LED on if it overflows, so you can confirm for certainly whether or not that's the problem.</p>
<p>What I do (with 30+ years of programming experience) is pretend I'm the CPU, and "execute" the code in my head (or on paper if complex) in order to try to work out what unplanned or unexpected things might be happening to cause the problematic behaviour.</p>
<p>Cheers,<br />A.</p>
<div id="signature">---<br />
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"> </div>
</div>
<p><br /></p>
<p id="reply-intro">On 20-03-2020 11:14, Jean-Pierre Desrochers wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div> </div>
</blockquote>
</blockquote>
<style type="text/css">@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}

#replybody1 p.v1MsoNormal, #replybody1 li.v1MsoNormal, #replybody1 div.v1MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
#replybody1 a:link, #replybody1 span.v1MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
#replybody1 a:visited, #replybody1 span.v1MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
#replybody1 span.v1EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;
        font-weight:normal;
        font-style:normal;}
#replybody1 .v1MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
#replybody1 div.v1WordSection1
        {page:WordSection1;}</style>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div id="replybody1">
<div lang="FR-CA">
<div class="v1WordSection1">
<p class="v1MsoNormal"><span>I’m working on a new polyphonic MIDI to CV module (8 voices).</span></p>
<p class="v1MsoNormal"><span>So far I did my tests with an old PIC16F887 @ 20Mhz micro I had on hand.</span></p>
<p class="v1MsoNormal"><span>I use a USART interrupt driven c function to ‘catch’ all the incoming MIDI bytes.</span></p>
<p class="v1MsoNormal"><span>My code is pretty fast, but still, since I only read one MIDI channel (1-16) at the time <br />when I play very fast chords on an external keyboard</span></p>
<p class="v1MsoNormal"><span>all the notes are read in the incoming queue but sometimes</span></p>
<p class="v1MsoNormal"><span>I get stuck notes or unread ones..</span></p>
<p class="v1MsoNormal"><span>Same thing happens when playing MIDI files on Cakewalk SONAR <br />feeding my prototype with  a MIDI cable.<br />The interrupt function grabs each incoming byte and put them</span></p>
<p class="v1MsoNormal"><span>In a receive buffer of 32 bytes and the main () reads and treats them in a FIFO manner</span></p>
<p class="v1MsoNormal"><span>Later in the main loop.</span></p>
<p class="v1MsoNormal"><span> </span></p>
<p class="v1MsoNormal"><em><span style="font-size: 12.0pt;">-Would a 32Mhz micro do a difference in the USART interrupt reading speed ?</span></em></p>
<p class="v1MsoNormal"><em><span style="font-size: 12.0pt;">-And is 32 bytes long enough for the RxBuffer to handle a 6 voices chords ?</span></em></p>
<p class="v1MsoNormal"><em><span style="font-size: 12.0pt;">-And finaly I checked the web for a ‘decent’ C code examples</span></em></p>
<p class="v1MsoNormal"><em><span style="font-size: 12.0pt;">  for MIDI reception (MIDI Tx is much easier to implement) with no success..<br />  ‘Obscure’ Arduino libraries all around with no explainations of its inner code.</span></em></p>
<p class="v1MsoNormal"><span> </span></p>
<p class="v1MsoNormal"><span>Did anybody use good C code available ?</span></p>
<p class="v1MsoNormal"><span>JP</span></p>
<p class="v1MsoNormal"> </p>
<p class="v1MsoNormal">Synth-diy@synth-diy.org</p>
</div>
</div>
</div>
<br />
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">_______________________________________________<br />Synth-diy mailing list<br /><a href="mailto:Synth-diy@synth-diy.org">Synth-diy@synth-diy.org</a><br /><a href="http://synth-diy.org/mailman/listinfo/synth-diy" target="_blank" rel="noopener noreferrer">http://synth-diy.org/mailman/listinfo/synth-diy</a></div>
</blockquote>
</body></html>