Browse Source

12-bit ADC resolution for STM32 (#20519)

vanilla_fb_2.0.x
LinFor 4 years ago
committed by GitHub
parent
commit
36aff1e464
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      Marlin/src/HAL/STM32/HAL.h
  2. 2
      Marlin/src/module/thermistor/thermistors.h
  3. 2
      buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h

6
Marlin/src/HAL/STM32/HAL.h

@ -159,14 +159,14 @@ static inline int freeMemory() {
#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT) #define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT)
inline void HAL_adc_init() {}
#define HAL_ADC_VREF 3.3 #define HAL_ADC_VREF 3.3
#define HAL_ADC_RESOLUTION 10 #define HAL_ADC_RESOLUTION ADC_RESOLUTION // 12
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_result #define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true #define HAL_ADC_READY() true
inline void HAL_adc_init() { analogReadResolution(HAL_ADC_RESOLUTION); }
void HAL_adc_start_conversion(const uint8_t adc_pin); void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result(); uint16_t HAL_adc_get_result();

2
Marlin/src/module/thermistor/thermistors.h

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

2
buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h

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

Loading…
Cancel
Save