[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] BUG? Comparing of words error.
From: |
Francisco Silva |
Subject: |
Re: [avr-gcc-list] BUG? Comparing of words error. |
Date: |
Wed, 18 Jan 2006 16:57:50 -0200 |
2006/1/18, Flemming Steffensen (sent by Nabble.com) <address@hidden>:
> Hi,
>
> This is my first post to this forum. I'm not even sure it's the right place
> to post, but I think so.
>
> I'm trying this with an ATmega8, with a 500Hz oscillator connected at INT0,
> using WinAVR (avr-gcc 3.4.3).
>
> I noticed the problem using this code:
> ------------
>
> unsigned short RotCount;
>
> SIGNAL(SIG_INTERRUPT0){
> RotCount++;
> }
>
> void test(void){
> while (1){
> RotCount = 0;
> while (RotCount < 1000) {}
> RotCount = 0;
> while (RotCount < 2000) {}
> }
> }
> ------------
>
> My problem is that the two inner whiles sometimes exists prematurly.
> The one counting to 1000 sometimes exists at 768.
> The one counting to 2000 sometimes exists at 1792.
> Sometimes, means once every 5 to 20 loops.
>
> Looking at the numbers bineary, seems to give a pointer to an explanation;
>
> 0000 0011 1110 1000 = 1000
> 0000 0011 0000 0000 = 0768
>
> 0000 0111 1101 0000 = 2000
> 0000 0111 0000 0000 = 1792
>
> As can be seen, it appears that the while() exists when the high byte of the
> two words matches.
>
> I didn't check the assembler output yet to see what might be happening, but
> thought I'd ask you guys first.
>
> Any idear what might be at play here?
>
> Best regards,
> Flemming
>
This FAQ number 1. See:
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_volatile
Regards,
--
Francisco
- [avr-gcc-list] BUG? Comparing of words error., Flemming Steffensen (sent by Nabble.com), 2006/01/18
- Re: [avr-gcc-list] BUG? Comparing of words error.,
Francisco Silva <=
- RE: [avr-gcc-list] BUG? Comparing of words error., Dave Hansen, 2006/01/18
- Re: [avr-gcc-list] BUG? Comparing of words error., Dave Hylands, 2006/01/18
- Re: [avr-gcc-list] BUG? Comparing of words error., Albert Andras, 2006/01/18
- Re: [avr-gcc-list] BUG? Comparing of words error., Graham Davies, 2006/01/18
- Re: [avr-gcc-list] BUG? Comparing of words error., Markus Baertschi, 2006/01/18
- [avr-gcc-list] Re: BUG? Comparing of words error., Volkmar Dierkes, 2006/01/18
- Re: [avr-gcc-list] BUG? Comparing of words error., Dimitar Dimitrov, 2006/01/18