Nasty ADC header file bug 32A4U

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Took me hours and hours to find this, so I figured I'd post it. The iox32a4u.h file has an incomplete definition for ADC_CH_t, so it appears 7 bytes long instead of 8, causing ADC_t's CH1, CH2 and CH3 to map to the wrong memory locations. Probably no one noticed because CH0 was in the correct spot.

I added

register8_t reserved_0x7;

to the end of the struct definition to fix the problem.

I haven't checked the other header files, but they also may be faulty. I didn't know where to report this (it's not an ASF bug, for once ;)), so hopefully someone with the power to fix it will read this thread and take care of it.

Jeff Nichols

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My *.h file for it is correct at 8 bytes wide , since there's a 16 bit register in there ( Result ), then scan and finally a reserved location .

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is what mine looked like before I made any changes:

/* ADC Channel */
typedef struct ADC_CH_struct
{
    register8_t CTRL;  /* Control Register */
    register8_t MUXCTRL;  /* MUX Control */
    register8_t INTCTRL;  /* Channel Interrupt Control Register */
    register8_t INTFLAGS;  /* Interrupt Flags */
    _WORDREGISTER(RES);  /* Channel Result */
    register8_t SCAN;  /* Input Channel Scan */
} ADC_CH_t;

Perhaps you have a different version than I do? I looked at the release notes for Atmel Studio 6 but didn't see any mention of it. I guess I'll have to download it and see.

Jeff Nichols

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got it from ASF 2.9.0 xmega->util->headers->GCC -> file .

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just checked the AVR Toolchain installed with Studio 5.1 and it has this:

/* ADC Channel */
typedef struct ADC_CH_struct
{
    register8_t CTRL;  /* Control Register */
    register8_t MUXCTRL;  /* MUX Control */
    register8_t INTCTRL;  /* Channel Interrupt Control Register */
    register8_t INTFLAGS;  /* Interrupt Flags */
    _WORDREGISTER(RES);  /* Channel Result */
    register8_t SCAN;  /* Input Channel Scan */
    register8_t reserved_0x07;
} ADC_CH_t;

That would appear to have the additional padding so it looks like it is fixed already. What version of avr-libc do you have? Mine is:

C:\Program Files\Atmel\AVR Studio 5.1\extensions\Atmel\AVRGCC\3.3.1\AVRToolchain\avr\include\avr>type version.h

#ifndef _AVR_VERSION_H_
#define _AVR_VERSION_H_

/** \ingroup avr_version
    String literal representation of the current library version. */
#define __AVR_LIBC_VERSION_STRING__ "1.7.1"

/** \ingroup avr_version
    Numerical representation of the current library version.

    In the numerical representation, the major number is multiplied by
    10000, the minor number by 100, and all three parts are then
    added.  It is intented to provide a monotonically increasing
    numerical value that can easily be used in numerical checks.
 */
#define __AVR_LIBC_VERSION__        10701UL

/** \ingroup avr_version
    String literal representation of the release date. */
#define __AVR_LIBC_DATE_STRING__    "20110216"

/** \ingroup avr_version
    Numerical representation of the release date. */
#define __AVR_LIBC_DATE_            20110216UL

/** \ingroup avr_version
    Library major version number. */
#define __AVR_LIBC_MAJOR__          1

/** \ingroup avr_version
    Library minor version number. */
#define __AVR_LIBC_MINOR__          7

/** \ingroup avr_version
    Library revision number. */
#define __AVR_LIBC_REVISION__       1

#endif /* _AVR_VERSION_H_ */

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ALM reports this as fixed as of 02/Nov/11, which means AS5.1 and AS6 should have corrected definitions for all devices.

- Dean :twisted:

PS: Am I useful yet?

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I was using AVR Studio 5.0. I downloaded Atmel Studio 6 overnight and I see the problem is fixed there.

Is there a complete list of fixes for things somewhere so I don't have to go through this again?

Jeff Nichols

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Is there a complete list of fixes for things somewhere so I don't have to go through this again?

If you have a problem in Vn of any software and it's the case that there's at least a Vn+1 available would the first thing you try not always be to upgrade to the later and see if it fixes it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not when Vn takes 2*n hours to download. :)

Jeff Nichols