News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

PIC16F1827/47

Started by joesaliba, Jul 04, 2023, 07:05 AM

Previous topic - Next topic

joesaliba

I would like to use the PIC16F1827 or PIC16F1847.

Through USART I will need to sometimes send and receive non-inverted data, and sometimes send and receive inverted data.

In the data sheet I can only see that I can invert transmitting data, but cannot see how to invert receiving data.

Am I missing something through the datasheet?

Regards

Joe

Stephen Moss

I had had a quick look through the datasheet and come to the same conclusion as you, in that the Receiver has no way of knowing if the data is inverted or not.
Presumably the assumption is that you would be transmitting all data as either inverted or non-inverted and thus if the incoming data needs un-inverting it would be performed in code using a compliment (~) function after reception or via some intermediary device before it reached the Rx pin.

tumbleweed

Quoteand thus if the incoming data needs un-inverting it would be performed in code using a compliment (~) function
Typically you need to invert the whole thing (START-DATA-STOP) and not just the data, so if that's the case it needs to be done in hardware.

If you have the pins available you could connect the RXD signal to one of the comparator inputs and then the comparator output to RXD in. The comparator has a polarity bit (CxPOL) that can be used to change/invert the output.

david

Can't say I've seen a PIC with inversion on the rx side but an Exclusive OR gate would do the job.  Rx input to one gate and just toggle the other gate for true or inverted.  Single gate in a variety of very small packages.  A SOT-23 can easily be hand soldered if needed.

Cheers,
David

joesaliba

Thanks everyone for the answers.

@david 18F26K22 can do inversion on the rx side. I ad this PCB ready but had to change an external hardware which sends inverted data. I think I might find a place for a small SOT-23 inverter. I can also use a small MOSFET to invert data.

Regards

Joe

david

Understood.  I thought you were forced to use one only input for both the true and inverted signal sources.  If it's a fixed and known source then the inverter is fine but the cost will be the same and it's a one way street.
Good luck with your project.

Cheers,
David


joesaliba


trastikata

Quote from: david on Jul 04, 2023, 11:58 AMCan't say I've seen a PIC with inversion on the rx side but an Exclusive OR gate would do the job.

Newer Q-family PIC18F have offer full control over TX and RX polarities.

david

Good to know.  I have used tx inversion on hobby projects to talk directly to a PC but generally I'm a bit old school and have on-board comms as TTL and anything off-board as inverted and level shifted.

Cheers,
David