PDA

View Full Version : Serial - to invert or not to invert...?



barkerben
- 1st December 2004, 22:23
Hi,

Been getting a bit confused about the need or lack of need to invert the data to, and from my PIC.

My setup is:


PC---->MAX232------->PIC
PC<----MAX232<-------PIC

Looking at the data sheets, the MAX232 invertes the signal, but I have heard it suggested that the UART needs (and sends) an inverted level anyway, so the 2 cancel out and there is no problem.

Would this then only be a problem if I was uning non-hardware serial pins, and would therefore need to artificially invert everything in software?


Cheers,


Ben

mister_e
- 1st December 2004, 22:31
Would this then only be a problem if I was uning non-hardware serial pins, and would therefore need to artificially invert everything in software?


I use often PIC connected directly to RS-232 with resistors in serie (about 1K-4.7K) and i never have any problems with. SERIN,SERIN2,SEROUT,SEROUT2 allow you to drive true or inverted. BUT if your PIC have already an USART, it's more code efficient to use it. If you need to invert signal you can also use simple 10 cents combination of NPN transistor+2 resistors too instead of MAX232+cap

barkerben
- 1st December 2004, 22:47
Thanks - that makes sense, and is what I had suspected.

Cheers,


Ben