4 posts / 0 new
Author
Message

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

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:

```#if (!XMEGA_E)
/* Negative input multiplexer selection without gain */
{
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_INTGND_gc = (0x07<<0),  /* Internal ground */

/* Negative input multiplexer selection with gain */
{
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 */
#endif
```

iox128a1.h

```/* Negative input multiplexer selection when gain on 4 MSB pins */
{
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 */

/* Negative input multiplexer selection when gain on 4 LSB pins */
{
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 */
```

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

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):

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 (Version: 7.0.1652) on Windows 10

Xplained/Pro/Mini Boards mostly

Last Edited: Sat. Oct 21, 2017 - 09:01 PM

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 */
{
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_INTGND_gc = (0x07<<0),  /* Internal ground */

/* Negative input multiplexer selection with gain */
{
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 */
#endif```

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

Thanks!