Methods:
Bob Ammerman [RAMMERMAN at PRODIGY.NET] of RAm Systems says:
Here is a neat trick to get a 'push-pull' output from two PORT A pins:1: define them as analog (ADCON1)
2: TRIS them as outputs.Now, when you BSF either of them the other will automatically be cleared.
Andrew Warren says:
Of course, if you can't configure the pins as analog inputs (because, for instance, the PIC you're using doesn't HAVE an A/D converter), you can do this:MOVLW 00000001B ;RA0 = 1, RA1 = 0. MOVWF PORTA ; MOVLW 00000011B XORWF PORTA ;Toggle RA0 and RA1. XORWF PORTA ;Toggle the two pins again. XORWF PORTA ;And again...Or, if those two pins are the only ones defined as outputs on that port:
MOVLW 00000001B ;RA0 = 1, RA1 = 0. MOVWF PORTA ; COMF PORTA ;Toggle RA0 and RA1. COMF PORTA ;Again. COMF PORTA ;And again...
Nationals app note for a mouse actually skipped the cap
Dan Michaels of Oricom has an appnote on this at http://www.oricomtech.com/an-ecd02.zip (cached 20001016 in HTML)
and Engdahl did something similar in a line buffer circuit
http://www.hut.fi/Misc/Electronics/circuits/rsbuffer.html
but he was using an external power source for extra juice so the amplifier
type would have to be changed from emiter follower to a voltage gain amp.
They did not use RTS as a source of +12 volts, connecting the transistor
to +Vcc (local +5 volts) instead. My thinking is that if RTS isn't at +12,
the peripheral shouldn't be sending anyway. In fact, if I bias this correctly,
setting up the TX pin as an input would allow the periperal to read the RTS
status without needing another IO pin. That would be cool, but Jeff Frohwein
says ``it doesn't appear to me that it would work. It appears to me that
the transistor would always be on ...'' forcing TxD to always be Hi no matter
what data we're trying to transmit on TX.
Here is a circuit and board
in Eagle and a picture of the circuit.
Take the higher voltages from the RS232 port. T1,T2 & T4 may be almost any npn low power transistors (eg. BC107). T3 almost any pnp low power transistor with UCEmax >=30V (eg. BC177). Using of switching transistors is however recommended. Diodes - almost any low power impulse diodes.
See also:
Interested: