UART at 31250 baud (MIDI, FullDuplexSerial)
Hi,
I have some trouble using a UART at 31250 baud (the baud rate using
by MIDI. The Data (NoteOn, NoteOff, etc.) seems to be received
correctly about 98% of the time, but something about 2% gets
discarded for some reason. I'm using the FullDuplexSerial object.
This seems only to appear when I'm using more cogs - e.g.
SIDCog (modified version), ADC objects and FullDuplexSerial.
It has worked without any problems previously.
This is some snippet to show how the data is processed:
I have some trouble using a UART at 31250 baud (the baud rate using
by MIDI. The Data (NoteOn, NoteOff, etc.) seems to be received
correctly about 98% of the time, but something about 2% gets
discarded for some reason. I'm using the FullDuplexSerial object.
This seems only to appear when I'm using more cogs - e.g.
SIDCog (modified version), ADC objects and FullDuplexSerial.
It has worked without any problems previously.
This is some snippet to show how the data is processed:
repeat note := -1 if ( b := midi.rxcheck ) <> -1 midi.tx(b) if b & $80 runningStatus := b b := midi.rx if ( runningStatus ) == $90 note := b vel := midi.rx if vel == 0 note := -1 elseif ( runningStatus ) == $80 ' Do something (CH0 note off) midi.rx ' Ignore velocity. if note <> -1 ' Do something (NoteOn)
Comments
it might be a problem wth the buffer.
The standard fullduplexserial-object (short fdx) has send and receivebuffer of 16 bytes. If 16 bytes have been received and a seventeentth byte arrives
the oldest byte gets overwritten by the newest byte.
It is possible to increase the buffersize. With the standard fdx-object you have to do this at sevral places including the PASM-code.
There are other versions of FDX that make it very easy to change the buffersize. I don't have the names handy. Maybe somebody else can chime
in and post a link or the name of this objects.
best regards
Stefan
Are you thinking about http://forums.parallax.com/showpost.php?p=883228&postcount=3 ?
BTW, is okay that your system adds a 1-byte delay to the outgoing MIDI stream? Seems like you'd want to have the MIDI THRU port done in hardware to that it passes through without delay.
It actually has a hardware MIDI thru port. The MIDI output is only used
for sequencer output etc.