On Thu, Nov 08, 2007 at 08:52:30PM -0000, bigningbo wrote:
>
> I try to write a routine for RS232 communication between PC and AVR.
> Which way is best if I transmit a string to PC by using a interrupt
> driven transmission or not by using interrupt?
Neither is best, it all depends on what you want to do.
> How will performance affects if a string is long by interrupt driven
> transmission?
What is there to affect/effect? Either way you will probably send each
character tail-up (circus animals in a parade closely packed with tails
up in the air).
> Will interrupt occur character by character? Thanks in advance!
It could interrupt every other character. You can interrupt each time
the TX shift register is empty, and/or you can interrupt when the double
buffer is empty.
With interrupt driven transmitter you have to provide a buffer big
enough to hold whatever you might send in one block. Or you have to test
for buffer full and block your program from sending more data until the
serial port catches up. If your application has nothing else to do until
the data string is sent then polling is much simpler and every bit as
good.
A good compromise I often use is to poll on TX, interrupt on receive.
--
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.