Skip to content

Commit 44b31b0

Browse files
Correctly scale analog reading per issue #4794
1 parent e9b9f0b commit 44b31b0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ports/mimxrt10xx/common-hal/analogio/AnalogIn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
8181

8282
}
8383

84-
// Shift the value to be 16 bit
85-
return ADC_GetChannelConversionValue(self->pin->adc, ADC_CHANNEL_GROUP) << 4;
84+
// Stretch 12-bit ADC reading to 16 bits via 24-bit interim result
85+
return (ADC_GetChannelConversionValue(self->pin->adc, ADC_CHANNEL_GROUP) * 0x1001) >> 8;
8686
}
8787

8888
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {

0 commit comments

Comments
 (0)