2015-05-25 11:51 AM
Hallo,
I try to read the ADC but get allways 0 als result :-( Does anybody have an Idea whats wrong?GPIO_Clk_Enable(@GPIOA_BASE);
GPIO_Config(@GPIOA_BASE,_GPIO_PINMASK_All,_GPIO_CFG_MODE_ANALOG or _GPIO_CFG_PULL_NO);
ADON_bit :=1; // ADC on/off
CONT_bit :=1; // use continius measurement
ADC1_CR1 := %00000010000000000000000000000000;
ADC1_CR2 := %01000000000000000000000000000011;
ADC1_SQR1 := %00000000000000000000000000000000;
ADC1_SQR3 := %00000000000000000000000000000000;
//ADC1_SMPR1 := %0000000000000000000000000000000;
//ADC1_SMPR2 := %0000000000000000000000000000000;
SWSTART_bit := 1; //start conversion
while EOC1_bit = 1 DO nop;value := ADC1_DR;
2015-05-25 12:52 PM
Did you turn on the ADC peripheral clock ?
Cheers, Hal2015-05-25 10:40 PM
2015-05-26 03:09 AM
2015-05-26 03:14 AM
is there any Diagram where I can see, what and when I have to set for using Perepheri?!?
Perhaps in the ?
2015-05-26 03:49 AM
2015-05-26 04:32 AM
no, there I can't see something like this
Of course it's there. Nobody said it will leap to your eye immediately. You will have to read the document. And if you plan to spend some more time on this MCU, you will need it anyway.
2015-05-26 05:36 AM
yes, I think with Xmega its much easier, because more hrlp from the community :(
Now I have this, but it run about 1 to 5 seconds then the ADC freeze... And I can't see anything like I asked into the Reference!!!Startet once
ADC1EN_bit :=1;
ADON_bit :=1; // ADC on/off
delay_ms(100);
this is into the loop
CONT_bit :=1; // use continius measurement
ADC1_CR2 := %00000000000000000000000100000011;
ADC_CCR := %00000000000000110000111100000000;
ADC1_SQR3 := %00000000000000000000000000000001;
ADC1_CR2 := %01000000000000000000000000000011;
delay_ms(1);
while EOC1_bit = 0 DO nop;
value := ADC1_DR;
2015-05-26 06:30 AM
Procedure ADC_Init;
Begin
ADON_bit :=1; // ADC on/off
CONT_bit :=1; // use continius measurement
ADC1EN_bit :=1;
//ADC1_CR2 := %00000000000000000000000100000011;
ADC1_CR1 := %00000000000000000000000000000000;
ADC_CCR := %00000000110000010000000000000000;
ADC1_SQR3 := %00000000000000000000000000000001;
ADC1_CR2 := %01000000000000000000000000000011;
SWSTART_bit:=1;
delay_ms(1);
end;
and then the loop
while EOC1_bit = 0 DO nop;
// delay_ms(5);
value := ADC1_DR;
I think it's not really correct..but with this it works..the rest will be much easier :)
2015-05-26 06:31 AM
Use the examples in the Standard Peripheral Library as a guide to the steps required.
Not many Forum responders will take the time to check register level code. Cheers, Hal