avr-gcc-list
[Top][All Lists]
Advanced

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

RE: [avr-gcc-list] why does this not work?!?


From: Ben Mann
Subject: RE: [avr-gcc-list] why does this not work?!?
Date: Wed, 8 Jun 2005 09:07:49 +0800

I added
avr-objdump -h -S qwe.ELF >  qwe.LST
to the build sequence, and the LST shows too few jump vectors.
Adding -mmcu=atmega128 to the linker - 2nd avr-gcc line - seems to fix this.
Ben

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of Torsten
Mohr
Sent: Wednesday, 8 June 2005 8:11 AM
To: address@hidden
Subject: [avr-gcc-list] why does this not work?!?

Hi,

i use binutils-2.15, gcc-3.4.4 and avr-libc-1.2.3

I tracked down a certain problem to the attached example code.
There are two switches on PB2 and PB3 and there are two LEDs
on PB4 and PB5.
Sometimes the code after the simple for() is reached (what i expect, "it 
works"), sometimes not.  I see this on the patterns the LEDs show.

- If i use "i" as a global variable, the for() does not seem to exit.
- If i use "i" as the local variable, defined in main() it works.
- If i use "i" as a global variable and set the limit in the for() from 2 to
1
it works.  That way the exit condition for for() is met immediately.

This must be some really stupid bug i wrote, but i don't see it at the
moment.

It would be great if anybody could give me some hints on this one.


Best regards,
Torsten.


I compile with these commands:

avr-gcc -I /opt/avr/avr/include/avr -mmcu=atmega128 -Wa,-ahnls=qwe.s -c \
qwe.c -O0 -oqwe.o
avr-gcc -I /opt/avr/avr/include/avr -o qwe.elf qwe.o
avr-objcopy -O srec qwe.elf qwe.hex


------------------- example code:
#include <io.h>
#include <wdt.h>
#include <interrupt.h>

#define L1 0x10
#define TMASK 0x0c
#define LMASK 0x30

volatile unsigned int i;


int main(void) {
  //volatile unsigned int i;

  cli();
  wdt_disable();

  DDRB = LMASK;
  PORTB = TMASK | L1;

  for(i = 0; i < 2; i++);

  PORTB = TMASK | LMASK;

  do {
    i++;
  } while(1);

  return 0;
}


_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list







reply via email to

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