Ensure ADC conversion is complete before reading (#11336)

The current Marlin implementation relies on a timer interrupt to start the ADC conversion and read it. However in some circumstances the interrupt can be delayed resulting in insufficient time being available for the ADC conversion. This results in a bad reading and false temperature fluctuations. These changes make sure that the conversion is complete (by checking the ADC hardware via the HAL) before reading a value.

See: https://github.com/MarlinFirmware/Marlin/issues/11323
This commit is contained in:
Andy Shaw
2018-07-26 09:59:19 +01:00
committed by Scott Lahteine
parent e2aa635e70
commit 624986d423
10 changed files with 140 additions and 111 deletions

View File

@ -52,6 +52,7 @@
* States for ADC reading in the ISR
*/
enum ADCSensorState : char {
StartSampling,
#if HAS_TEMP_ADC_0
PrepareTemp_0,
MeasureTemp_0,
@ -328,6 +329,7 @@ class Temperature {
/**
* Called from the Temperature ISR
*/
static void readings_ready();
static void isr();
/**