HSERIN and HSEROUT problems


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94

    Default HSERIN and HSEROUT problems

    Hi,
    i wrote this program to give serial information by jserin and hserout instructions.i want to send
    "C" charactor and then send B0 and B1 valude and in reciver first i should get the "C" charactor
    anf then get serial data and put them in B0 and B1 variables and show them on lcd.
    when i turn on reciver after 1 or 2 seconds some randim numbers is shown on lcd without turning on transmitter.
    could you help me with this problem?

    transmitter program:
    define OSC 4
    ' Set transmit register to transmitter enabled
    DEFINE HSER_TXSTA 20h
    ' Set baud rate
    DEFINE HSER_BAUD 1200
    ' Set SPBRG directly (normally set by HSER_BAUD)
    DEFINE HSER_SPBRG 25
    B0 var byte
    B1 var byte
    B0=125
    B1=225
    hserout ["C"]
    hserout [bin B0,B1]
    end

    reciver program:
    define OSC 4
    '
    'lcd defines
    '

    ' Set receive register to receiver enabled
    DEFINE HSER_RCSTA 90h
    ' Set baud rate
    DEFINE HSER_BAUD 1200
    ' Set SPBRG directly (normally set by HSER_BAUD)
    DEFINE HSER_SPBRG 25
    n var byte
    B0 var byte
    B1 var byte
    ArrayVar var byte
    C var byte
    n=1
    hserin [STR ArrayVar\n\C]
    hserin [bin B0,B1]
    lcdout $fe,1,#B0," ",#B1
    end

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    amindzo, You should use the "WAIT" qualifier in your hserin statement and then make the qualifier string something like the word "data" and then send the data bytes. Your receiver's data slicer is probably decoding noise and this noise is being interpreted by the UART as data bytes. The qualifier used in the hserin statement will WAIT for the qualifier string (in this case "data") to br received before receiving any further bytes. It's in the manual.....

    Dave Purola,

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,810


    Did you find this post helpful? Yes | No

    Default

    Try this:

    transmitter program:
    define OSC 4
    ' Set transmit register to transmitter enabled
    DEFINE HSER_TXSTA 20h
    ' Set baud rate
    DEFINE HSER_BAUD 1200
    ' Set SPBRG directly (normally set by HSER_BAUD)
    DEFINE HSER_SPBRG 25
    B0 var byte
    B1 var byte
    B0=125
    B1=225
    hserout ["C"]
    hserout [B0,B1]'<<<<<<<<<< NO BIN qualifier here!!!
    end

    reciver program:
    define OSC 4
    '
    'lcd defines
    '

    ' Set receive register to receiver enabled
    DEFINE HSER_RCSTA 90h
    ' Set baud rate
    DEFINE HSER_BAUD 1200
    ' Set SPBRG directly (normally set by HSER_BAUD)
    DEFINE HSER_SPBRG 25
    n var byte
    B0 var byte
    B1 var byte
    ArrayVar var byte
    C var byte
    hserin [wait("C")]'<<<<<<<<<< Use wait
    hserin [B0,B1]'<<<<<<<<<<<< No Bin here!
    lcdout $fe,1,$80,bin B0,$fe,$c0 bin B1
    end

    Hope it helps
    Ioannis

Similar Threads

  1. HSEROUT and Commas, What? Help Me Understand
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th July 2009, 19:12
  2. HSERIN and HSEROUT commands
    By ryan in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 6th January 2007, 22:11
  3. HSERIN and HSEROUT problems
    By amindzo in forum Serial
    Replies: 1
    Last Post: - 6th September 2006, 21:11
  4. Problems with HSERIN HSEROUT
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th September 2005, 17:24
  5. HSEROUT Problems
    By SergioRM in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th April 2005, 23:17

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