Skip to content

Commit

Permalink
Fix #259: added code snippet to apply better Calibration value
Browse files Browse the repository at this point in the history
  • Loading branch information
dhineshkumarmcci committed Jul 10, 2020
1 parent 478ad23 commit b1c6d0e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib/stm32/stm32l0/CatenaStm32L0_CalibrateSystemClock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,25 @@ uint32_t CatenaStm32L0::CalibrateSystemClock(void)
} while ((Calib != CalibNew) &&
(! fHaveSeenLow || !fHaveSeenHigh));

//
// Check which calibration value is better,
// with lower error in PPM
//
if (fHaveSeenLow && fHaveSeenHigh)
{
uint32_t mSecondHighDiff;
uint32_t mSecondLowDiff;

mSecondHighDiff = (mSecondHigh - 1000);
mSecondLowDiff = (1000 - mSecondLow);

if (mSecondHighDiff > mSecondLowDiff)
fHaveSeenHigh = false;

else if (mSecondHighDiff <= mSecondLowDiff)

This comment has been minimized.

Copy link
@chwon64

chwon64 Jul 10, 2020

Collaborator

You don't need "else if" -- "else" is same condition check.

fHaveSeenLow = false;
}

//
// We are going to take higher calibration value first and
// it allows us not to call LMIC_setClockError().
Expand Down

0 comments on commit b1c6d0e

Please sign in to comment.