Serial I/O Timing problem
Pyrotom
Posts: 84
Now I know that the cogs are supposed to run pretty much independantly of each other. But recently I'm not so sure. I'm working on a MIDI application. I can run this program
and all of my MIDI bytes show up on my laptop (via the PropStick serial port) just fine. But when I add two more cogs running my prototype MIDI app like so:
something strange happens. Occasional bytes start showing up on the laptop shifted left 1 bit - what should be x80 comes in as x00, and x90 comes in as x20. This is showing up in my app as stuck notes or as the whole thing just freezing up. Any ideas on why this is happening?? The code in FastShiftOut and MidiIn are doing hub reads and writes to the channel_notes array, but are not using any locks. MidiIn is reading the same midi signal, but off a different pin - the two pins are sharing the same signal from the MIDI interface.
CON _clkmode = xtal1 + pll16x ' use external crystal * 16 _xinfreq = 5_000_000 ' 5 MHz external crystal (standard on PropStick) OBJ miditracein : "FullDuplexSerial" miditraceout : "FullDuplexSerial" PUB PipeOrgan miditracein.start(5, 4, 0, 31_250) miditraceout.start(31, 30, 0, 38_400) repeat miditraceout.tx(miditracein.rx) return
and all of my MIDI bytes show up on my laptop (via the PropStick serial port) just fine. But when I add two more cogs running my prototype MIDI app like so:
CON _clkmode = xtal1 + pll16x ' use external crystal * 16 _xinfreq = 5_000_000 ' 5 MHz external crystal (standard on PropStick) Midi_in_pin = 7 ' input pin from MIDI IN Pipes_1_data_pin = 8 ' data pin for pipe group 1 Pipes_1_clock_pin = 9 ' clock pin for pipe group 1 Pipes_1_latch_pin = 10 ' latch pin for pipe group 1 Pipes_1_size = 16 ' number of pipes in pipe group 1 VAR byte channel_notes[noparse][[/noparse]2048] OBJ shout_1 : "FastShiftOut" ' output shifter for pipe group 1 midi : "MidiIn" ' serial driver for the MIDI interface miditracein : "FullDuplexSerial" miditraceout : "FullDuplexSerial" PUB PipeOrgan midi.start(Midi_in_pin, @channel_notes) shout_1.start(Pipes_1_data_pin, Pipes_1_clock_pin, Pipes_1_latch_pin, Pipes_1_size, @channel_notes + 60) miditracein.start(5, 4, 0, 31_250) miditraceout.start(31, 30, 0, 38_400) repeat miditraceout.tx(miditracein.rx) return
something strange happens. Occasional bytes start showing up on the laptop shifted left 1 bit - what should be x80 comes in as x00, and x90 comes in as x20. This is showing up in my app as stuck notes or as the whole thing just freezing up. Any ideas on why this is happening?? The code in FastShiftOut and MidiIn are doing hub reads and writes to the channel_notes array, but are not using any locks. MidiIn is reading the same midi signal, but off a different pin - the two pins are sharing the same signal from the MIDI interface.
Comments
Charlie
try adding _stack = 250 or so to your CON section in the main application, also make sure that your COGS are not using the same pins!
James