[Top][All Lists]

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

Re: [avr-gcc-list] Compile problem

From: Dave Hansen
Subject: Re: [avr-gcc-list] Compile problem
Date: Fri, 07 Oct 2005 16:41:14 -0400

From: Patrick Blanchard <address@hidden>

On Fri, 2005-10-07 at 08:24 -0700, Razvan Turiac wrote:
> I think I have a compile problem. I am using WinAVR
> 20050214 and I've got one problem when compiling some
> code.

OK, but you need to show us the compiler errors received...

You have to scan the attachments. It probably would have been better for the OP to simply include the code in-line with his message.

From what I see, there were no error messages, but it appears the compiler
generated incorrect code.

also, avr/io.h header does not define wait(), nor does avr/delay.h

It was his function, in the attached (to his message) C file.

> The assembler code is all wrong.


It appears the TIFR register is not "acting" volatile. Perhaps it's incorrectly declared in the header?

The wait function is:
void wait(unsigned char time)
        TCCR0 = 0x02;                           //set prescaler to 2

        while(time--)                                   //wait time * 100us 
increments @ XTAL = 16MHz
                TCNT0 = 56;
                TIFR |= (1 << TOV0);

                while(!(TIFR & TOV0));


Note: the "TIFR |= (1 << TOV0);" should more properly be "TIFR = (1 << TOV0);" due to the way TIFR works. But I digress.

The generated code is:
/* prologue: frame size=0 */
/* prologue end (size=0) */
        ldi r25,lo8(2)
        out 83-0x20,r25
        tst r24
        breq .L9
        ldi r24,lo8(56)
        out 82-0x20,r24
        in r24,88-0x20
        ori r24,lo8(1)
        out 88-0x20,r24
        in r24,88-0x20
        rjmp .L4
Note the inner loop is optimized out, apparently on the assumption that the low bit in TIFR has just been set, so it remains set.


reply via email to

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