Skip to content

Commit 5ef1f2d

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

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
125125
value = 0;
126126
}
127127

128-
// Map value to from 14 to 16 bits
129-
return value << 2;
128+
// Stretch 14-bit ADC reading to 16-bit range
129+
return (value << 2) | (value >> 12);
130130
}
131131

132132
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {

0 commit comments

Comments
 (0)