Andy Warner wrote:
> [...]
> Here is the USART0 rx interrupt handler that demonstrates the problem
> (apologies in advance, if gmail mangles this):
> 
> #define       SEARCHING (-2)
> #define       BREAK (-1)
> #define       MAX_DMX (512)
> 
> ISR(USART0_RX_vect)
> {
>       unsigned char status = UCSR0A;
>       unsigned char data = UDR0;
>       volatile static int slot = SEARCHING;

Does the problem still occur if you assign the variables later and not
at declaration time, i.e., something like:

        unsigned char status, data;
        volatile static int slot = SEARCHING;

        status = UCSR0A;
        data = UDR0;

I don't know from memory if the creation of local variables that are not
themselves volatile must respect their order. It might be the case that
the compiler is allowed to reorder the creation of the variables and
then it respects the volatile assignment by actually reading the memory
positions even if the values would be discarded later.

And why is the "slot" variable volatile? It seems there is no reason for
it and it makes the code a lot worse...

-- 
Paulo Marques - www.grupopie.com

"I used to be indecisive, but now I'm not so sure."

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to