Forward Serial Data from pic to pc


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2008
    Posts
    12

    Question Forward Serial Data from pic to pc

    Hello, I have had some trouble trying to do the following:

    I need to send 8 bytes, from pic1(16f887) to pic2(18f2550) using hserin/hserout. Then I need to forward those 8 bytes from pic2 to a PC via USB.

    What would be a good algorithm to accomplish this? Lets take into account tmr0 Interrupts(dt instant I.) running on both pics. Pic1 has other bussiness to do other than sending the data, and pic2 is just a mediator between pic1 and pc.

    If anyone has an idea I would be very grateful. I just need the algorithm to come up with the code. By the way, I know how to use the 2550 to send info via USB.
    Thanks a lot in advance!
    Last edited by Muller; - 2nd September 2008 at 20:08.

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


    Did you find this post helpful? Yes | No

    Default

    Receive into pic2 as an array, then forward the array. ?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Apr 2008
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    wait, sorry. My enter key is messing up, wasn't finished
    Last edited by Muller; - 2nd September 2008 at 21:26.

  4. #4
    Join Date
    Apr 2008
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    OK, I tried that Dave. With bad results, here's my code:

    Pic2 code
    <code>
    RXIn:
    if RCIF then

    @ INT_DISABLE TMR0_INT
    for index = 0 to 3
    hserin [serialdata]
    dataA(index) = serialdata
    next index
    usbservice
    gosub dousbout
    @ INT_ENABLE TMR0_INT

    endif
    @ INT_RETURN

    </code>

    pic1 code:

    <code>
    hserout [var1(0), var1(1), var1(2), var1(3)] 'it only has 4 bytes now
    </code>

    I tried:
    <code>
    hserout [STR var1\4]
    </code>
    but it gave me an error (ERROR: Macro HSEROUTSTRN?W not found in macro file.)
    Last edited by Muller; - 2nd September 2008 at 21:31.

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


    Did you find this post helpful? Yes | No

    Default

    To receive an array you need to HSERIN something like this
    Code:
    [WAIT("A"),STR NUMS\8]
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Apr 2008
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    sorry, again.. I wish I could delete the messages. My enter key, instead of jumping a line, sends the message earlier. sorry

  7. #7
    Join Date
    Apr 2008
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    And when I want to send it, why do I get that error?

    ERROR: Macro HSEROUTSTRN?W not found in macro file.

    Isn't <code> hserout [STR nums\8] </code> right?

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


    Did you find this post helpful? Yes | No

    Default

    We are passing each other

    Can you post the whole code. Something is missing.
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Apr 2008
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    OK, I found out what I was doing wrong.. THe array I was trying to send was a word, not a byte.. Sorry..

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


    Did you find this post helpful? Yes | No

    Default

    Thats what was missing
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  2. Send data to PC USB
    By konter in forum Off Topic
    Replies: 2
    Last Post: - 18th December 2009, 21:57
  3. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  4. PC serial port funny
    By nicjo in forum Serial
    Replies: 13
    Last Post: - 6th February 2007, 05:34
  5. Receiving data from more than one serial Port
    By PICtron in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th March 2005, 10:20

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