From e9207f0563c36df419a167a2694ec8cf7dd2fe78 Mon Sep 17 00:00:00 2001 From: Erik Strand Date: Thu, 12 Dec 2019 17:23:03 -0500 Subject: [PATCH] Call initADC in setup instead of analogRead --- adc/adc.ino | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/adc/adc.ino b/adc/adc.ino index 9994953..a30e92a 100644 --- a/adc/adc.ino +++ b/adc/adc.ino @@ -29,11 +29,6 @@ uint32_t bm_analogRead( uint32_t pin ) { uint32_t valueRead = 0; - // Uses a variable outside this translation unit - //if (!ADCinitialized) { - // initADC(); - //} - // pinPeripheral now handles disabling the DAC (if active) if ( pinPeripheral(pin, PIO_ANALOG_ADC) == RET_STATUS_OK ) { @@ -54,8 +49,9 @@ void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(LED_GREEN, OUTPUT); - // Calling the regular method once ensures that the ADC does get initialized. - analogRead(SENSE_LINE_0); + + // Initialize the ADC + initADC(); // Selection for the positive ADC input ADC->INPUTCTRL.bit.MUXPOS = GetADC(SENSE_LINE_0); @@ -64,7 +60,6 @@ void setup() { // Enable ADC ADC->CTRLA.bit.ENABLE = 0x01; syncADC(); - } void loop() { -- GitLab