Serial problems


Closed Thread
Results 1 to 5 of 5

Thread: Serial problems

  1. #1
    Join Date
    Mar 2008
    Posts
    59

    Default Serial problems

    PBP3, Here is my newest problem.

    #config
    __config _INTOSC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _LVP_OFF & _CP_ON & _BODEN_OFF
    #endconfig
    CMCON = 7 'CHANGES PORTA TO DIGITAL
    V1 VAR byte
    V1 = 0
    SETTINGS:
    OVER:
    SERIN2 PORTB.0,16468,3000,OVER,[V1]
    serout PORTA.3,6,["V1 = ",#V1,10]
    goto OVER

    'When I send "50 why do I receive "v1 = 53"? I also get "v1 = 53" from "51"? I am missing something?

    Thanks to anyone that can help!
    Last edited by n0yox; - 30th September 2015 at 04:57.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517

    Default Re: Serial problems

    Hi,
    Yes, you're missing somehing....
    You get V1=53 because you're sending a string of two ASCII characters from the PC, a "five" and a "zero". You're telling the PIC to receive ONE byte, it grabs the first one, the "five" which happens to be ASCII code 53. Try sending 60 and you'll get 54 because 54 is the ASCII code for "six" or 93 and you'll get 57 because 57 is the ASCII code for "nine".

    If you're sending decimal numbers as ASCII strings then tell SERIN you're doing just that
    Code:
    SERIN2 PORTB.0,16468,3000,OVER,[DEC V1]
    BTW, please use code tags when posting code, it gets so much easier to read.

    /Henrik.

  3. #3
    Join Date
    Mar 2008
    Posts
    59

    Default Re: Serial problems

    Thank you very much for your help. I added the DEC modifier and now receive nothing back when I send "50". So after a little reading I tried DEC2 and that seems to work. I really appreciate your help!

    Thanks again!

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517

    Default Re: Serial problems

    It depends on "how" you send it.
    If you use the DEC it will grab as many digitis as you send provided you end the string with a non numeric character (like a character or, LF or CR), if you don't it doesn't know when to stop and will sit there waiting. If you ALWAYS send exactly two digits then DEC2 is the best aproach.

    /Henrik.

  5. #5
    Join Date
    Mar 2008
    Posts
    59

    Default Re: Serial problems

    Thank You, That explains another problem I am having! Again,I really appreciate your help!

    Thanks!

Similar Threads

  1. Serial cable problems
    By akilleuz in forum Serial
    Replies: 5
    Last Post: - 29th May 2007, 23:38
  2. Serial communication problems
    By amindzo in forum Serial
    Replies: 0
    Last Post: - 28th August 2006, 18:48
  3. Serial communication problems
    By amindzo in forum General
    Replies: 0
    Last Post: - 28th August 2006, 18:47
  4. Serial output problems...
    By jesterhoz in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd March 2005, 03:39
  5. Serial comm Problems
    By Fossil in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th January 2004, 03:29

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