SERIN confusion on receiving a string of characters.


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: SERIN confusion on receiving a string of characters.

    What sort of USB-to-serial is this?
    The fact that you're using a 22k resistor indicates the converter is an "USB-to-RS232" converter which means you should use N9600 (Mode 6) when the RS232-signal is connected (via resistor) to the PIC. Your code, on the other hand, uses T9600 (Mode 2) indicating that the converter is "USB-to-UART" in which case the resistor isn't really needed. Also, make sure you have the GND of the converter connected to GND of PIC and - obviously - that you have selected the correct baudrate in whatever terminal program you're using.

    As usual, get the basics going first BEFORE you try to fill arrays, using wait characters, timeouts and so on.

  2. #2
    Join Date
    Feb 2013
    Posts
    1,160


    Did you find this post helpful? Yes | No

    Default Re: SERIN confusion on receiving a string of characters.

    Decoder routine and other code works fine. I'll check other things too later. I already tried setting mode 6, no difference.

    The USB<>Serial converter is common one, based on CH340 chip.

    Name:  unitrode.jpg
Views: 1105
Size:  138.4 KB

  3. #3
    Join Date
    Feb 2013
    Posts
    1,160


    Did you find this post helpful? Yes | No

    Default Re: SERIN confusion on receiving a string of characters.

    Issue solved.
    While manual says "Pin is automatically made an input."
    In fact it does not, so I made that pin an input via TRIS register and now (mode 6) works fine.

    Now how to change above code, so it displays text immediately after pressing the enter, not waiting for 8 characters to fill in?

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,175


    Did you find this post helpful? Yes | No

    Default Re: SERIN confusion on receiving a string of characters.

    Page 211 of the manual for the SERIN2 command

    Use STR ArrayVar\n{\c} where the c is the 13 (enter).

    Ioannis

  5. #5
    Join Date
    Feb 2013
    Posts
    1,160


    Did you find this post helpful? Yes | No

    Default Re: SERIN confusion on receiving a string of characters.

    Like this?

    serin2 portb.6,16468,[WAIT(13),STR textline\8]

    It works, but with big delay and not repsonding to "ENTER"
    actually, it only works when 8 characters are typed in a row quickly...

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,175


    Did you find this post helpful? Yes | No

    Default Re: SERIN confusion on receiving a string of characters.

    More like this

    serin2 portb.6,16468,[STR textline\8\13]

    It will exit either filling 8 characters in the textline or earlier if you hit enter

    If you want also to start filling textline after first enter then use this (not recommended though):

    serin2 portb.6,16468,[WAIT(13),STR textline\8\13]

    because serin may get confused which enter is, first or last. Better use different character for start and finish.

    Ioannis

  7. #7
    Join Date
    Feb 2013
    Posts
    1,160


    Did you find this post helpful? Yes | No

    Default Re: SERIN confusion on receiving a string of characters.

    Wow thanks!
    it works like Charm!

Similar Threads

  1. PLz Help! Serin and Serout Confusion
    By noor31 in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 16th June 2014, 20:51
  2. String of characters(array) to decimal value
    By tacbanon in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 20th June 2012, 15:30
  3. Problem receiving string
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th October 2009, 08:24
  4. Receiving Different String lengths
    By Jannie in forum Serial
    Replies: 5
    Last Post: - 26th January 2009, 06:00
  5. USART Stops Receiving Characters
    By breesy in forum Serial
    Replies: 7
    Last Post: - 26th November 2006, 04:50

Members who have read this thread : 0

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