CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RS 485 reception problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
uttarawakhke



Joined: 06 Feb 2014
Posts: 2

View user's profile Send private message

RS 485 reception problem
PostPosted: Thu Feb 06, 2014 2:57 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 06, 2014 3:57 am     Reply with quote

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

View user's profile Send private message

Re: RS 485 reception problem
PostPosted: Thu Feb 06, 2014 5:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 06, 2014 5:44 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 06, 2014 9:23 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group