Tue 29 Aug 2006 01:17:09 AM UTC, original submission:
If I compile this:
void
test(void) {
PINB = 0;
PORTB = 0;
DDRB = 0;
PINC = 0;
PORTC = 0;
DDRC = 0;
PIND = 0;
PORTD = 0;
DDRD = 0;
}
Using this command line:
avr-gcc -mmcu=atmega168 -D_01_ -Os -Wall -fpack-struct -fdollars-in-identifiers -ffunction-sections -DVERSION=00 -DVERSIONSMALL=00 -DVERSIONTINY=04 -c test.c -o test.o
I get:
- <test>:
0: 13 b8 out 0x03, r1 ; 3
2: 15 b8 out 0x05, r1 ; 5
4: 14 b8 out 0x04, r1 ; 4
6: 16 b8 out 0x06, r1 ; 6
8: 18 b8 out 0x08, r1 ; 8
a: 17 b8 out 0x07, r1 ; 7
c: 19 b8 out 0x09, r1 ; 9
e: 1b b8 out 0x0b, r1 ; 11
10: 1a b8 out 0x0a, r1 ; 10
12: 08 95 ret
According to the datasheet those addresses should be 0x23, 0x24, 0x25... I get absolutely nothing when I try to use PORTB, etc, but it works if I use the direct address in the datashet.
It seems to be something in sfr_defs.h, but I am having trouble following that file. I will keep looking at it to see if I can find the problem.
My compiler and assembler are:
[prices@thing2 /usr/avr/include/avr]% avr-gcc --version
avr-gcc (GCC) 4.1.1 (Gentoo 4.1.1)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[prices@thing2 /usr/avr/include/avr]% avr-as --version
GNU assembler 2.17.50.0.3 20060715
Copyright 2005 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.
This assembler was configured for a target of `avr'.
I am using AVR-libc version 1.4.4
|