[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Strange issues with 16-bit values
From: |
Brian Neltner |
Subject: |
Re: [avr-gcc-list] Strange issues with 16-bit values |
Date: |
Fri, 07 Nov 2008 12:47:17 -0500 |
Sorry, typo. I was giving example code, not a literal copy of my source.
I haven't tried looking at the assembly code (I'm not very familiar with
AVR style assembler), but here is the makefile I am using to compile, as
well as the actual original source file (which compiled previously and
behaved as expected) and benc.c library which is used by
ultraluminous_v6.c.
I compile with make clean; make. With -O3 the code works, with -O
anything else, it fails, and commenting out the code and inserting
breakpoints showed that it's failing as soon as it's doing things with
the long variable in the delay function (which I turned into a for loop
with nop's to isolate the problem).
The chip is still running, because the way I actually inserted the
breakpoint was to set the PWM value for one of my outputs to 0x20 out of
0xFF. The pin is still PWMing, so I know that the interrupts are still
being called -- the main loop just stops progressing (so, not a watchdog
issue, or oscillator problem).
The code had the same behavior on two different boards, so I don't think
it is a hardware failure. I am using the ATmega1281
On Fri, 2008-11-07 at 08:37 +0100, Josef Eisl wrote:
> Hello,
>
> Brian Neltner wrote:
> > Very oddly, the code runs when I compile it with -O3, but not with any
> > other optimization level.
> >> This works:
> >>
> >> int main(void) {
> >> uint8_t i;
> >> for(i=1;i<0xFF;i++) asm volatile("nop/n/t");
> >> PORTA=0x01;
> >> while(1);
> >> }
>
> You are using /n and /t instead of \n \t (backslash-slash). Anyway I
> don't think this is the problem in your case. Could you please give us
> the avr-gcc command with all parameters and compiler flags you use to
> compile the code.
>
> Which target device are you using? Have you already took a look into the
> dissembled code (using avr-objdump)? May that will give you some hints.
>
> BR,
> Josef
>
--
Brian Neltner
Makefile
Description: Text Data
benc.c
Description: Text Data
ultraluminous_v6.c
Description: Text Data
- [avr-gcc-list] Strange issues with 16-bit values, Brian Neltner, 2008/11/07
- Re: [avr-gcc-list] Strange issues with 16-bit values, Brian Neltner, 2008/11/07
- Re: [avr-gcc-list] Strange issues with 16-bit values, David Brown, 2008/11/07
- Re: [avr-gcc-list] Strange issues with 16-bit values, Josef Eisl, 2008/11/07
- Re: [avr-gcc-list] Strange issues with 16-bit values, Bob Paddock, 2008/11/11
- Re: [avr-gcc-list] Strange issues with 16-bit values, Brian Neltner, 2008/11/11
- Re: [avr-gcc-list] Strange issues with 16-bit values, Pink Boy, 2008/11/11
Re: [avr-gcc-list] Strange issues with 16-bit values, Bernard Fouché, 2008/11/07