Skip to content

Commit c59d05f

Browse files
authored
saadc: Clear events_calibratedone before calibration
Without this, if you initialize SAADC for a second time, the events_calibratedone is still set from before, so the while loop doesn't wait for calibration to be done. This causes garbage readings if you read immediately after, because calibration is still running.
1 parent b4eae29 commit c59d05f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

nrf-hal-common/src/saadc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ impl Saadc {
8787
saadc.ch[0].pseln.write(|w| w.pseln().nc());
8888

8989
// Calibrate
90+
saadc.events_calibratedone.reset();
9091
saadc.tasks_calibrateoffset.write(|w| unsafe { w.bits(1) });
9192
while saadc.events_calibratedone.read().bits() == 0 {}
9293

0 commit comments

Comments
 (0)