My USART problems..


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80


    Did you find this post helpful? Yes | No

    Default ..And reading..

    Hmm, now I have problem with reading from the USART instead..

    I searched the forum and found ALOT of threads, but none that really solved my prob..

    I want to read a string of chars, like 16, BUT if a CR (13) occurs it should skip the rest.

    I.e I want to be able to write strings UP to 16 chars in my terminal program, and get them as a string or array.

    This seem to be a bit harder than I first thought ?

    It was very easy to read single chars with HSERIN.. and I thiought it would be easy with something like

    HSERIN [ str rxarr\16\13 ]

    ..But no ?

    Does anyone have a bit of sample code that do this using HSERIN ?

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


    Did you find this post helpful? Yes | No

    Default

    Have you used SEROUT2/SERIN2 much? The hardware command use the same syntax.

    Off the top I would try
    $d
    in place of
    13

    What exactly is or is not happening?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80


    Did you find this post helpful? Yes | No

    Default

    Well, I havent used SERIN, never really had use of the serial stuff before.

    Now I have:

    main:

    HSERIN [ str rxarr\8\13 ]
    LCDOUT $FE, 1, "Serial data is:"
    LCDOUT $FE, $C0, rxarr
    pause 500
    goto main:


    ..This just print the first char I write.. I want rxarr to contain eight chars.

    btw I found this on melabs website, which made me even more confused..

    http://melabs.com/resources/samples/pbp/usart.bas

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


    Did you find this post helpful? Yes | No

    Default

    I think I see what you need. When you use the STR thing it is creating an array. Here is an example.
    Code:
    SERIN2 PORTB.5,24972,[WAIT("A"),STR NUMS\16]	'7, Even
    X1 = (NUMS[1])
    X2 = (NUMS[3])
    X3 = (NUMS[5])
    X4 = (NUMS[7])
    X5 = (NUMS[9])
    X6 = (NUMS[11])
    X7 = (NUMS[13])
    X8 = (NUMS[15])
    the above is saving a 16 character array but I only want every other bit. Now I have eight variables X1 to X8. Do what ever you need with them.

    Sorry for the poor example but it is what I have with me.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56
  2. USART TXREG Problems
    By BigH in forum Serial
    Replies: 2
    Last Post: - 11th January 2006, 00:30
  3. USART problems
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 47
    Last Post: - 6th March 2005, 21:45
  4. Replies: 5
    Last Post: - 1st December 2004, 12:49
  5. Synchronous USART problems... HELP!!!
    By moni in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th November 2003, 19:00

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