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

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

[avr-gcc-list] optimizer removes volatile pin access code. why?


From: Joerg Desch
Subject: [avr-gcc-list] optimizer removes volatile pin access code. why?
Date: Tue, 27 Oct 2009 12:39:44 +0100

Hello all.

I' using gcc version 4.3.2 (Ubuntu Jaunty) to compile some simple code. The 
makefile is one of these standard AVR makefile. The optimization is set to -Os 
(size).

For some historic reasons, I use the following macros:

#ifndef BV
#define BV(bit)                 (1<<(bit))
#endif
#ifndef cbi
#define cbi(reg,bit)            reg &= ~(BV(bit))
#endif
#ifndef sbi
#define sbi(reg,bit)            reg |= (BV(bit))
#endif


So far so good.

In my current sandbox project, I've tried to mark the occurrence of an 
interrupt by setting an "debug pin" high. For now, the ISR is empty.

ISR(TIMER2_COMP_vect)
{
    sbi(PORTC,6);
    // ...
    cbi(PORTC,6);
}

With -Os enables, the setup of the port pin is removed! Without optimization 
the pin toggles as expected.

Why does the compiles removes the pin access code? It shouldn't do this, 
because the SFR pointer are declared volatile. Aren't they?

What's my fault?

-- 
Email: Joerg Desch <jd DOT vvd AT web DOT de>






reply via email to

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