-->
Page 9 of 13

Re: analogread won't work

PostPosted: Mon Jun 15, 2015 3:07 am
by tytower
If it keeps resetting have a look in the code for any statements where the program can hang for a second. while(1) will do this ,while(::) I have seen as well. I suspect the watch dog timer is being triggered and that can be many things . Another one is to try to read an array but the index is out of bounds .
memory size should not matter.

Re: analogread won't work

PostPosted: Mon Jun 15, 2015 3:24 am
by bernd331
Hi,

i had also problems with analograd. Now it works. First was to define the variable which keeps the analog value as uint.

Second was NOT to use (arduino) analogread. Instead to use the other (adc_read?) function from the SDK (?). I'm at work but later at home I can take a look what exactly it was.

Greetz, Bernd

EDIT: I think it was this: uint16 adc = system_adc_read();

Re: analogread won't work

PostPosted: Mon Jun 15, 2015 3:35 am
by Tawhiz20
tytower wrote:If it keeps resetting have a look in the code for any statements where the program can hang for a second. while(1) will do this ,while(::) I have seen as well. I suspect the watch dog timer is being triggered and that can be many things .

Thanks Tytower... but the program is VERY simple... none of the described problem would likely occur...
Code: Select allvoid setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  delay(1000);       
}

but I also did a run with the Watchdog disabled... same result.. :cry:

Re: analogread won't work

PostPosted: Mon Jun 15, 2015 3:53 am
by Tawhiz20
bernd331 wrote:I'm at work but later at home I can take a look what exactly it was.
EDIT: I think it was this: uint16 adc = system_adc_read();

Thanks Bernd.... looking it up would be greatly appreciated.. I tried to find it myself but was unsuccesfull..