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

RS485 and flushing RX_Buffer

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



Joined: 23 Oct 2023
Posts: 3

View user's profile Send private message

RS485 and flushing RX_Buffer
PostPosted: Mon Oct 23, 2023 6:32 am     Reply with quote

hi
i've run into a problem i'm hopeing someone out there can help me with, typically i use RS422 for everthing, which works great with built in #users232 rx and tx buffers, however on a current solution i am having to use rs485, which would have been fine if we had built the hardware with a linedriver we could disable the RX on!, however we didn't! so everything that sends gets echo'ed back on the RX line, so question is there an easy way to either disable the RXbuffer during writes, purge the RX buffer?, or even suggest a bit of code that would do all the above relaibly? as can't find an obvious command (outside have a loop that reads the buffer and dumps it) and a search of the forum has proved a bit fruitless
any help would be greatly appreciated
cheers graham
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Oct 23, 2023 6:44 am     Reply with quote

Which RS-485 interface device do you use as I'm pretty sure when you tie rcv enable to tx enable on a MAX485,it'll block the 'loopback' data.
The enable pins are next to each other,so solder blob can join them......

this from fuzzy memory of the dinosaur...dang what happenned to 'fuzz logic'?
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Mon Oct 23, 2023 7:06 am     Reply with quote

As Jay says changing the hardware so the RX is disabled when your transmit
would be the standard and nicest way to go.

Unfortunately the standard PIC UART does not have a RXEN bit. You only
have the UART enable, and a separate TXEN. So you can turn off the
transmit separately, but not the receive.

Fist choice would be to not use the supplied RX buffering. Instead use the
ex_sisr.c buffering. You can then simply add a flag to this called something
like 'rx_enable', and when this is set to false, just have the ISR read the
character and throw it away.
The second way is just to use the supplied buffering and read the characters
to empty the buffer. The obvious way.
There is possibly a third 'sneaky' way of doing this, depending on what
chip you are using?.
If you are using a chip with PPS to map the signal to the UART, then
provided the fuse is set to allow repeated remapping, you can simply
set the UART RX signal to 'NONE' at the moment you enable the transmit
and then back to the required pin when you turn this off. Result the
input is ignored.
gce



Joined: 23 Oct 2023
Posts: 3

View user's profile Send private message

PostPosted: Mon Oct 23, 2023 7:20 am     Reply with quote

hi temtronic
sorry meant to put that in the mail it's a MAX33072EASA+ (seemed a good choice in the rush as built in as invertable pins, esd etc... should have read the data sheet more closely!) i thought the same, it would disable the recieve when writing but sadly not in this case... on the next spin i'll change the chips out probably to MAX3440E which properly enables and disables the drivers (like i'd expected) was just looking for a solution in software to test out the prototypes so i didn't have to practic my wirewrapping skills on SMT, but might have to just get the chips swapped out instead if theres not an easy method
cheers
graham
gce



Joined: 23 Oct 2023
Posts: 3

View user's profile Send private message

PostPosted: Mon Oct 23, 2023 7:24 am     Reply with quote

thanks for the reply Ttelmah, sadly it's a 18f26k22 so no option 3, but will take a look at the sisr buffering method
cheers
graham
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Mon Oct 23, 2023 11:15 am     Reply with quote

One critical thing. If you switch to a driver with the receive disable,
remember you need a pull-up resistor on the receive line between
the driver and the PIC, to ensure it floats high....
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