/dm-pcf2131-real-time-clock-driver-with-demo-app

This example demo provides CMSIS Compliant APIs to configure different operating modes of PCF2131 RTC.

Primary LanguageCBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

NXP Application Code Hub

This demo provides APIs to configure, read and write PCF2131 RTC.

This example provides CMSIS Compliant APIs to configure different operating modes of PCF2131 RTC. It also provides APIs to perform below mentioned operations:

  • RTC Start
  • RTC Stop
  • Get Time
  • Set Time
  • Get Recorded Timestamps on Switches
  • Software Reset 
  • Interrupt Functionality

PCF2131-ARD RTC: Brief Introduction

The PCF2131 is a CMOS real time clock (RTC) and calendar with an integrated temperature compensated crystal (Xtal) oscillator (TCXO) and a 32.768 kHz quartz crystal optimized for very high accuracy and ultra-low power consumption.

PCF2131-ARD RTC: Key Features

  • Selectable I2C-bus or SPI-bus interfaces for full flexibility when selecting the associated MCU/MPU.

  • Backup battery input and switch-over circuit, allowing the RTC to keep track of the time, even when the main power supply is removed.

  • Calendar capabilities to keep tracking of the time from years down to 1/100 seconds.

  • Up to 4 timestamp registers, which can be associated to timestamp input in order to register tampering events.

  • Up to 2 interrupt outputs to enable/disable systems to reduce the overall current consumption.

  • Real Time Clock Block Diagram:

Boards: FRDM-MCXN947 FRDM-MCXA153

Categories: RTC

Peripherals: SPI, I2C

Toolchains: MCUXpresso IDE

Table of Contents

  1. Software
  2. Hardware
  3. Setup
  4. Run Example Projects
  5. Run PCF2131 Demo Example
  6. FAQs
  7. Support
  8. Release Notes

1. Software

2. Hardware

3. Setup

3.1 Step 1: Download and Install required Software(s)

3.2 Step 2: Clone the APP-CODE-HUB/dm-pcf2131-real-time-clock-driver-with-demo-app

  • Clone this repository to get the example projects:
  • Change directory to cloned project folder:
    cd dm-pcf2131-real-time-clock-driver-with-demo-app

Note: If you are using Windows to clone the project, then please configure filename length limit using below command.

git config --system core.longpaths true

3.3 Step 3: Build example projects

  • Open MCUXpresso IDE and select a directory to create your workspace.
  • Install MCXUpresso SDK 2.14.0 for FRDM-MCX947 (drag and drop SDK zip into "Installed SDK" view) into MCUXpresso IDE.
  • Go to "Quickstart Panel" and click on "Import Project(s) from file system",
  • Select "Project directory (unpacked)" and browse to the cloned project folder.
  • Select example projects that you want to open and run.
  • Right click on project and select build to start building the project.

4. Run Example Projects

  • Connect the chosen example project HW: FRDM-MCXN947 with PCF2131-ARD.
  • Right click on project and select "Debug As". Select MCUXpresso IDE LinkServer (inc. CMSIS DAP) probes.
  • Connect a USB cable between the host PC and the MCU-Link USB port on the target board.
  • Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Note 1: For selecting communication interface, Change:

  • I2C_ENABLE to 1 under rtc/pcf2131.h for I2C
  • I2C_ENABLE to 0 under rtc/pcf2131.h for SPI

Note 2: By default SPI/I2C Controller operates in interrupt mode, to switch into EDMA mode Change:

  • RTE_I2C2_DMA_EN to 1 under board/RTE_Device.h for I2C
  • RTE_SPI1_DMA_EN to 1 under board/RTE_Device.h for SPI

5. Run PCF2131 Demo Example

  • User need to check COM port after connecting USB cable between Host PC and Target Board via device manager.

  • Open PUTTY/Teraterm application installed on your Windows PC with Baudrate 115200 and assigned COM port as mentioned in above step.

  • After right click on project and select "Debug As", Demo application will run in interactive mode. When the demo runs successfully, you can see the logs printed on the terminal.

LOGS:

  • Main Menu will look like this

  • Enter #1 to Start RTC

  • Enter #4 to Set Time and choose respective sub-options

  • Enter #5 to Get Time

  • Enter #5 to Record Timestamps on Switches:

a) Enter sub-option #1 to Enable Timestamp on SW2: 

NOTE: Press SW2 on PCF2131-ARD to enable Timestamp.

b) Enter sub-option #2 Disable Timestamp on SW2: 

c) Enter sub-option #3 to Get Timestamp: 

  • Use any option (7,8,9,12) to Enable Interrupts:

a) Steps to Enable Timestamp Interrupt: 

   Timestramp interrrupt is generated on pressing SW1-SW4.

   Below are the steps to Enable timestamp interrupt for SW2:

    Step1: Enter #7 to Enable Timestamp Interrupt

    Step2: Enter #2 to select SW2

    Step3: Choose any one Interrupt Pin and Press Enter

Step4: Press Switch number on which interrupt is enabled to
           get the interrupt

  • Enter #13 to Clear Interrupt:

6. FAQs

No FAQs have been identified for this project.

7. Support

Provide URLs for help here.

Project Metadata

Board badge Board badge

Category badge

Peripheral badge Peripheral badge

Toolchain badge

Questions regarding the content/correctness of this example can be entered as Issues within this GitHub repository.

Warning: For more general technical questions regarding NXP Microcontrollers and the difference in expected funcionality, enter your questions on the NXP Community Forum

Follow us on Youtube Follow us on LinkedIn Follow us on Facebook Follow us on Twitter

8. Release Notes

Version Description / Update Date
1.0 Initial release on Application Code Hub March 28th 2024
2.0 Additional features for PCF2131 on FRDM-MCXN947 and Complete features for PCF2131 on FRDM-MCXA153 April 30th 2024
3.0 Fixed Bugs related to EDMA for FRDM-MCXN947 & FRDM-MCXA153 May 30th 2024