Kaynağa Gözat

12-bit ADC resolution for STM32 (#20519)

LinFor 3 yıl önce
ebeveyn
işleme
36aff1e464
No account linked to committer's email address

+ 3
- 3
Marlin/src/HAL/STM32/HAL.h Dosyayı Görüntüle

@@ -159,14 +159,14 @@ static inline int freeMemory() {
159 159
 
160 160
 #define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT)
161 161
 
162
-inline void HAL_adc_init() {}
163
-
164 162
 #define HAL_ADC_VREF         3.3
165
-#define HAL_ADC_RESOLUTION  10
163
+#define HAL_ADC_RESOLUTION  ADC_RESOLUTION // 12
166 164
 #define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
167 165
 #define HAL_READ_ADC()      HAL_adc_result
168 166
 #define HAL_ADC_READY()     true
169 167
 
168
+inline void HAL_adc_init() { analogReadResolution(HAL_ADC_RESOLUTION); }
169
+
170 170
 void HAL_adc_start_conversion(const uint8_t adc_pin);
171 171
 
172 172
 uint16_t HAL_adc_get_result();

+ 2
- 0
Marlin/src/module/thermistor/thermistors.h Dosyayı Görüntüle

@@ -27,6 +27,8 @@
27 27
 #define THERMISTOR_TABLE_SCALE (HAL_ADC_RANGE / _BV(THERMISTOR_TABLE_ADC_RESOLUTION))
28 28
 #if ENABLED(HAL_ADC_FILTERED)
29 29
   #define OVERSAMPLENR 1
30
+#elif HAL_ADC_RESOLUTION > 10
31
+  #define OVERSAMPLENR (20 - HAL_ADC_RESOLUTION)
30 32
 #else
31 33
   #define OVERSAMPLENR 16
32 34
 #endif

+ 2
- 0
buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h Dosyayı Görüntüle

@@ -114,6 +114,8 @@ extern "C" {
114 114
 #define NUM_ANALOG_INPUTS       7
115 115
 #define NUM_ANALOG_FIRST        80
116 116
 
117
+#define ADC_RESOLUTION          12
118
+
117 119
 // PWM resolution
118 120
 // #define PWM_RESOLUTION          12
119 121
 #define PWM_FREQUENCY           20000 // >= 20 Khz => inaudible noise for fans

Loading…
İptal
Kaydet