bugAVR C Runtime Library - Bugs: bug #17561, headers returning PORTx, PINx and...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #17561: headers returning PORTx, PINx and DDRx incorrectly for Mega168

Submitter:  Scott Price <scottprice>
Submitted:  Tue 29 Aug 2006 01:17:09 AM UTC
   
 
Category:  Header Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Invalid Assigned to:  joerg_wunsch
Percent Complete:  0% Open/Closed:  Closed
Release:  None Fixed Release:  None

Tue 29 Aug 2006 01:05:23 PM UTC, comment #4: 

You are right.  Things are a lot clearer this morning.

Sorry for the bogus bug.

Scott Price <scottprice>
Tue 29 Aug 2006 05:02:08 AM UTC, comment #3: 

Sorry, but that's exactly the IO addresses these ports are
supposed to live at.  You've been confusing IO addresses and
memory (MMIO) addresses.  For example, PINB is at IO address
0x03 (to be used in IN or OUT instructions), or at memory
address 0x23 (to be used in LDS or STS instructions).

Joerg Wunsch <joerg_wunsch>
Group administrator
Tue 29 Aug 2006 03:24:18 AM UTC, comment #2: 


Okay, it seems to be that anything that uses _SFR_IO8 is wrong on the Mega168.  I will see if I can figure out why.

I must be really tired.  I meant to type that it works if I use _SFR_IO8(0x23) etc.

Sorry for all the extra posts.  Some days I feel brain dead.  ;)

Scott Price <scottprice>
Tue 29 Aug 2006 01:19:40 AM UTC, comment #1: 

Sorry, I wasn't very clear in one part. 

My program works if I use the direct addresses for the ports, but not if I use the name.  Also,

Other registers seem to work correctly.  I will dig into this more to see if other registers are failing also.  These are just the ones I have noticed.

Scott Price <scottprice>
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:

00000000 <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


Scott Price <scottprice>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Follow 4 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-08-29 joerg_wunsch StatusNeed Info Invalid
    Open/ClosedOpen Closed
2006-08-29 joerg_wunsch StatusNone Need Info
    Assigned toNone joerg_wunsch

Back to the top

Powered by Savane 3.13-caa5.
Corresponding source code