avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Re: USART - Interrupt - problem -Similar


From: Matthew Arcus
Subject: Re: [avr-gcc-list] Re: USART - Interrupt - problem -Similar
Date: Sun, 23 May 2004 21:30:01 +0100

On Sunday 23 May 2004 6:33 pm, Steve wrote:
> Hi,
>
> I have a similar problem to Onno below.
>
> Using a STK500 and the AT90S8515 I have been playing with the UART. I
> can get the receive interrupt to fire but not the two transmit related
> interrupts. (UART_UDRE and UART_TXC). I should re-phase that, that
> UART_UDRE I can definitely see fires during some circumstances but
> UART_TXC I can not see any indication of.
> /*data register empty*/
> SIGNAL(SIG_UART_DATA)
> {
>       //UDR = 'A';
> }
>
> /*char has been received*/
> SIGNAL(SIG_UART_RECV)
> {
>       PORTC ^=0x01;
>       a = UDR;
> }
>
> /*transmit complete*/
> SIGNAL(SIG_UART_TRANS)
> {
> }

You need to make sure that every interrupt handler resets the condition that
caused the interrupt in the first place. For the TXC interrupt, that's done
automatically by the AVR, before the interrupt handler is called, for RXC
interrupts, the condition is cleared by reading from UDR, so your handler is
OK there. For UDRE interrupts, the condition is cleared by writing to UDR
(there's no way to reset the condition other than this, which makes sense),
which your handler isn't doing so it will be running continually, blocking
out the TX interrupt completely since that has a lower priority (though still
allowing the RX handler to run as that has a higher priority). (I had
though,wrongly, that this was Onno's problem, forgetting that RX interrupts
aren't cleared automatically like the TX ones).

You could do what you want by disabling the UDRE interrupt in the
SIG_UART_DATA handler, and reenabling it when you transmit a character.

I think the AVR datasheets number interrupt vectors from 1, while the avr-gcc
headers number them from 0 (as things should be numbered).

Hope that helps,

Matthew.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]