[Top][All Lists]

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

Re: [avr-gcc-list] Re: USART interrupts

From: Larry Barello
Subject: Re: [avr-gcc-list] Re: USART interrupts
Date: Mon, 14 Apr 2003 16:37:24 -0700

The usart is triple buffered in the newer mega chips.  Unless you were
processing some serious fast data stream it seems unlikely you would
miss the next character.  If pushing stuff before reading the UDR
causes you to lose data, then reading before pushing will still cause
problems, or at a minimum recursion until problems occur!

Anyway, with the USART you analysis is correct, you need to clear the
interrupt source (read/write the udr) BEFORE re-enabling interrupts.

Most people avoid the issue all together by re-enabling the interrupts
when they return (reti).  Thus most people use SIGNAL for everything.

Unless you have a higher speed, more time critical interrupt, there is
no good reason to re-enable.  It doesn't make anything faster.  It
just reduces latency a tad.

This isn't a bug, just the way Atmel decided to do it.  Some
interrupts are cleared when the vector is taken, others when a
specific hardware action is taken.

----- Original Message -----
From: "Bob Halford" <address@hidden>
To: <address@hidden>
Sent: Monday, April 14, 2003 3:05 PM
Subject: [avr-gcc-list] Re: USART interrupts

> This is most likely an FAQ but it would seem (with the mega8 at
> that you
> have to use SIGNAL rather than INTERRUPT for SIG_UART_RECV as
> the code produced by the C-compiler does not read the UDR until
> whole bunch
> of registers have  been pushed on the stack..... Difficult to say
> the limited
> in-circuit tools to hand but my guess is that when using INTERRUPT,
> soon as the
> interrupt is re-enabled, the un-cleared RXC flags immediately causes
> another interrupt
> and so on until the stack is full.
> Is this really what happens? If so, surely this is a bug.... the
> interrupt arbritation logic
> should not allow this (ie one way of avoiding this is to make the
> interrupt transition
> rather than level sensitive.. but preferable is to disallow
> interrupts).
> You can kind of work round the problem by using SIGNAL and doing an
> sei() just after
> reading the UDR but does this mean that if the SIG_UART_RECV s/r
> not get done
> before the next RXC, we are in the shit?
> Cheers, Bob
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list

reply via email to

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