PCF2129 RTC example code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PCF2129 RTC example code

PCF2129 RTC example code

**************************************************************************************************
* The PCF2129AT is a CMOS Real Time Clock (RTC) and calendar with an integrated
* Temperature Compensated Crystal Oscillator and a 32.768 kHz quartz crystal
* optimized for very high accuracy and very low power consumption.

*

* This simple example code has been written for the FRDM-KL25Z + OM13513
* boards and demonstrates how to set and read the time/date on the PCF2129AT
* using the SPI (do not forget to remove the JP1 jumper) interface. It also
* illustrates how to use a second interrupt to generate an interrupt on the
* INT pin once per second when the Seconds register increments.
*
* In this example the time to be set is Wednesday, February 26 2020, 10:30 AM.
*
* Connection:      FRDM-KL25Z           OM13513
* VDD                 J9-4                           P2-2
* GND                 J9-14                         P2-1
* MOSI               J2-8                            P2-5
* MISO               J2-10                          P2-6
* SCLK               J2-12                          P2-4
* CS                   J2-6                            P2-7
* INT                  J1-6                            P2-8
**************************************************************************************************

Enabling the second interrupt by writing 0x01 to the Control_1 register (0x00):

Second Interrupt Write.JPG

Second interrupt generated on the INT pin once per second:

Interrupt.JPG

Setting the time and date by writing to registers Seconds (0x03) - Years (0x09): 

Write.JPG

Actual time and date shown in the Debug window:

Capture.JPG

Attachments
Comments

Hi, is there any driver or example code for PCF2131?

%3CLINGO-SUB%20id%3D%22lingo-sub-1105024%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EPCF2129%20RTC%20example%20code%20%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1105024%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3E**************************************************************************************************%3C%2FSPAN%3E%3CBR%20%2F%3E%20*%20The%20PCF2129AT%20is%20a%20CMOS%20Real%20Time%20Clock%20(RTC)%20and%20calendar%20with%20an%20integrated%3CBR%20%2F%3E%20*%20Temperature%20Compensated%20Crystal%20Oscillator%20and%20a%2032.768%20kHz%20quartz%20crystal%3CBR%20%2F%3E%20*%20optimized%20for%20very%20high%20accuracy%20and%20very%20low%20power%20consumption.%3C%2FP%3E%3CP%3E*%3C%2FP%3E%3CP%3E*%20This%20simple%20example%20code%20has%20been%20written%20for%20the%20FRDM-KL25Z%20%2B%20OM13513%3CBR%20%2F%3E%20*%20boards%20and%20demonstrates%20how%20to%20set%20and%20read%20the%20time%2Fdate%20on%20the%20PCF2129AT%3CBR%20%2F%3E%20*%20using%20the%20SPI%20(do%20not%20forget%20to%20remove%20the%20JP1%20jumper)%20interface.%20It%20also%3CBR%20%2F%3E%20*%20illustrates%20how%20to%20use%20a%20second%20interrupt%20to%20generate%20an%20interrupt%20on%20the%3CBR%20%2F%3E%20*%20INT%20pin%20once%20per%20second%20when%20the%20Seconds%20register%20increments.%3CBR%20%2F%3E%20*%3CBR%20%2F%3E%20*%20In%20this%20example%20the%20time%20to%20be%20set%20is%20Wednesday%2C%20February%2026%202020%2C%2010%3A30%20AM.%3CBR%20%2F%3E%20*%3CBR%20%2F%3E%20*%20Connection%3A%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20FRDM-KL25Z%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BOM13513%3CBR%20%2F%3E%20*%20VDD%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BJ9-4%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BP2-2%3CBR%20%2F%3E%20*%20GND%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BJ9-14%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BP2-1%3CBR%20%2F%3E%20*%20MOSI%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BJ2-8%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20P2-5%3CBR%20%2F%3E%20*%20MISO%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BJ2-10%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20P2-6%3CBR%20%2F%3E%20*%20SCLK%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BJ2-12%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20P2-4%3CBR%20%2F%3E%20*%20CS%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BJ2-6%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20P2-7%3CBR%20%2F%3E%20*%20INT%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20J1-6%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20P2-8%3CBR%20%2F%3E%20**************************************************************************************************%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEnabling%20the%20second%20interrupt%20by%20writing%200x01%20to%20the%26nbsp%3BControl_1%20register%20(0x00)%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Second%20Interrupt%20Write.JPG%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Second%20Interrupt%20Write.JPG%22%20style%3D%22width%3A%20544px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F99092iE61F0A7905AE0948%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Second%20Interrupt%20Write.JPG%22%20alt%3D%22Second%20Interrupt%20Write.JPG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ESecond%20interrupt%20generated%26nbsp%3B%3CSPAN%3Eon%20the%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BINT%20pin%20once%20per%20second%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Interrupt.JPG%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Interrupt.JPG%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F99130i54B0EDBEBBD05CDC%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Interrupt.JPG%22%20alt%3D%22Interrupt.JPG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ESetting%20the%20time%20and%20date%20by%20writing%20to%20registers%20Seconds%20(0x03)%20-%20Years%20(0x09)%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Write.JPG%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Write.JPG%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F99091iA7388088A5A9DD50%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Write.JPG%22%20alt%3D%22Write.JPG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EActual%20time%20and%20date%20shown%20in%20the%20Debug%20window%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Capture.JPG%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Capture.JPG%22%20style%3D%22width%3A%20741px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F99173iC9AAFD9CDEB3E0B3%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Capture.JPG%22%20alt%3D%22Capture.JPG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1670768%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20PCF2129%20RTC%20example%20code%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1670768%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%20is%20there%20any%20driver%20or%20example%20code%20for%20PCF2131%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
No ratings
Version history
Last update:
‎02-27-2020 02:47 AM
Updated by: