Multiple PICs on usart network


Closed Thread
Results 1 to 40 of 52

Hybrid View

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

    Default Re: Multiple PICs on usart network

    Hi,
    This....
    Code:
    TXSTA.5 = 1                                 ' Enable USART TX function
    HSEROUT (slave sends reply only when spoken to by master)
    TXSTA.5 = 0                                 ' Disable USART TX function
    ...is also a bad idea.

    The HSEROUT will load TXREG with the last byte to be sent, then the program continues. If the next line turns off the transmitter the last byte won't be sent properly.

    Poll TXIF to determine when you can turn off the transmitter.

    If this is for anything more than messing around, use RS485 or something designed for the purpose.

    /Henrik.

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default Re: Multiple PICs on usart network

    Quote Originally Posted by HenrikOlsson View Post
    ...
    The HSEROUT will load TXREG with the last byte to be sent, then the program continues. If the next line turns off the transmitter the last byte won't be sent properly.
    ...
    Weird, nothing unusual came up when I was doing my tests back then; no bytes lost, no data loss. I'm going to have to test this with a higher volume of data transfer and add the polling of TXIF as you suggest.

    I just read a RS485 app note and my head hurts.
    http://www.analog.com/static/importe...tes/AN-960.pdf

    Robert
    Last edited by Demon; - 2nd January 2015 at 22:59.

  3. #3
    Join Date
    Aug 2011
    Posts
    453

    Default Re: Multiple PICs on usart network

    TXIF only means that you can load the TXREG.

    You need to poll TRMT to know when the byte has been shifted out of the TSR (Transmit Shift Register) and you can disable the output. TRMT gets set halfway into the STOP bit.

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

    Default Re: Multiple PICs on usart network

    Robert,
    I've done quite a bit of work with half duplex RS485 where you have a pin telling the tranceiver chip if it should operate in TX or RX mode.
    If I do
    Code:
    TxRx = Tx   ' Switch tranceiver to TX mode
    HSEROUT["Test",10,13]   ' Send data
    TxRx = Rx  'Sitch tranceiver to RX mode
    The last byte (13) will not go thru properly because the tranceiver chip is switched from Tx to Rx mode in the middle of it. I'm pretty sure you'll get the same thing when disabling the USART. It's possible though that a low oscillator frequency in combination with high baudrate "masks" the problem.

    Tumbleweed,
    TRMT is the correct bit, thanks for pointing that out!

    /Henrik.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,636

    Default Re: Multiple PICs on usart network

    they might get away with it because the last chr is 13 , so that means the last 4 bit and the stop bit all leave the tx line high anyway

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default Re: Multiple PICs on usart network

    It was 64MHz at 115,200 with a checksum that always balanced.

    I can't explain it but it worked. But I'm going to do intensive testing soonday and report back here.

    Robert

Similar Threads

  1. PICs in a RS-485 network?
    By atomski in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 12th November 2011, 09:52
  2. Multiple PICS from Same Crystal?
    By WOZZY-2010 in forum General
    Replies: 2
    Last Post: - 6th February 2010, 15:18
  3. Problems controlling multiple pics
    By gandora in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 29th May 2007, 08:59
  4. Multiple Pics to One serial port
    By Rleonard in forum Serial
    Replies: 1
    Last Post: - 18th January 2007, 18:30
  5. Multiple Data on to USART RX pin
    By Squibcakes in forum Serial
    Replies: 2
    Last Post: - 20th July 2006, 00:37

Members who have read this thread : 4

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