ASF ATMega IOPORT services and drivers fail for ATMega64/128

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Moved from thread referencing posts 4, 5, and 8.  The ATMega64/128 chips have a stray IO register definition that causes the ASF IOPORT routines to fail.

 

clawson wrote:

 

OH and there's a "trick" you can use on AVRs that works for almost every port of every AVR. The registers are always in the order:

 

PIN

DDR

PORT

 

So you only need be given one address. For example if you are given DDRB then the PIN register is addr-1 and the PORT register is addr+1 though I guess the user is most likely to want to use:

Led red(&PORTB);

in which case DDR is addr-1 and PIN is addr-2. The point being they don't have to pass all of PORTB, DDRB, PINB.

 

No doubt someone will be along in a minute to point out some example of an AVR/port where this three address sequence is broken! ;-)

snigelen wrote:

 

clawson wrote:

No doubt someone will be along in a minute to point out some example of an AVR/port where this three address sequence is broken! ;-)

ATMega64/128 PORTF.

(three minutes smiley)

A follow up to my earlier post regarding this breaking my IOPorts class.  This is something Atmel needs to know about.

 

The latest, and surely some previous, ASF code for the IOPORT services and drivers for the ATMega series in ASF/common/services/ioport/ioport.h and ASF/common/services/ioport/mega/ioport.h are written based on that same assumption.  Any ATMega64/128 projects that wish to use this ASF code will fail, tested and verified.

 

This is the struct in the file ASF/common/services/ioport/mega/ioport.h

/* I/O Ports */
typedef struct PORT_struct {
 volatile uint8_t PINCRL;         /* I/O Port PIN DATA READ ONLY */
 volatile uint8_t DIR;            /* I/O Port Data Direction Set */
 volatile uint8_t PORTDATA;       /* I/O Port DATA register */
} PORT_t;

I wonder how many other ATMega chips have a stray port define?

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Tue. Jan 27, 2015 - 02:40 AM