Commit a24c874a authored by Erik Strand's avatar Erik Strand

Don't disable the ADC between samples

parent 9a86a161
......@@ -37,13 +37,6 @@ uint32_t bm_analogRead( uint32_t pin )
// pinPeripheral now handles disabling the DAC (if active)
if ( pinPeripheral(pin, PIO_ANALOG_ADC) == RET_STATUS_OK )
{
ADC->INPUTCTRL.bit.MUXPOS = GetADC(pin); // Selection for the positive ADC input
syncADC();
ADC->CTRLA.bit.ENABLE = 0x01; // Enable ADC
syncADC();
// Start conversion
ADC->SWTRIG.bit.START = 1;
syncADC();
......@@ -51,9 +44,6 @@ uint32_t bm_analogRead( uint32_t pin )
// Store the value
while (ADC->INTFLAG.bit.RESRDY == 0); // Waiting for conversion to complete
valueRead = ADC->RESULT.reg;
ADC->CTRLA.bit.ENABLE = 0x00; // Disable ADC
syncADC();
}
return mapResolution(valueRead, _ADCResolution, _readResolution);
......@@ -66,6 +56,15 @@ void setup() {
pinMode(LED_GREEN, OUTPUT);
// Calling the regular method once ensures that the ADC does get initialized.
analogRead(SENSE_LINE_0);
// Selection for the positive ADC input
ADC->INPUTCTRL.bit.MUXPOS = GetADC(SENSE_LINE_0);
syncADC();
// Enable ADC
ADC->CTRLA.bit.ENABLE = 0x01;
syncADC();
}
void loop() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment