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

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

[avr-gcc-list] register wierdness?


From: Mark Glines
Subject: [avr-gcc-list] register wierdness?
Date: Sat, 6 Apr 2002 11:37:32 -0800
User-agent: Mutt/1.3.28i

Hi!  I'm still learning, so please be nice if I've made a stupid
mistake...

I seem to have my port-A data-direction register (DDRA)
clobbered when a piece of unrelated (and, for that matter,
uncalled) code is added.  Attached is a C source file which
reproduces the problem.

main() initializes DDRA to 0xff, and then proceeds to write
incrementing values to PORTA to blink some LEDs.  Normally, the
LEDs blink quite brightly. When the unrelated sourceline (in
write_byte()) is compiled in, they do not - somehow DDRA is
being reset to 0, because the blinking is very dim!

There are 3 #ifndef blocks - if you #define any of those three
macros, the code works as I'd expect it to.  Somehow, the
combination of these 3 lines of code causes DDRA to be reset!

I was surprised when I noticed that overflowing the local
variable 'k' was required to reproduce the bug.  It turns out
to be r25 in my resulting assembly, which AFAIK has nothing to
do with DDRA...

UISP does correctly detect the microcontroller I'm using, which
is an AT90S8515-4PI.

Any help would be appreciated... I can't figure out what's going
on here.  I'm not even sure if I'm forgetting to link something
into the executable... =(

To compile and run this source, I did:
avr-gcc -mmcu=at90s8515 -Os -Wall -Wno-char-subscripts -c avrtest.c
avr-objcopy -O srec -S avrtest.o avrtest.srec
uisp -dprog=dapa -v=5 -dvoltage=5 -dno-poll --erase
uisp -dprog=dapa -v=5 -dvoltage=5 -dno-poll --upload if=avrtest.srec

gcc version:
Reading specs from /usr/lib/gcc-lib/avr/3.0.4/specs
Configured with: ../src/configure -v --enable-languages=c --prefix=/usr 
--infodir=/usr/share/info --mandir=/usr/share/man --enable-shared --with-gnu-as 
--with-gnu-ld --with-system-zlib --enable-long-long --enable-nls 
--without-included-gettext --disable-checking --build=i386-linux 
--host=i386-linux --target=avr
Thread model: single
gcc version 3.0.4

binutils version:
GNU objcopy 2.12.90.0.1 20020307
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.

uisp version:
uisp version 20010701
(c) 1997-1999 Uros Platise, 2000-2001 Marek Michalkiewicz

Thanks,
Mark

Attachment: avrtest.c
Description: Text Data


reply via email to

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