Skip to content

Commit b123fa7

Browse files
authored
🐛 Restore STM32 / STM32F1 12-bit ADC (MarlinFirmware#23871)
1 parent 79b38e0 commit b123fa7

File tree

3 files changed

+2
-2
lines changed

3 files changed

+2
-2
lines changed

Marlin/src/HAL/STM32F1/HAL.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ void MarlinHAL::adc_start(const pin_t pin) {
335335
_TCASE(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN, POWERMON_CURRENT)
336336
_TCASE(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN, POWERMON_VOLTS)
337337
}
338-
adc_result = adc_results[(int)pin_index] >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits
338+
adc_result = (adc_results[(int)pin_index] & 0xFFF) >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits
339339
}
340340

341341
#endif // __STM32F1__

ini/stm32-common.ini

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ build_flags = ${common.build_flags}
1616
-std=gnu++14 -DHAL_STM32
1717
-DUSBCON -DUSBD_USE_CDC
1818
-DTIM_IRQ_PRIO=13
19+
-DADC_RESOLUTION=12
1920
build_unflags = -std=gnu++11
2021
src_filter = ${common.default_src_filter} +<src/HAL/STM32> +<src/HAL/shared/backtrace>
2122
extra_scripts = ${common.extra_scripts}

ini/stm32g0.ini

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ board = marlin_STM32G0B1RE
3030
board_build.offset = 0x2000
3131
board_upload.offset_address = 0x08002000
3232
build_flags = ${stm32_variant.build_flags}
33-
-DADC_RESOLUTION=12
3433
-DPIN_SERIAL4_RX=PC_11 -DPIN_SERIAL4_TX=PC_10
3534
-DSERIAL_RX_BUFFER_SIZE=1024 -DSERIAL_TX_BUFFER_SIZE=1024
3635
-DTIMER_SERVO=TIM3 -DTIMER_TONE=TIM4

0 commit comments

Comments
 (0)