Using RTC PCF85263A
This application note describes how to configure RTC PCF85263A in Zephyr BSP and use it in the user application.
The PCF85263A device is declared in nrf9151som_nrf9151_ns.dts as a child node of the i2c1 bus:
&i2c1 {
...
rtc_pcf85263a: pcf85263a@51 {
compatible = "nxp,pcf85263a";
reg = <0x51>;
alarms-count = <2>;
inta-mode = <(INTx_ALARM1_IE | INTx_LEVEL_MODE)>;
inta-gpios = <&gpio0 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
status = "okay";
};
...
};This node configures the following parameters:
Parameter | Value | Description |
|---|---|---|
|
| Enables the |
|
| LPS22HH slave address on the I2C bus, which will be used by the driver to communicate with the RTC. |
|
| Number of alarms supported by RTC device. The number of alarms defaults to 0, which indicates that the RTC has no alarms. |
|
| RTC INTA pin output mode. |
|
| Host SoC GPIO, that will be used for RTC interrupts. |
The Customized Asset Tracker v2 application makes use of the Zephyr RTC API and implements the following C-binding helper API to control the PCF85263A real-time clock:
Function | Description | Comments |
| Set RTC time. |
Returns 0 if successful, negative errno code if failure. |
| Get current RTC time. |
Returns 0 if successful, negative errno code if failure. |
| Get alarm fields supported by RTC. |
Returns 0 if successful, negative errno code if failure. |
| Get RTC alarm time. |
Returns 0 if successful, negative errno code if failure. |
| Set RTC alarm time. |
Returns 0 if successful, negative errno code if failure. |
| Set RTC alarm callback. |
Returns 0 if successful, negative errno code if failure. |
The Customized Asset Tracker v2 application provides a set of Zephyr shell commands for PCF85263A RTC, defined in rtc_app_shell.c:
Command | Parameters | Comments |
|
| Set RTC time |
|
| Get current RTC time |
|
| Set alarm time and callback |
|
| Get alarm time |
|
| Disable RTC alarm |
Put Jumpers on the JP1 and JP2 headers on the SOM-NRF9151-BSB board.
Plug the battery into P3 on the SOM-NRF9151-BSB board.
Power up the board from the USB Type-C.
From the serial console, set the RTC time and date to the current wall time:
uart:~$ rtc_app set 2025-02-27T17:27:43Validate that the RTC returns correct wall time:
uart:~$ rtc_app get2025-02-27T17:28:02From the serial console set the RTC alarm for 15 minutes from now:
uart:~$ rtc_app set_alarm -1:43:-1 Setting alarm time: 00:43:00 Alarm mask: hour: not set min: set sec: not set