[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Extremly confusing behaviour... (Suspect compiler?, o
From: |
Mike Panetta |
Subject: |
Re: [avr-gcc-list] Extremly confusing behaviour... (Suspect compiler?, optimization error?) |
Date: |
14 May 2003 13:35:20 -0400 |
Please explain to me why the return value needs to be declared
volatile? That makes no sense, and even more thats not what the FAQ
suggests. It suggests to use volatile when you are inspecting (using)
variables that are updated in an ISR. That is not the case here. There
are NO ISR's involved in this code.
As for assembly output, see the attached listing:
do
{
delay = 1000;
1c4: 88 ee ldi r24, 0xE8 ; 232
1c6: 93 e0 ldi r25, 0x03 ; 3
1c8: a0 e0 ldi r26, 0x00 ; 0
1ca: b0 e0 ldi r27, 0x00 ; 0
1cc: 89 83 std Y+1, r24 ; 0x01
1ce: 9a 83 std Y+2, r25 ; 0x02
1d0: ab 83 std Y+3, r26 ; 0x03
1d2: bc 83 std Y+4, r27 ; 0x04
while (delay--);
1d4: 89 81 ldd r24, Y+1 ; 0x01
1d6: 9a 81 ldd r25, Y+2 ; 0x02
1d8: ab 81 ldd r26, Y+3 ; 0x03
1da: bc 81 ldd r27, Y+4 ; 0x04
1dc: 01 97 sbiw r24, 0x01 ; 1
1de: a1 09 sbc r26, r1
1e0: b1 09 sbc r27, r1
1e2: 89 83 std Y+1, r24 ; 0x01
1e4: 9a 83 std Y+2, r25 ; 0x02
1e6: ab 83 std Y+3, r26 ; 0x03
1e8: bc 83 std Y+4, r27 ; 0x04
1ea: 89 81 ldd r24, Y+1 ; 0x01
1ec: 9a 81 ldd r25, Y+2 ; 0x02
1ee: ab 81 ldd r26, Y+3 ; 0x03
1f0: bc 81 ldd r27, Y+4 ; 0x04
1f2: 8f 5f subi r24, 0xFF ; 255
1f4: 9f 4f sbci r25, 0xFF ; 255
1f6: af 4f sbci r26, 0xFF ; 255
1f8: bf 4f sbci r27, 0xFF ; 255
1fa: 61 f7 brne .-40 ; 0x1d4
PORTA |= _BV (PA1);
1fc: d9 9a sbi 0x1b, 1 ; 27
retval = srf08_read(1, 0, pingdata, 2);
1fe: 65 e0 ldi r22, 0x05 ; 5
200: c6 2e mov r12, r22
202: d1 2c mov r13, r1
204: cc 0e add r12, r28
206: dd 1e adc r13, r29
208: 02 e0 ldi r16, 0x02 ; 2
20a: 10 e0 ldi r17, 0x00 ; 0
20c: 20 e0 ldi r18, 0x00 ; 0
20e: 30 e0 ldi r19, 0x00 ; 0
210: a6 01 movw r20, r12
212: 60 e0 ldi r22, 0x00 ; 0
214: 81 e0 ldi r24, 0x01 ; 1
216: 0e 94 9c 04 call 0x938
PORTA &= ~(_BV(PA1));
21a: d9 98 cbi 0x1b, 1 ; 27
PORTB = retval;
21c: 68 bb out 0x18, r22 ; 24
} while (retval != 2);
21e: 60 17 cp r22, r16
220: 71 07 cpc r23, r17
222: 82 07 cpc r24, r18
224: 93 07 cpc r25, r19
226: 71 f6 brne .-100 ; 0x1c4
On Wed, 2003-05-14 at 12:42, Keith Gudger wrote:
> You say you read the FAQ, but I see that your return value is still not
> declared volatile.
>
> If you would like us to help you, you must send us the assembly language
> produced for this loop.
>
> Try avr-gcc with the -S option to give you the assembly output.
>
> Keith
>
> On 14 May 2003, Mike Panetta wrote:
>
> > A: I already did that.
> > B: I am not using the variables you mentioned yet, and they are not
> > involved in the code that I am having problems with.
> >
> > I have read the FAQ (many times, its even where I got the basis for my
> > i2c code for this project from), and I know what volatile is for.
> >
> > The problem I am having is GCC is seemingly IGNORING the return value of
> > a function I am calling. Why is it doing that? That is what I need
> > help with.
> >
> > Thanks,
> > Mike
> >
> > Wondering if anyone is actually reading his emails before pushing him at
> > the FAQ...
> >
> > On Wed, 2003-05-14 at 12:17, Joerg Wunsch wrote:
> > > Mike Panetta <address@hidden> wrote:
> > >
> > > > If someone could help me understand my error, I would be greatly
> > > > appreciated.
> > >
> > > Why didn't you follow Keith's advise, and looked into the FAQ? You'll
> > > certainly want to declare at least one of your variables to be
> > > "volatile", namely SPIByteCounter, but maybe more -- please try to
> > > read and understand the FAQ. It would have saved you hours.
> > >
> > > In case you don't know:
> > >
> > > http://savannah.nongnu.org/download/avr-libc/doc/avr-libc-user-manual/FAQ.html
> > >
> > > --
> > > J"org Wunsch Unix support
> > > engineer
> > > address@hidden http://www.interface-systems.de/~j/
> > >
> > > _______________________________________________
> > > 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
> >
> >
> >
>
- [avr-gcc-list] Extremly confusing behaviour..., Mike Panetta, 2003/05/13
- Re: [avr-gcc-list] Extremly confusing behaviour..., Keith Gudger, 2003/05/13
- Re: [avr-gcc-list] Extremly confusing behaviour... (Suspect compiler?, optimization error?), Mike Panetta, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (Suspect compiler?, optimization error?), Joerg Wunsch, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (Suspect compiler?, optimization error?), Mike Panetta, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (Suspect compiler?, optimization error?), Keith Gudger, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (Suspect compiler?, optimization error?),
Mike Panetta <=
- Re: [avr-gcc-list] Extremly confusing behaviour... (Suspectcompiler?, optimization error?), Larry Barello, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (Suspectcompiler?, optimization error?), Mike Panetta, 2003/05/14
- RE: [avr-gcc-list] Extremely confusing behaviour... (Suspectcompiler?,optimization error?), Ralph Mason, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (Suspect compiler?, optimization error?), Joerg Wunsch, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (more detailed explanation of error, believe me its not a volatile thing), Mike Panetta, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (more detailedexplanation of error, believe me its not a volatile thing), Larry Barello, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (more detailedexplanation of error, believe me its not a volatile thing), Mike Panetta, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (more detailed explanation of error, believe me its not a volatile thing), E. Weddington, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (more detailed explanation of error, believe me its not a volatile thing), Mike Panetta, 2003/05/14
- Re: [avr-gcc-list] Extremly confusing behaviour... (more detailedexplanation of error, believe me its not a volatile thing), David Brown, 2003/05/16