strange rs232 data displayed


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219

    Default strange rs232 data displayed

    I am sending RS232 from PIC to PIC. Transmitter sends 16 characters, “ABCD….OP”. Transmitter output is verified with Tera Term on PC. Both Tx and Rx operates at 96k baud. Receiver stores characters in VAR RxData. RxData is displayed on LCD on my X1 board. On the first pass LCD displays ABABCDEFG….. On the second pass and all passes after the LCD displays OPABCDE….. for 16 characters. I have used different delays on the receiver before and after, hserin 2000,TimeOut , [str Rxdata\16]. I can’t figure out why this is happening. I’m not real sure about the use of STR modifier, can this be a problem? Comments please!

    Tx char string ABCDEFGHIJKLMNOP
    First pass Rx display ABABCDEFGHIJKLMN
    Second pass display OPABCDEFGHIJKLMN
    All fallowing pass OPABCDEFGHIJKLMN
    --------------------------------------------

    RxData var byte [20]

    Main:
    RxData=0 ;clear RxData
    hserin 2000,TimeOut , [str Rxdata\16]

    LCDOUT $FE,1,"Rcvd string: " ;display 16 bytes RxData
    LCDOUT $FE,$c0
    LCDOUT str rxdata\16
    pause 3000
    goto Main ;Loop forever

    TimeOut:
    LCDOUT $FE,1,"Fumble,try again"
    pause 1000
    GOTO main

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    What happens if you clear rxdata after you lcdout the value?
    I am thinking . . . . 20 byte array vs 16 byte data . . . maybe shifting . . . no time right now to play with this .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Reply to Joe

    Joe,
    I cleared RxData after LCDout as you suggested with no change in results. Then I tried this addition:

    LCDOUT $FE,1
    LCDOUT RxData[1],RxData[2],RxData[3],RxData[4],RxData[5], RxData[6]
    PAUSE 3000
    Results: first pass: BABCDE. second pass: PABCDE
    This is even more puzzling.
    String display after first pass OPABCDE…Byte display PABCDE
    String display screws up two bytes while byte display screws up one byte????

    With this change:
    hserin 2000,TimeOut , [wait ("A"),str Rxdata\15
    LCDOUT $FE,1
    LCDOUT RxData[1],RxData[2],RxData[3],RxData[4],RxData[5], RxData[6]
    pause 3000


    Results:
    first pass: ABCDEF “A” should not have been displayed
    second pass: CDEFGH
    third pass: ABCDEF same as first pass
    forth pass: CDEFGH same as second pass
    and continues to rotate output data through each pass

    If I Rx string then LCDout and END with only one cycle the results are the same ABABCDEF…..
    It sounds like RxData IS clearing based on changing first display byte. So it has something to do with hserin RxData “I think”. I added a delay after Tx output with no change in Rx. Still scratching my head...........

    By the way, I like your quote from the 1950's. I've passed it on to others.

  4. #4


    Did you find this post helpful? Yes | No

    Default Hope this helps

    Hey Moutnain747

    What are your HSER defines set to ?

    What clock speeds etc , internal or external oscillator ?
    PIC's?

    Is there anything between the two PIC's ?

    Are they wired or wireless ?
    Did it all work before ?

    Did you try a lower baud rate ?

    Think this info may help other help you more :-)

    Thought this may help assuming you're running at 20 MHz


    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 0 ' 9600 KBaud @ 20MHz, -86.98%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    Kind regards
    Dennis
    Last edited by Dennis; - 12th January 2010 at 23:48.

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


    Did you find this post helpful? Yes | No

    Default

    Post your whole code, RX and TX.
    Remember that arrays start at zero [0]
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Reply:

    After testing at different Bauds, trying different Hser defines, I found that if I always use a short define string before my needed data all reception is exceptable. Sending a string of “SINKABCDEFG…… and receive with

    hserin 2000,TimeOut , [wait("SINK"),str Rxdata\16]

    is successful each loop without error. I’ve seen other examples like this and I’m sure it’s a good practice. I’m sending with 16F819 at 8Mhz internal driving a LT108CN RS232 shifter. Resulting in NO errors on Tera Term.

    Receive on X1 board, 16F877A at 20Mhz also with LT108CN. Wired connection from bread board w/ F819. My only question now is why this works on receive end:

    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_BAUD 9600 ' Baud rate
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    And this doesn’t work on receive end with my X1 board:

    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 0 ' 9600 KBaud @ 20MHz, -86.98%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    Thank you guys for all your comments!

  7. #7


    Did you find this post helpful? Yes | No

    Default need more information :)

    Hi Mountain :-)

    Glad you're winning !

    You left a few things out :-)

    Try this
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 12 ' 9600 Baud @ 8MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    Hope that helps :-)

    Dennis

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Nokia 3310 display text
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th August 2007, 03:39
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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