AVR XMEGA ADC Compilefehler

Gast #1929446
Lesenswert?

nabend,

kann mir jemand sagen warum ich hier:
1
#include <avr/io.h>
2
#include "adc.h"
3

4

5

6
void init_adc(void)
7
{
8

9
 ADCB.CTRLA = ADC_ENABLE_bm; // Enable ADCB
10
 ADCB.CTRLB = ADC_RESOLUTION_8BIT_gc; // 8Bit Resolution
11
 ADCB.REFCTRL = ADC_REFSEL_AREFB_gc; // External Referance on AREFB 
12
 ADCB.PRESCALER = ADC_PRESCALER_DIV512_gc; // Prescaler = 512
13
 ADCB.CH0.CTRL = ADC_CH_INPUTMODE_SINGLEENDED_gc;   // Singleended
14

15
}
16

17

18

19
unsigned int read_adc_channel(unsigned char channel)
20
{
21

22
 ADCB.CH0.MUXCTRL = channel << 3;
23

24
 ADCB.CH0.CTRL |= ADC_CH_START_bm; 
25
 //while(!ADCB.CH0.INTFLAGS);
26
 while(((ADCB.CH0.INTFLAGS & ADC_CH_CHIF_bm) == 0x00));
27

28
 return ADCB.CH0RESH;
29

30
}

diese Fehler bekomme:

Build started 8.11.2010 at 20:08:12
avr-gcc  -mmcu=atxmega128a1 -Wall -gdwarf-2 -std=gnu99 
-DF_CPU=32000000UL -O1 -funsigned-char -funsigned-bitfields 
-fpack-struct -fshort-enums -MD -MP -MT adc.o -MF dep/adc.o.d  -c 
../adc.c
../adc.c: In function 'init_adc':
../adc.c:13: error: expected identifier before numeric constant
../adc.c: In function 'read_adc_channel':
../adc.c:22: error: expected identifier before numeric constant
../adc.c:24: error: expected identifier before numeric constant
../adc.c:26: error: expected identifier before numeric constant
make: *** [adc.o] Error 1
Build failed with 4 errors and 0 warnings...
Gast #1929614
Lesenswert?

Nein geht nicht. Das Problem ist ja in all diesen zeilen vorhanden. Es 
hat irgendwie etwas mit dem .CH0 zutun allerdings frag ich mich warum? 
Weil ansich stimmt das ja also bei anderen geht es nur bei mir nicht.

 ADCB.CH0.CTRL = ADC_CH_INPUTMODE_SINGLEENDED_gc;

 ADCB.CH0.MUXCTRL = (channel << 3);

 ADCB.CH0.CTRL |= ADC_CH_START_bm;

 while(((ADCB.CH0.INTFLAGS & ADC_CH_CHIF_bm) == 0x00));

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren