XMEGA128A1 - ASF ADC, adc.h & iox128a1.h: Conflicting types for ADC_CH_MUXNEGL_t

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

Hello, 

 

I am working with a XMEGA A1 XPlained board, which has a XMEGA128A1 device. I have been successfully using ASF (which has helped a lot to get stuff working). But when I try to setup ADC by

 

1) ASF Wizard, apply ADC (driver)

2) Write main.c & other files 

3) Build => 

 

Message previous declaration of 'ADC_CH_MUXNEGH_t' was here C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\XMEGAA_DFP\1.1.68\include\avr\iox128a1.h 1312

Message previous declaration of 'ADC_CH_MUXNEGL_t' was here C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\XMEGAA_DFP\1.1.68\include\avr\iox128a1.h 1321

Error conflicting types for 'ADC_CH_MUXNEGL_t'  C:\Users\tapio\Projects\Electronics\LoadCell\AStudio\XLOADCELL3\XLOADCELL3\src\ASF\xmega\drivers\adc\adc.h 98

Error conflicting types for 'ADC_CH_MUXNEGH_t' C:\Users\tapio\Projects\Electronics\LoadCell\AStudio\XLOADCELL3\XLOADCELL3\src\ASF\xmega\drivers\adc\adc.h 109

 

Why are the ASF files conflicting with XMEGAA_DFP(?) files? I have been trying to understand but to no avail so far. 

 

The conflicting parts in these files read: 

 

adc.h

#if (!XMEGA_E)
/* Negative input multiplexer selection without gain */
typedef enum ADC_CH_MUXNEG_MODE10_enum
{
    ADC_CH_MUXNEG_MODE10_PIN0_gc = (0x00<<0),  /* Input pin 0 */
    ADC_CH_MUXNEG_MODE10_PIN1_gc = (0x01<<0),  /* Input pin 1 */
    ADC_CH_MUXNEG_MODE10_PIN2_gc = (0x02<<0),  /* Input pin 2 */
    ADC_CH_MUXNEG_MODE10_PIN3_gc = (0x03<<0),  /* Input pin 3 */
    ADC_CH_MUXNEG_MODE10_GND_gc = (0x05<<0),  /* PAD ground */
    ADC_CH_MUXNEG_MODE10_INTGND_gc = (0x07<<0),  /* Internal ground */
} ADC_CH_MUXNEGL_t;

/* Negative input multiplexer selection with gain */
typedef enum ADC_CH_MUXNEG_MODE11_enum
{
    ADC_CH_MUXNEG_MODE11_PIN4_gc = (0x00<<0),  /* Input pin 4 */
    ADC_CH_MUXNEG_MODE11_PIN5_gc = (0x01<<0),  /* Input pin 5 */
    ADC_CH_MUXNEG_MODE11_PIN6_gc = (0x02<<0),  /* Input pin 6 */
    ADC_CH_MUXNEG_MODE11_PIN7_gc = (0x03<<0),  /* Input pin 7 */
    ADC_CH_MUXNEG_MODE11_INTGND_gc = (0x04<<0),  /* Internal ground */
    ADC_CH_MUXNEG_MODE11_GND_gc = (0x07<<0),  /* PAD ground */
} ADC_CH_MUXNEGH_t;
#endif

 

iox128a1.h

 

/* Negative input multiplexer selection when gain on 4 MSB pins */
typedef enum ADC_CH_MUXNEGH_enum
{
    ADC_CH_MUXNEGH_PIN4_gc = (0x00<<0),  /* Input pin 4 */
    ADC_CH_MUXNEGH_PIN5_gc = (0x01<<0),  /* Input pin 5 */
    ADC_CH_MUXNEGH_PIN6_gc = (0x02<<0),  /* Input pin 6 */
    ADC_CH_MUXNEGH_PIN7_gc = (0x03<<0),  /* Input pin 7 */
} ADC_CH_MUXNEGH_t;

