Hello everyone,
I have a custom board with an nRF5340, which currently uses the internal clock.
I'm trying to use the RV8263-C8 RTC to achieve accurate real-time tracking.
Here is my schematic:
My .dts:
&pinctrl { i2c1_default: i2c1_default { group1 { psels = <NRF_PSEL(TWIM_SDA, 1, 2)>, <NRF_PSEL(TWIM_SCL, 1, 3)>; }; }; i2c1_sleep: i2c1_sleep { group1 { psels = <NRF_PSEL(TWIM_SDA, 1, 2)>, <NRF_PSEL(TWIM_SCL, 1, 3)>; low-power-enable; }; }; }; &i2c1 { compatible = "nordic,nrf-twim"; status = "okay"; clock-frequency = <400000>; zephyr,concat-buf-size = <512>; pinctrl-0 = <&i2c1_default>; pinctrl-1 = <&i2c1_sleep>; pinctrl-names = "default", "sleep"; rv_8263_c8: rv-8263-c8@51 { compatible = "microcrystal,rv-8263-c8"; reg = <0x51>; status = "okay"; clkout = <1024>; int-gpios = <&gpio1 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; }; };
When I running the sample code:
#include <zephyr/kernel.h> #include <zephyr/drivers/rtc.h> #include <zephyr/logging/log.h> LOG_MODULE_REGISTER(rtc_test, LOG_LEVEL_INF); const struct device *rtc_dev = DEVICE_DT_GET(DT_NODELABEL(rv_8263_c8)); int main(void) { if (!device_is_ready(rtc_dev)) { LOG_ERR("RTC device not ready"); return -1; } struct rtc_time set_time = { .tm_sec = 0, .tm_min = 0, .tm_hour = 0, .tm_mday = 1, .tm_mon = 1, .tm_year = 125, .tm_wday = 1, }; if (rtc_set_time(rtc_dev, &set_time) != 0) { LOG_ERR("Failed to set RTC time"); return -1; } while (1) { struct rtc_time curr_time; if (rtc_get_time(rtc_dev, &curr_time) == 0) { LOG_INF("Time: %02d:%02d:%02d", curr_time.tm_hour, curr_time.tm_min, curr_time.tm_sec); } else { LOG_ERR("Failed to read RTC"); } k_sleep(K_SECONDS(1)); } return 0; }
My output:
SEGGER J-Link V8.12 - Real time terminal output SEGGER J-Link (unknown) V1.0, SN=1050200307 Process: JLinkExe [00:00:00.002,593] <dbg> microcrystal_rv8263c8: rv8263c8_in[00:00:00.001,159] <dbg> microcrystal_rv8263c8: rv8263c8_init: Configure ClkOut: 5 [00:00:00.006,561] <dbg> microcrystal_rv8263c8: rv8263c8_init: Configure ClkOut: 5 *** Booting nRF Connect SDK v2.9.0-7787b2649840 *** *** Using Zephyr OS v3.7.99-1f8f3dc29142 *** [00:00:02.161,743] <dbg> microcrystal_rv8263c8: rv8263c8_time_set: Set time: year = 125, mon = 1, mday = 1, wday = 1, hour = 0, min = 0, sec = 0 [00:00:02.672,515] <err> rtc_test: Failed to read RTC [00:00:04.177,856] <err> rtc_test: Failed to read RTC [00:00:05.683,166] <err> rtc_test: Failed to read RTC [00:00:07.188,476] <err> rtc_test: Failed to read RTC [00:00:08.693,786] <err> rtc_test: Failed to read RTC [00:00:10.199,127] <err> rtc_test: Failed to read RTC
Using an oscilloscope, I observed that SDA and SCL show the same waveform.
I’ve tried running other samples, but I keep getting the same issue.
When I add bias-pull-up to the pinctrl, I get a "device not ready" error.
Has anyone encountered this before or knows what might be going wrong?
Any help would be greatly appreciated!