Timing issues with trying to do MIDI output with FullDuplexSerial
__red__
Posts: 470
When running the following program:
My Logic analyzer shows that each serial character appears to take 5 seconds to send.
I've run my other code on the same board so i don't think it's a crystal issue.
Anyone have any insight as to my simple mistake?
Thanks,
Red
'************************************************************** '* miditest * '************************************************************** CON _clkmode = xtal1 + pll16x _clkfreq = 80_000_000 MIDI_OUT_PIN = 20 'MIDI out pin MIDI_IN_PIN = 21 OPEN_DRAIN = true 'if using the standard MIDI output circuitry TX must be open drain INVERT_TX = false 'change if required BASE_OCT = 0 'can go down to -2 or up OBJ 'include 2 ViewPort objects: ser : "FullDuplexSerial" VAR long onems PUB main | n, mode mode := 0 if INVERT_TX mode |= 2 if OPEN_DRAIN mode |= 4 ser.start(MIDI_IN_PIN, MIDI_OUT_PIN, 31250, mode) waitcnt(cnt + clkfreq * 3) onems := clkfreq / 1000 repeat repeat n from 0 to 60 send_note(n, 500) waitcnt(cnt + clkfreq * 10) PRI send_note(pitch, duration) 'send NoteOn message ser.tx($90) ser.tx((BASE_OCT + 2) * 12 + pitch) ser.tx($40) 'wait for a while waitcnt(cnt + duration * onems) 'send NoteOff message ser.tx($80) ser.tx((BASE_OCT + 2) * 12 + pitch) ser.tx($40)
My Logic analyzer shows that each serial character appears to take 5 seconds to send.
I've run my other code on the same board so i don't think it's a crystal issue.
Anyone have any insight as to my simple mistake?
Thanks,
Red
Comments
80_000_000 with 16x.
I'd delete the thread but there is no delete function that I can see.
I now return you to your previous programming...
Red