[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] GCC problem, volatile
From: |
Dave Hylands |
Subject: |
RE: [avr-gcc-list] GCC problem, volatile |
Date: |
Fri, 12 Mar 2004 07:16:15 -0800 |
Hi Andreas,
I believe that you declared the thing that _rx_decode_buffer points to
as being volatile and not the pointer itself.
Read pointer declarations from right to left, and you see that:
static volatile _RX_BUFFER *_rx_decode_buffer;
Is a pointer to a volatile _RX_BUFFER. If you want a volatile pointer
then you need to use:
static _RX_BUFFER * volatile _rx_decode_buffer;
If you also want the contents to be volatile, then you need to use:
static volatile _RX_BUFFER * volatile _rx_decode_buffer;
--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/
> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden On Behalf Of Andreas Becker
> Sent: Friday, March 12, 2004 5:49 AM
> To: address@hidden
> Subject: [avr-gcc-list] GCC problem, volatile
>
>
> Hi All,
>
> I'm using AVR-GCC 3.3.2
> I have got a a problem with the the optimisation the Compiler
> does. The C File:
>
> #include <stdlib.h>
> #include <avr/signal.h>
> #define _RX_BUFFER_SIZE 30
> #define _RX_BUFFER_NUMBER 5
>
> typedef struct
> {
> char buffer[_RX_BUFFER_SIZE];
> char elements;
> } _RX_BUFFER;
>
> static _RX_BUFFER _rx_buffers[_RX_BUFFER_NUMBER];
>
> static volatile _RX_BUFFER *_rx_decode_buffer;
>
> SIGNAL(SIG_ADC)
> {
> _rx_decode_buffer++;
> }
>
> extern int main (void)
> {
> while(1)
> {
> if (_rx_decode_buffer != NULL)
> {
> _rx_decode_buffer = NULL;
> }
> }
> }
>
> If I use Optlevel 0 everything works fine.
>
> ASSEMBLER CODE from the .lss File:
> while(1)
> {
> if (_rx_decode_buffer != NULL)
> d2: 80 91 fb 00 lds r24, 0x00FB
> d6: 90 91 fc 00 lds r25, 0x00FC
> da: 00 97 sbiw r24, 0x00 ; 0
> dc: d1 f3 breq .-12 ; 0xd2
> {
> _rx_decode_buffer = NULL;
> de: 10 92 fc 00 sts 0x00FC, r1
> e2: 10 92 fb 00 sts 0x00FB, r1
> e6: f5 cf rjmp .-22 ; 0xd2
>
>
> If I use Optlevel 1 the Compiler does't reloads the _rx_decode_buffer
> Pointer. Compare the Line 0xdc (Optlevel 0) and Line
> 0xce (Optlevel 1).
> The Destination of the Jump is another.
>
> ASSEMBLER CODE from the .lss File:
> while(1)
> c4: 80 91 fb 00 lds r24, 0x00FB
> c8: 90 91 fc 00 lds r25, 0x00FC
> {
> if (_rx_decode_buffer != NULL)
> cc: 00 97 sbiw r24, 0x00 ; 0
> ce: f1 f3 breq .-4 ; 0xcc
> {
> _rx_decode_buffer = NULL;
> d0: 80 e0 ldi r24, 0x00 ; 0
> d2: 90 e0 ldi r25, 0x00 ; 0
> d4: fb cf rjmp .-10 ; 0xcc
>
>
> Is it my fault, or is there something wrong with the
> Compiler?
>
> --
> Dipl.-Ing.(FH) Andreas Becker
> Entwicklung
>
> dSys e.K.
> Soeflinger Str. 100
> D-89077 Ulm
> Tel: +49.731.151579-1
> Fax: +49.731.151579-9
> web: www.dsys.de
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-> list
>
>
_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list