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
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.
-
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:
- IoT Sensing SDK (ISSDK) v1.8 offered as middleware in MCUXpresso SDK for supported platforms
- MCUXpresso IDE v11.9.0
- FRDM-MCXN947 MCU board
- PCF2131-ARD RTC Device
- Personal Computer
- Mini/micro C USB cable
- Install MCUXpresso IDE 11.9.0 ((https://www.nxp.com/mcuxpresso/ide))
- Download and Install MCUXpresso SDK v2.14.0 for FRDM-MCXN947. Make sure to select ISSDK middleware while building SDK.
- Install Git v2.39.0 (for cloning and running west commands)
- 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
- 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.
- 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
- 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:
No FAQs have been identified for this project.
Provide URLs for help here.
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
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 |