Zanduino / MCP7940

Arduino Library to access the MCP7940M, MCP7940N and MCP7940x Real-Time chips
GNU General Public License v3.0
37 stars 22 forks source link

calibration sign #9

Closed dtran11 closed 6 years ago

dtran11 commented 6 years ago

I believe this line:

int32_t SecDeviation = dt.unixtime()-now().unixtime();

needs to be this:

int32_t SecDeviation = now().unixtime()-dt.unixtime();

So that the sign of the trim is correct.

thanks

SV-Zanshin commented 6 years ago

Sorry for taking so long to sort this out - the bug got lost in my inbox until now.

I think that the sign is correct. The "SecDeviation" is positive when the clock is faster then the expected time and negative when slower. A faster clock (positive value) means that the sign bit is to be cleared. The MCP7940N datasheet explains the formula on page 30.