combne serout commands
guydb
Posts: 29
hi,
I'm having a weird problem:
I want to send MIDI out (using pin 14) and send strings to a serial LCD display (using pin 7). both operations use SEROUT.
Now comes the weird thing (at least to me): separately everything works (I can send MIDI or send strings to the LCD display), but as soon as I combine both things in one program the LCD goes blank once the first MIDI command is being sent, and it stays blank, whatever I send to it, while MIDI continues to function???
any suggestions about what goes wrong?
thanks,µGuy
I'm having a weird problem:
I want to send MIDI out (using pin 14) and send strings to a serial LCD display (using pin 7). both operations use SEROUT.
Now comes the weird thing (at least to me): separately everything works (I can send MIDI or send strings to the LCD display), but as soon as I combine both things in one program the LCD goes blank once the first MIDI command is being sent, and it stays blank, whatever I send to it, while MIDI continues to function???
any suggestions about what goes wrong?
thanks,µGuy
Comments
here is the simple test version (the actual thing is way too long, while this reproduces the problem:
' {$STAMP BS2sx}
z VAR Byte
x VAR Byte
N9600 CON $40F0
j CON 254
CLR CON 1
LINE2 CON 192
L1_C7 CON 135
FOR x = 1 TO 127
z=z+1
SEROUT 7, n9600, [noparse][[/noparse]j,CLR]
SEROUT 7, n9600, [noparse][[/noparse]j,CLR]
PAUSE 10
SEROUT 7, n9600, [noparse][[/noparse]"last number"]
SEROUT 7, n9600, [noparse][[/noparse]j,LINE2]
SEROUT 7, n9600, [noparse][[/noparse]DEC z]
SEROUT 15,60,[noparse][[/noparse]177,23,z]
PAUSE 1000
NEXT
END
run it like this and nothing will show up on the screen, remove the SEROUT 15 line and the LCD will nicely display figures from 1 to 127
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
You might consider using our template as a starting place and following our "Elements of PBASIC Style" guidelines.· One of my big no-no's is using "magic numbers" (embedded numeric values) in code (except for with PAUSE which is unambiguous).· I've taken your program and applied it to our template; give this a try and see if it clears the air.· Note that I've used a bit of a trick with the LCD -- I've inserted a 3 millisecond delay (pacing) between every byte; this will not be noticed by humans and eliminate the need to put PAUSE instructions after the LCD commands that require a bit of a delay before the next character arrives.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I just did copy paste...I don't have twice the same pin number in the program.
I tried with your example and it's just the same problem: nothing shows on the LCD display unless I disable the serout line for the MIDI output...it is very puzzling, especially as both commands work separately...
just had an idea: I ran the program but disconnected the midi output cable...and now the display works, while sending (tho
It may be a grounding problem. Is there a solid ground between the MIDI device and the Stamp, either through the serial cable, or elsewhere? If not, you may need to supply one.
Regards,
Bruce Bates
thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I guess I'll work with it like this (need it tomorrow) and will do some thinking and make a new board from scratch when I'm back...it might be an electrical problem (nothing else makes sense)...
thanks,
guy
DEBUG DEC3 midiCmd, " ", DEC3 midiDat1, " ", DEC3 midiDat2, CR
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax