HSerin


Closed Thread
Results 1 to 4 of 4

Thread: HSerin

  1. #1
    Join Date
    Jan 2010
    Posts
    24

    Default HSerin

    I have a pic connected through a RS232 and the transmit seems to be working fine but I am having issues with sending the pic commands(at least its not doing what I want it to).

    Code:
    :SetTxRx                ' Set receive register to receiver enabled
    	DEFINE HSER_RCSTA	90h
    
    
    	' Set transmit register to transmitter enabled
    	DEFINE HSER_TXSTA	20h
    
    
    	' Set baud rate
    	DEFINE HSER_BAUD	2400
    
    
    	' Set SPBRG directly (normally set by HSER_BAUD)
    	DEFINE HSER_SPBRG	25
    
    
                    ' Use only if even parity desired
    	'DEFINE HSER_EVEN	1
    
    
    :SendOnline
    
    
    
    
    	HSEROUT ["I am online.", 10, 13]
    
    
    :Online
    High Porta.6
    
    
    :Listen
    HSerin [INC]
    HSerout ["You entered: ", INC, 10, 13]
    IF INC = 1 THEN Think
    IF INC = 2 THEN TURNON
    IF INC = 3 THEN TURNOFF
    GOTO Listen
    
    
    :TURNON
    HIGH Porta.7
    GOTO Listen
    
    
    :TURNOFF
    LOW Porta.7
    GOTO Listen
    When the pic powers up, I get the "I am online." message.

    When I send a 1 the pic responds properly with the "You entered: 1" back.

    Same with 2 and whatever number I send.

    The issue is that It is not running the IF commands.

    I also want to make the incoming data a bit longer such as A123. When I try that, I get:

    You entered: A
    You entered: 1
    You entered: 2

    and so on.

    Any help would be great.

  2. #2
    Join Date
    Jan 2010
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: HSerin

    Anther issue I am having is that the pic will hang up after sending data now and then. It almost always hangs if I send something like 12345.

  3. #3
    Join Date
    Jan 2010
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: HSerin

    Code:
    Hserin [DEC3 INC]
    HSerout ["You entered: ", INC, 10, 13]
    IF INC = 111 THEN GOTO Think
    IF INC = 222 THEN GOTO TURNON
    IF INC = 333 THEN GOTO TURNOFF
    This worked great. However, it is sending odd chars back. Am I formatting the HSerout wrong?

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: HSerin

    Maybe?

    HSerout ["You entered: ",DEC INC, 10, 13]
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts