Skip to content

Commit

Permalink
Merge #298
Browse files Browse the repository at this point in the history
298: saadc: Clear events_calibratedone before calibration r=Yatekii a=Dirbaio

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.

Co-authored-by: Dario Nieuwenhuis <[email protected]>
  • Loading branch information
bors[bot] and Dirbaio authored Mar 1, 2021
2 parents b4eae29 + c59d05f commit f39d042
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions nrf-hal-common/src/saadc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl Saadc {
saadc.ch[0].pseln.write(|w| w.pseln().nc());

// Calibrate
saadc.events_calibratedone.reset();
saadc.tasks_calibrateoffset.write(|w| unsafe { w.bits(1) });
while saadc.events_calibratedone.read().bits() == 0 {}

Expand Down

0 comments on commit f39d042

Please sign in to comment.