Shop OBEX P1 Docs P2 Docs Learn Events
Problem with SERIN command — Parallax Forums

Problem with SERIN command

charlercharler Posts: 8
edited 2006-08-20 11:09 in BASIC Stamp
First· I use Basic Stamp 2SX. I connected P0 to my computer RX (pin 2 in DB9 female connector)· and P1 to my computer TX (pin 3 in DB9 female connector). And wired pin 5 in DB9 female to basic stamp GND.


after that

I writing a little program to send "Hello World" to computer (using Hyper Terminal). It's work fine.

the problem is·I want to send some character from my computer but nothing happend.

this is my code ( i wrote with led blinking)

'{$STAMP BS2sx}
'{$PORT COM1}
 
 
tmpOUTL var Byte
dummyByte var Byte
 
ch var Byte
DIRH = %11111111
OUTH = %00000001
 
baudmode con 17405
ch = "-"
 
tmpOUTL = OUTH
 
Main :
tmpOUTL = tmpOUTL << 1
if tmpOUTL = 0 THEN Refresh
BUTTON 7,1,255,250,dummyByte,1,SENDRS
SERIN 0,baudmode,1000,LED_OUT,[noparse][[/noparse]ch]
LED_OUT:
 
OUTH = tmpOUTL
goto Main
 
Refresh :
tmpOUTL = 1
GOTO LED_OUT
 
SENDRS:
OUTH = %11111111
SEROUT 1,baudmode,10,[noparse][[/noparse]"Basic Stamp Said : Hello World > ",ch,10,13]
Goto Main


I don't know how to make SERIN work. I will correct hardware or something else or not?

sorry for my bad english.





ps. I try every way·I try such as making VB and C try to sending one charactor but It's not working. The result is the same SEROUT is work but SERIN is not.

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-08-20 10:43
    charter -

    I can see at least one path through your program which may eventuate in no read (SERIN) being done by the Stamp. May I suggest that you cut the program down tothe bare essentials, and then go from there:

    DEBUG "Program Initiating"

    READ:

    Serin IPin, Baudmode, Timeout, [noparse][[/noparse]databyte]

    SEROUT OPin, Baudmode, [noparse][[/noparse]"Stamp received ", databyte]

    END

    Timeout:

    DEBUG "Timeout occurred"
    GOTO READ

    END

    Or something like that.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • charlercharler Posts: 8
    edited 2006-08-20 11:09
    Wooow It's work great.
    ummmmm My programming skill need a lot of improve.
    I use a simple code as you said.
    '{$STAMP BS2sx}
    '{$PORT COM1}
    dbyte var byte
    baudmode con 17405
    DIRH = 255
    OUTH = 1
     
    READport
    :
    SERIN 0,baudmode,2000,TimeOUT,[noparse][[/noparse]dbyte]
    SEROUT 1,baudmode,[noparse][[/noparse]"Receive ",dbyte]
     
     
    GOTO READport
    TimeOUT:
    OUTH = OUTH + 1
    GOTO Readport
    
    

    O.K. and a little help can you explain my previous code is not usable please.

    Thank you, Very much.
Sign In or Register to comment.