[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] Sought: interrupt-driven buffered UART sender
From: |
Ron Kreymborg |
Subject: |
RE: [avr-gcc-list] Sought: interrupt-driven buffered UART sender |
Date: |
Wed, 24 Oct 2001 22:06:17 +1000 |
In most situations, compared to the time scale of transmitting a byte, the
difference between using SIG_UART_TRANS and SIG_UART_DATA will be negligable
(a few microseconds). As you suggest, the advantage of SIG_UART_TRANS is
that you need not mess with the interrupt bits when there are no more bytes
to send (my code just sets the software busy flag to free). So unless data
rate is everything, I would go for the simpler solution.
//-------------------------------------------------------------------
// Signal handler for uart txd ready interrupt.
//
SIGNAL(SIG_UART_TRANS)
{
if (--MessageLen > 0) // while bytes to send
outp(*TxPntr++, UDR); // write next byte from data buffer
else
TxBusy = 0; // once again available
}
Ron
-------------------------------------------
Ron Kreymborg
Jennaron Research
Melbourne, Australia
> Does SIG_UART_TRANS make sense? According to the AVR documentation,
> it'll only be signalled once all characters have left the transmitter.
> Normally, I'd use SIG_UART_DATA instead (which gets signalled once
> there's room in the data holding register, i. e. the current byte is
> still in the Tx shift register). However, handling UDRE interrupts is
> a bit messy (the interrupt gets only cleared by writing to UDR, so
> once all has been written, you need to turn that interrupt off again
> completely since you can't write anything else to UDR), so i didn't
> get my version to work at first.
>
> Rich's code apparently does it that way. He did some things a bit
> differently than my initial version, maybe that's the reason why it
> works. ;-)
>
> --
> J"org Wunsch Unix support engineer
> address@hidden
> http://www.interface-systems.de/~j/