View previous topic :: View next topic |
Author |
Message |
uttarawakhke
Joined: 06 Feb 2014 Posts: 2
|
RS 485 reception problem |
Posted: Thu Feb 06, 2014 2:57 am |
|
|
Hi,
I am using rs485 between PIC24(master) and pic18(slave).
I am not getting correct data from slave. 15 bytes data is expected first byte and last 2 bytes are missing while remaining data that is received is correct.
Tried doing almost everything.. please help.
Thanks and regards,
Uttara |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Thu Feb 06, 2014 3:57 am |
|
|
On the last two bytes being missing, you are almost certainly turning off the transceiver, or turning it round (depending how it is wired) too early.
Remember that when a putc/printf returns there are _still_ two bytes in the hardware buffer. If you turn the transceiver off at this point, these will be lost....
Various solutions. Just delay for two byte times (simplest), or test the UART's TRMT bit, and wait for this to be set.
First byte being missing, could be multiple things. Is it missing, or are you getting garbage?. Missing, then look at whether the receiving device is enabling it's buffer quickly enough. Remember that the bus, and the lines to devices should all be wired to give the bus idle state when not driven. Otherwise you can see 'false' start bits that could lose part of the first byte. Consider a fractional delay between enabling the buffer, and sending.
Best Wishes |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
Re: RS 485 reception problem |
Posted: Thu Feb 06, 2014 5:09 am |
|
|
uttarawakhke wrote: | Hi,
I am using rs485 between PIC24(master) and pic18(slave).
I am not getting correct data from slave. 15 bytes data is expected first byte and last 2 bytes are missing while remaining data that is received is correct.
Tried doing almost everything.. please help.
Thanks and regards,
Uttara |
Try reducing the No of characters to say ~5.
Use spare pins on TX and RX devices to show their status.
Then use a 'scope to see what your timing relations are.
Mike |
|
|
uttarawakhke
Joined: 06 Feb 2014 Posts: 2
|
|
Posted: Thu Feb 06, 2014 5:44 am |
|
|
Thanks Ttelmah.
I have given enough delay of 1sec before sending the data from master and also i check for TMRT == 1. still i am not ablr to receive last two bytes. now i am receiving first byte as garbage value.
Actually i am modifying RS232 compatible bootloader code to rs485. and full bootloader stack provided by microchip is in assembly. so can u please tell me that i have put rs485 control bit instructions at right place?
Please help. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Thu Feb 06, 2014 9:23 am |
|
|
From here I can't tell if you've got a TX, RX or a TX and RX problem.
Judicious testing with a 'scope will give you some clues.
Mike
OR maybe convert TTL levels to RS232 and feed to a PC. |
|
|
|