From a8172e35886c23b9fbd6f44cf79023aa92016311 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Mon, 18 Jan 2016 19:54:45 +0100 Subject: [PATCH] Fixes #2639: ADC crosstalk on X9E fixed, sample time was not set for the right channels, sample time also needed to be increased --- radio/src/targets/taranis/adc_driver.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/radio/src/targets/taranis/adc_driver.cpp b/radio/src/targets/taranis/adc_driver.cpp index b689b0580..41ad53fa3 100644 --- a/radio/src/targets/taranis/adc_driver.cpp +++ b/radio/src/targets/taranis/adc_driver.cpp @@ -26,7 +26,8 @@ #define PIN_PORTC 0x0200 // Sample time should exceed 1uS -#define SAMPTIME 2 // sample time = 28 cycles +#define SAMPTIME 2 // sample time = 28 cycles +#define SAMPTIME_LONG 3 // sample time = 56 cycles #if defined(REV9E) const int8_t ana_direction[NUMBER_ANALOG] = {1,1,-1,-1, -1,-1,-1,1, -1,1,1,1, -1}; @@ -96,8 +97,8 @@ void adcInit() ADC3->SQR1 = (NUMBER_ANALOG_ADC3-1) << 20 ; // NUMBER_ANALOG Channels ADC3->SQR2 = 0; ADC3->SQR3 = (ADC_CHANNEL_POT1<<0) + (ADC_CHANNEL_SLIDER1<<5) + (ADC_CHANNEL_SLIDER2<<10) ; // conversions 1 to 3 - ADC3->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6); - ADC3->SMPR2 = 0; + ADC3->SMPR1 = 0; + ADC3->SMPR2 = (SAMPTIME_LONG<<(3*ADC_CHANNEL_POT1)) + (SAMPTIME_LONG<<(3*ADC_CHANNEL_SLIDER1)) + (SAMPTIME_LONG<<(3*ADC_CHANNEL_SLIDER2)); // Enable the DMA channel here, DMA2 stream 1, channel 2 DMA2_Stream1->CR = DMA_SxCR_PL | DMA_SxCR_CHSEL_1 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC;