Can't reliably transfer over serial connection between two PICs


+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2013
    Posts
    1,138

    Default Can't reliably transfer over serial connection between two PICs

    Hello.
    Having a strange issue.

    PIC18F45K80 and PIC16F1936.

    they are connected to each other via 22K resistor. PORTC.3 on both.

    Trying to run the simple code:

    TX: (1936)

    Code:
    barka:
    serout2 portc.3,84,[345]
    pause 100
    goto barka
    RX (45K80)

    Code:
    taka:
    serin2 portc.3,84,[x]
    if x=345 then stop
    lcdout $fe, $c0, "X=", dec x, "    "
    goto taka
    It does not work, it never receives "345". received value is always random, but quite often it is 89.
    Variable types are proper, port configs also.
    I tried to change direction and send from 18F to 16F - same issue.
    Checked signals with scope - no issues.
    Tried to various resistors - 1K, 10K, 22K - no difference.

    Yes I know that hardware port should be used, but PCB is already made.
    Distance from one chip to another is about 10 centimeters and they're both on the same PCB and same power supply. I've checked signals with scope and there are no issues, like low levels or noise.

    I tried to make code more complicated, like sending 8 characters + control character (enter) -this improves it a bit, might say that at least one try from 10 delivers proper result. Sometimes, it starts to work fine, but then again messes up. Also tried reducing port speed to 1200bps - no change.


    Any ideas?

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,146


    Did you find this post helpful? Yes | No

    Default Re: Can't reliably transfer over serial connection between two PICs

    1. How can you be sure that the receiving PIC will start "listening" just before the sending PIC? Better use a start character on the sender and use this character as a WAIT one on the receiving PIC to synchronize both.

    2. How is variable x defined? BYTE or WORD? 345 is more than a BYTE can store. 345 in Binary is 101011001. So if x is byte, it will randomly store 01011001 which happens to be, guess what?
    Exactly 89...!!!

    Ioannis

Similar Threads

  1. Csv file transfer directly into excel using vb for serial coms
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th May 2016, 08:43
  2. Usb to ttl modules - connection to pics at 3.3v
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 12th March 2015, 20:03
  3. Replies: 1
    Last Post: - 23rd December 2006, 10:38
  4. large file transfer petween pics
    By Ron Marcus in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd July 2005, 17:04
  5. Can serial transfer binary data?
    By TurboLS in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th March 2005, 08:27

Members who have read this thread : 3

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