RS485/PIC18F4520-Interrupt not firing for all recieved bytes


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2009
    Posts
    3

    Default RS485/PIC18F4520-Interrupt not firing for all recieved bytes

    Hello to all forum members, hopefully somebody can point me in the right direction.

    I have setup a simple PIC18F4520 demo board, using a 10Mhz crystal. My Rx + Tx pins are connected directly to a Maxim 3080 rs485 transciever. PIC port D0 is connected to my { driver enable, (!reciever enable) } on the transciever. I am using a very short run of rj45 cable with no biasing or terminating resistors. I am using a baud rate of 115200.

    A PC is acting as bus master and sending simple ascii strings to the PIC using realterm.

    Sending characters from the PIC to the PC works fine, no characters are lost.

    Only the first 3 characters are triggering the rx interrupt when transmitting from the PC to the PIC.

    For example, I have set a breakpoint on the interrupt handler. When I send 'abcde' from the PC terminal, the breakpoint is only triggered for the 3 chars, a, b and c. The additional chars seem to be ignored.

    I could work around this, however I would like to understand what is happening.

    Thanks !

    David

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    955

    Default

    First off, without seeing code, it's very hard to comment accurately. Off the cuff, my rule of thumb is to not run the serial port at 115200 unless you are absolutely sure what you're doing. There are lots of things that can trip your code at this speed. Why not try a reasonable baud rate of 4800 or 9600 to check if your baud rate is the problem.

  3. #3
    Join Date
    Mar 2006
    Location
    China
    Posts
    266

    Default enable :-)

    Are you sure you have the rx enable on long enough to receive all characters and that you dont switch over to tx mode too fast before all stuff has arrived?

  4. #4
    Join Date
    Jul 2009
    Posts
    3

    Default

    Thanks for your responses. I reduced the baud rate and removed checking for overruns + framing errors. This seems to have solved my problem. Still not entirely sure why it works now, but its a start !
    Last edited by DavidKnott; - 9th July 2009 at 11:07.

  5. #5
    Join Date
    Dec 2005
    Posts
    1,073

    Default

    At 115200 you definitely need termination resistors at the ends of the RS485 bus. For a simple way to automatically control the TE/RE turn-around see FIG 4, p23 of...

  6. #6
    Join Date
    Jul 2009
    Posts
    3

    Default

    @dhouston

    Thanks, I might give that a go, now that I know that the circuit is working.
    I reduced the baud rate to 4800 as suggested by another member but I am still not using termination. I did read somewhere that if you are using short wiring line termination and biasing can cause more problems than it solves, however this may be only relevant for higher baud rates.

  7. #7
    Join Date
    Dec 2005
    Posts
    1,073

    Default

    Termination is not needed at low speeds but is a must at high speeds.

    Here is one of the best RS485 tutorials I've seen.
    And, anything by Jan Axelson on the topic is worth reading. She writes with great clarity making technical topics easy to grasp.

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 10:00
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 03:35
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 19:14
  4. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 03:59
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 02:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts