Serout freezes everything
linock
Posts: 31
Me again..i know
Here's the thing that happens.
I have a little bit of code which displays a value taken from rctime.
It works fine displaying the values towards the parallel lcd but i wished also to send the values displayed on the lcd to the serial port of my computer and btw display those values to a simple terminal.
Why this example won't work ?
serial:
SEROUT 16,16484,[noparse][[/noparse]"Test"]
RETURN
whatever i try when i launch the terminal program (hyperterminal configured with 9600, N, 8, 1) everything freezes, even the LCD display. When closing the terminal program then everything restarts working as usual.
Post Edited (linock) : 2/4/2006 2:10:32 PM GMT
Here's the thing that happens.
I have a little bit of code which displays a value taken from rctime.
It works fine displaying the values towards the parallel lcd but i wished also to send the values displayed on the lcd to the serial port of my computer and btw display those values to a simple terminal.
Why this example won't work ?
serial:
SEROUT 16,16484,[noparse][[/noparse]"Test"]
RETURN
whatever i try when i launch the terminal program (hyperterminal configured with 9600, N, 8, 1) everything freezes, even the LCD display. When closing the terminal program then everything restarts working as usual.
Post Edited (linock) : 2/4/2006 2:10:32 PM GMT
Comments
Make surte that the SX-Key is not connected to your serial port
while you are trying to SEROUT from the SX to the HyperTerminal
unless you are using a different s-232 alltogether.
Of course if you do not have the SX-Key then you need
to install the resonator crystal.
Samuel
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· T1200······ CON···· 813
··· T2400······ CON···· 396
··· T4800······ CON···· 188
··· T9600······ CON···· 84
··· T19K2······ CON···· 32
··· TMidi······ CON···· 12
··· T38K4······ CON···· 6
· #CASE BS2SX, BS2P
··· T1200······ CON···· 2063
··· T2400······ CON···· 1021
··· T4800······ CON···· 500
··· T9600······ CON···· 240
··· T19K2······ CON···· 110
··· TMidi······ CON···· 60
··· T38K4······ CON···· 45
· #CASE BS2PX
··· T1200······ CON···· 3313
··· T2400······ CON···· 1646
··· T4800······ CON···· 813
··· T9600······ CON···· 396
··· T19K2······ CON···· 188
··· TMidi······ CON···· 108
··· T38K4······ CON···· 84
#ENDSELECT
SevenBit······· CON···· $2000
Inverted······· CON···· $4000
Open··········· CON···· $8000
Baud··········· CON···· T9600
What I would do in your case is define two baud parameters:
LcdBaud········ CON···· Inverted | T9600
PcBaud········· CON···· T9600
Now you can create a conditional switch to direct your program:
#DEFINE __LcdMode = 1
With this definition, your intent is to direct the output to the LCD.· By changing the value to 0 your intent is to direct the output to the PC.· And here's how you make that happen:
#IF __LcdMode #THEN
··SEROUT LcdPin, LcdBaud, [noparse][[/noparse]"Test"]
#ELSE
· SEROUT PcPin, PcBaud, [noparse][[/noparse]"Test"]
#ENDIF
The danger of embedding "magic numbers" (i.e., numeric values for pin numbers, baudmode values, etc.) is that errors are very easily introduced when attempting to change the behavior of a program.· By adopting the guidelines of The Elements of PBASIC Style you will save yourself a lot of trouble, and with Conditional Compilation techniques you can make your program flexible for a wide variety of modules/applications.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I've found some code portions in the manual and while browsing it i found that my sx2 was not correctly detected.
So i fixed the sentence directly with serout 16,245,[noparse][[/noparse]DEC result] using the code example and finally i got the result in the debug window but it doesn't seems to whish to work with hyperterm. Then i started playing with Stamp Plot and no more success with it.
Now i found what is responsible of all this. In the Stamp plot, there's a note about the effects of DTR which may affect transmissions.
When DTR is enabled, everything freezes, lcd display, serial connction, when disabling DTR, everything restarts working just as nothing happened.
So all this is due to a misconfiguration in the RS 232 plug but i don't know where i made a mistake.
PIN_________PIN
DB9_________BS2
2 __________ 1
3 __________ 2
4 __________ 3
5 __________ NC
6-7 ************ NC
so i will have a look again at the documentation about this step
Post Edited (linock) : 2/4/2006 9:46:20 PM GMT