Time to buy a new Scope.
The bit rate of 31,250 baud (midi) is 32us.
An entire byte would take 320us.
But the big question is, how are you interfacing with the 5ma current loop?
<br>
Time to buy a new Scope.
The bit rate of 31,250 baud (midi) is 32us.
An entire byte would take 320us.
But the big question is, how are you interfacing with the 5ma current loop?
<br>
DT
Wahoo! My TDS210 is so black and white. Those new colour plasma scopes look fun...
You're right about the byte time. Somehow I messed up that calculation.
Receiving data through a 220W series resistor, a 6N137 and a flyback diode across pins 2 & 3 for protection. 1K pullup on the output, and the signal is nice and clean.
I did some further testing yesterday. Basically sat in a tight loop around RCIF2 and twiddled a pin when something come in and/or an error occurred.
Found that everything was working perfectly. FERR and OERR were never set and every byte I received came through properly.
Then, I re-added my TMR0 interrupt routine, using DT_INTS 18. It ticks every 60 uS and does about 4 uS of PBP work before returning. The routine works well when data is transmitted fairly slowly. It crashes and I start missing bytes when lots of data is sent in a chain.
I suspect that what I hadn't considered was the overhead of 70+ 'hidden' instructions on each side of the interrupt. Even at 20 MHz, it looks like the total interrupt time is about 34 uS.
It shouldn't make a difference, since my main loop is so short. But that's all I can think of right now.
Today I'm going to try using an .asm interrupt routine and see if the extra leanness makes any difference.
A lot of times, the handlers don't use any "heavy duty" PBP commands. Often just counting, setting a flag or something similar. If it's only using 4us, this may be one of those times.
If none of the PBP system registers are used, you can just change the handlers TYPE to ASM, and leave it as PBP statements, instead of having to convert it to ASM. This eliminates that overhead, (which is pretty large).
I'd like to see the handlers to verify it though.
<br>
DT
Thanks, DT, for the suggestions.
Update: I re-spun the code entirely. Got rid of the interrupts altogether and set up everything to poll the needed register flags.
UART2 works perfectly to capture the MIDI data - all of it - and the numbers generated by Mister-E's baud rate calculator are spot-on.
My main loop is massaging UART2's data and re-transmitting at a different baud rate through EAURT1.
Thanks to all for the input. At some point I may re-visit this program and try using interrupts...
Bookmarks