mjs513
Senior Member+
@KurtE
Think there is a minor error in the analog init function as well, last few lines for ADC2:
Line is read probably should be:
To avoid issuing a second PR for analog.c maybe you can incorporate into your PR?
But that leads to another question with the wait_for_cal function. Right now its only setup for ADC1:
Technically shouldn't it also include ADC2:
Red lines are added.
Nice catch and thanks for correcting. Checked Analog Resolution function to make sure that didn't have the same problem, but that was set up a bit differently so its ok.KurtE said:First fix attempt:
Code:
ADC1_CFG = mode;
ADC2_CFG = mode1;
That appears to work, so I pushed the change up to github cores
@Paul - if you are looking it is in my currently pending PR in cores: https://github.com/PaulStoffregen/cores/pull/404
Think there is a minor error in the analog init function as well, last few lines for ADC2:
Code:
//ADC2
ADC2_CFG = mode | ADC_HC_AIEN | ADC_CFG_ADHSC;
ADC2_GC = avg | ADC_GC_CAL; // begin cal
calibrating = 1;
[COLOR="#FF0000"]while (ADC1_GC & ADC_GC_CAL) ;[/COLOR]
calibrating = 0;
Code:
while (ADC2_GC & ADC_GC_CAL) ;
But that leads to another question with the wait_for_cal function. Right now its only setup for ADC1:
Code:
static void wait_for_cal(void)
{
//printf("wait_for_cal\n");
while (ADC1_GC & ADC_GC_CAL) ;
// TODO: check CALF, but what do to about CAL failure?
calibrating = 0;
//printf("cal complete\n");
}
Code:
static void wait_for_cal(void)
{
//printf("wait_for_cal\n");
while (ADC1_GC & ADC_GC_CAL) ;
// TODO: check CALF, but what do to about CAL failure?
calibrating = 0;
[COLOR="#FF0000"] while (ADC2_GC & ADC_GC_CAL) ;
calibrating = 0;[/COLOR]
//printf("cal complete\n");
}