MCP7940
v1.2.0
Arduino Library for the MCP7940N and MCP7940M Real-time clocks
|
#include <MCP7940.h>
Functions | |
void | setup () |
void | loop () |
Variables | |
const uint32_t | SERIAL_SPEED = 115200 |
Set the baud rate for Serial I/O. | |
const uint8_t | LED_PIN = 13 |
Arduino built-in LED pin number. | |
const uint8_t | SPRINTF_BUFFER_SIZE = 32 |
Buffer size for sprintf() | |
const uint8_t | MCP7940_MEMORY_SIZE = 64 |
Number of bytes in memory. | |
MCP7940_Class | MCP7940 |
Create an instance of the MCP7940. | |
char | inputBuffer [SPRINTF_BUFFER_SIZE] |
Buffer for sprintf()/sscanf() | |
Example program for using the MCP7940 library which demonstrates writing to and reading from the 64 bytes of RAM available to the user on the chip. The readRAM() and writeRAM() functions accept any data type and this example will accept characters typed in on the serial port and write them byte-by-bytte to RAM. Then the whole character array is read and displayed with one readRAM() function call.
The library as well as the most current version of this program is available on GitHub at https://github.com/Zanduino/MCP7940 and a more detailed description of this program (and the library) can be found at https://github.com/Zanduino/MCP7940/wiki/SetAndCalibrate.ino
The MCP7940 library uses the standard SPI Wire library for communications with the RTC chip and has also used the class definitions of the standard RTClib library from Adafruit/Jeelabs. The data sheet for the MCP7940M is located at http://ww1.microchip.com/downloads/en/DeviceDoc/20002292B.pdf. The MCP7940N has extra functionality revolving around battery backup but this library's functionality covers that chip as well.
On-chip digital trimming can be used to adjust for frequency variance caused by crystal tolerance and temperature. Since the chip only output full seconds, a calibration cycle won't be effective until there is at least one second difference between the RTC time and real time, and this might take a day or more to do, particularly if the RTC and crystal is already close to being accurate.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Written by Arnd Arnd@ at Zand uino. Comhttps://www.github.com/SV-Zanshin
Version | Date | Developer | Comments |
---|---|---|---|
1.0.3 | 2020-11-15 | SV-Zanshin | Issue #50 - clang-formatted document |
1.0.2 | 2019-01-20 | SV-Zanshin | Changed comments to doxygen formatting |
1.0.1 | 2018-07-07 | SV-Zanshin | Changed code for compatability reasons to new library |
1.0.0 | 2017-08-08 | SV-Zanshin | Initial coding |
void loop | ( | ) |
Arduino method called after setup() which loops forever
void setup | ( | ) |
Arduino method called once upon start or restart.