/MCP7940

Arduino Library to access the MCP7940M or MCP7940N Real-Time chips

Primary LanguageC++GNU General Public License v3.0GPL-3.0

Arduino library for accessing the Microchip MCP7940 real time clock. There are two versions of the RTC, MCP7940M and MCP7940N, which differ only in that the MCP7940N has a battery backup supply pin and keeps the clock running on power failure. The MCP7940N also has additional registers which store the timepoint of power failure and point in time when power was restored.

Overview

The MCP7940M and MCP7940N datasheets describe the chip in detail. While there is no breakout board available for this RTC at the present time, it is not difficult to build into a project. The MCP7940 is available as a PDIP 8 pin which allows for easy use on a breadboard and the only additional parts necessary are a 32.768kHz crystal with 2 small capacitors (~6pF, depends upon circuit capacitance) and some pull-up resistors for the I2C data lines as well as for the multifunction pin, if that is to be used.

Features

Apart from performing as a real-time clock, the MCP4790 has 64 Bytes of SRAM storage available and features 2 separate alarms that can be set to be recurring or a single use. The alarm state can be checked using library functions or can pull down the the MFP (multi-function pin) for a hardware interrupt or other action. The MCP7940 allows for software trimming and the library has functions which support fine-tuning the RTC to increase accuracy.

Description

A detailed library description along with further details are available at the GitHub MCP7940 Wiki. This includes wiring information and sample sketches that illustrate the library and it's functionality.





Examples

Several example sketches exist and are documented on the Wiki pages

Example Program Description
SetAndCalibrate Set and Calibrate the RTC using various methods
SetAlarms Set Alarm 0 and Alarm 1
SquareWave Output a Square Wave
TestBatteryBackup Show how the battery backup can be used
AccessMemory Read and Write to the MCP7940 memory

Documentation

The library and example programs have Doxygen documentation, whose output can be found at Doxygen Documentation

Supported Hardware

The following configurations have been compiled and/or tested. Travis-CI is used for automated continuous integration and testing.

Name Tested CPU Comments
Arduino UNO Yes ATMega328P
Arduino Mega Yes ATMega 2560
Arduino Micro Yes ATMega32U4
Arduino 1280 Yes ATMega1280
Arduino 328 Yes ATMega328
Arduino 168 Yes ATMega168

Zanshin Logo