I am working with hardware uart 16c74a I need to invert the uart
output beside adding external inverter is there any way of doing it
in software ? any help will appreciated.
Probably not I'd say.
BUT
To do it in software probably costs very little.
single NPN small signal transistor, emitter to ground.
10k resistor from output pin to transistor base.
Resistor (size depends on drive required - 1k to 10K probably) from
collector to Vcc.
Output from collector.
>Hi to all engineers.
>
>I am working with hardware uart 16c74a I need to invert the uart
>output beside adding external inverter is there any way of doing it
>in software ? any help will appreciated.
>
>Andre
>
The send function in a UART is actually somewhat simple. Assuming you
have interrupts, which is the real efficient way to do it, just bang
your message out. Then let the recieve run through the UART. The
recieve is the real work. You said you wanted to invert the send, not
recieve. If you want to do both, well, that is a different story.
> Probably not I'd say.
> BUT
> To do it in software probably costs very little.
> single NPN small signal transistor, emitter to ground.
> 10k resistor from output pin to transistor base.
> Resistor (size depends on drive required - 1k to 10K probably) from
> collector to Vcc.
> Output from collector.
>
> Russell McMahon
>
Thanks for your replay. at this point I inverted externally
using logic gate single transistor is good idea too.
andre
Russell McMahon wrote:
> Probably not I'd say.
> BUT
> To do it in software probably costs very little.
> single NPN small signal transistor, emitter to ground.
> 10k resistor from output pin to transistor base.
> Resistor (size depends on drive required - 1k to 10K probably) from
> collector to Vcc.
> Output from collector.
>
> not
> recieve. If you want to do both, well, that is a different story.
>
> Chris Eddy
>
> Russell McMahon wrote:
>
> > Probably not I'd say.
> > BUT
> > To do it in software probably costs very little.
> > single NPN small signal transistor, emitter to ground.
> > 10k resistor from output pin to transistor base.
> > Resistor (size depends on drive required - 1k to 10K probably) from
> > collector to Vcc.
> > Output from collector.
> >
> > Russell McMahon
> >
> thanks for your idea but couldn't understand clearly. What to do ?
He was suggesting you "bit-bang" the serial transmit function and use
the UART for receive. This on the (correct) premise that serial
transmission is much easier than receive.
> sorry I do not use interrupt for uart
If you use simple timing loops to clock out the transmitted bits, you
tend to occupy all the processor's time. If you have a source of
interrupts at the desired bitrate however, you can use these to clock
out the transmitted bits.
You can use timer interrupts to receive serial data, but then you need
interrupts at least three times the bitrate, and this is not so
efficient.
>> Then let the recieve run through the UART.
> is this means connecting transmit and receive together ?
No, just saying you use a general-purpose I/O to "bit-bang" the sent
data, but connect the received data to the UART as before (via an
inverter I presume).
It sounds like you went for the "hardware" solution anyway - just as
we as you really should isolate the PIC from the serial line.
--
Cheers,
Paul B.
>
> You can use timer interrupts to receive serial data, but then you need
> interrupts at least three times the bitrate, and this is not so
> efficient.
I've done this on an 84, with ints AT the bitrate.
The trick is to catch the edge of the start bit, and sync the ints up half a
bit-time late.
I wouldn't use this approach in a noisy environment or on long lines.
> Yes, but that's the hybrid technique; you still need to poll for the
> start bit and synchronize the interrupts. Only *thereafter* it has low
> overhead.
nananana.. I put the serial in on an external int.
I used the timer for a bunch of functions.
> nananana.. I put the serial in on an external int.
> I used the timer for a bunch of functions.
I think there is still a restriction insofar as you must synchronise
the timer to this serial interrupt on the start bit - you still cannot
use the timer for some other task.
Alternatively there is the technique of reading the timer each time
the serial line toggles and thus generates an interrupt (a lˆ BayCom).
That makes it both efficient and highly accurate (you can determine
*precisely* when the transition was and implement a PLL algorithm).
It takes a bit of design (i.e., thought) as for example, one interrupt
often shifts in as many as nine bits simultaneously, but is undoubtably
the best. I haven't actually implemented it myself yet, mind you.
--
Cheers,
Paul B.
>Dave VanHorn wrote:
>
>> I've done this on an 84, with ints AT the bitrate.
>> The trick is to catch the edge of the start bit, and sync the ints up
>> half a bit-time late.
>
> Yes, but that's the hybrid technique; you still need to poll for the
>start bit and synchronize the interrupts. Only *thereafter* it has low
>overhead.
Not necessarily - you can either sample at 2x baud rate, or generate
an edge interrupt on the startbit.
----- Original Message -----
From: Mike Harrison
> >Dave VanHorn wrote:
> >
> >> I've done this on an 84, with ints AT the bitrate.
> >> The trick is to catch the edge of the start bit, and sync the ints up
> >> half a bit-time late.
> >
> > Yes, but that's the hybrid technique; you still need to poll for the
> >start bit and synchronize the interrupts. Only *thereafter* it has low
> >overhead.
> Not necessarily - you can either sample at 2x baud rate, or generate
> an edge interrupt on the startbit.
That's what I said I did.. The second bit was someone else.
This could be so simple if the manufactories just implement a
programmable "uart tx/rx data polarity bit"... in some cases it could be
important... but they think "what the hack? who in the world would need
it?", well I guess not even this question passed their heads... the
same for high/low speed internal programmable clock speed, when any
interrupt would automatically set high speed back from saving power...
but... again "who need it?" answer: WE DO! they would say "use sleep
mode, it works"... not at all, I want to keep the processor doing
something, while saving 90% of the power... not sleeping... but simple
things are impossible to be done by manufacturers.