/* Negative input multiplexer selection when gain on 4 LSB pins */
typedef enum ADC_CH_MUXNEGL_enum
{
    ADC_CH_MUXNEGL_PIN0_gc = (0x00<<0),  /* Input pin 0 */
    ADC_CH_MUXNEGL_PIN1_gc = (0x01<<0),  /* Input pin 1 */
    ADC_CH_MUXNEGL_PIN2_gc = (0x02<<0),  /* Input pin 2 */
    ADC_CH_MUXNEGL_PIN3_gc = (0x03<<0),  /* Input pin 3 */
} ADC_CH_MUXNEGL_t;

I have also included full files as attachments. The adc.h file has unusual structure, it has some code with comments like 

 

/* Fix header error in ADC_CH_t structure about missing SCAN register */

 

/* Fix header error */

 

and the conflicting part is included with this "add-on" part. Then there are normal-start-of-configuration-file comments. Which of course makes me think if the fix indeed is the problem?

 

I would be very interested to understand what is going on here and the reason for conflict.

 

 

 

Attachment(s): 

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

Typically, all the SFRs (Special Function Registers) are setup in the device-specific header file (iox128a1.h), not in the peripheral-specific one.  From what I can gather, on occasion they put support for new devices in the peripheral-specific header (adc.h).  When I first tried to build a project with the ATmega328PB, avr/io.h declared it an unknown device!  After looking at the two files again, I'm guessing the XMEGA E has the ADC SFRs defined in adc.h.  In that case, the top line in the first file would need to have the bang removed.  Couldn't be a typo, could it?

 

#if (!XMEGA_E)

// becomes

#if (XMEGA_E)

 

edit: replaced part I accidentally deleted...

Greg Muth

Portland, OR, US

Atmel Studio 7.0 on Windows 10

Xplained/Pro/Mini Boards mostly

 

 

Last Edited: Sat. Oct 21, 2017 - 09:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for explanation. I took another look into this and fixed it by changing the part in adc.h

 

#if (!XMEGA_E)
/* Negative input multiplexer selection without gain */
typedef enum ADC_CH_MUXNEG_MODE10_enum
{
    ADC_CH_MUXNEG_MODE10_PIN0_gc = (0x00<<0),  /* Input pin 0 */
    ADC_CH_MUXNEG_MODE10_PIN1_gc = (0x01<<0),  /* Input pin 1 */
    ADC_CH_MUXNEG_MODE10_PIN2_gc = (0x02<<0),  /* Input pin 2 */
    ADC_CH_MUXNEG_MODE10_PIN3_gc = (0x03<<0),  /* Input pin 3 */
    ADC_CH_MUXNEG_MODE10_GND_gc = (0x05<<0),  /* PAD ground */
    ADC_CH_MUXNEG_MODE10_INTGND_gc = (0x07<<0),  /* Internal ground */
} ADC_CH_MUXNEG_MODE10_t;

/* Negative input multiplexer selection with gain */
typedef enum ADC_CH_MUXNEG_MODE11_enum
{
    ADC_CH_MUXNEG_MODE11_PIN4_gc = (0x00<<0),  /* Input pin 4 */
    ADC_CH_MUXNEG_MODE11_PIN5_gc = (0x01<<0),  /* Input pin 5 */
    ADC_CH_MUXNEG_MODE11_PIN6_gc = (0x02<<0),  /* Input pin 6 */
    ADC_CH_MUXNEG_MODE11_PIN7_gc = (0x03<<0),  /* Input pin 7 */
    ADC_CH_MUXNEG_MODE11_INTGND_gc = (0x04<<0),  /* Internal ground */
    ADC_CH_MUXNEG_MODE11_GND_gc = (0x07<<0),  /* PAD ground */
} ADC_CH_MUXNEG_MODE11_t;
#endif

 

i.e making things symmetric. But your fix is probably better. 

 

Thanks!

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

Reported as ASFP-6440

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)