From e7a8422fa93d1511d519a5a33594b490b48633e9 Mon Sep 17 00:00:00 2001 From: mxmxmx Date: Thu, 30 Aug 2018 11:34:50 +0200 Subject: [PATCH] [ADC] move dma->enable() --- software/C2M_X/C2M_ADC.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/software/C2M_X/C2M_ADC.cpp b/software/C2M_X/C2M_ADC.cpp index 83a1bd4..6fc7bb8 100644 --- a/software/C2M_X/C2M_ADC.cpp +++ b/software/C2M_X/C2M_ADC.cpp @@ -23,11 +23,13 @@ DMAMEM static volatile uint16_t __attribute__((aligned(DMA_BUF_SIZE+0))) adcbuff adc_.setConversionSpeed(kAdcConversionSpeed); adc_.setSamplingSpeed(kAdcSamplingSpeed); adc_.setAveraging(kAdcScanAverages); - adc_.enableDMA(); calibration_data_ = calibration_data; std::fill(raw_, raw_ + ADC_CHANNEL_LAST, 0); std::fill(smoothed_, smoothed_ + ADC_CHANNEL_LAST, 0); + std::fill(adcbuffer_0, adcbuffer_0 + DMA_BUF_SIZE, 0); + + adc_.enableDMA(); } void ADC::DMA_ISR() { @@ -35,8 +37,7 @@ void ADC::DMA_ISR() { ADC::ready_ = true; dma0->TCD->DADDR = &adcbuffer_0[0]; dma0->clearInterrupt(); - // move enable to SCAN_DMA() ? - dma0->enable(); + /* reenable in SCAN_DMA(); */ } /* @@ -88,6 +89,7 @@ void ADC::Init_DMA() { if (ADC::ready_) { ADC::ready_ = false; + /* * starts collecting results at adcbuffer_0[1] because of weird offset (--> discard adcbuffer_0[0]). * there's 16 samples in the buffer, 1-5 / 11-15 are the pitch inputs: @@ -103,6 +105,8 @@ void ADC::Init_DMA() { update(adcbuffer_0[8]); update(adcbuffer_0[9]); update(adcbuffer_0[10]); + /* start over */ + dma0->enable(); } }