k_sleep() function misbehaving for greater values of kernel ticks

Description:

Facing an issue with k_sleep() function misbehaving after few months due to the internal counter ticks crossed uint32_max values. Simulated the same by hardcoding the values given below on.

Setup:

1. NCS SDK version: v2.0.0 / Zephyr SDK v3.0.0 / Zephyr SDK v3.2.0

2. nRF52832 DK

Modifications:

1. Hardcode the values below in file https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/timer/nrf_rtc_timer.c#L42 to

static volatile uint32_t overflow_cnt = 23839;
static volatile uint64_t anchor = 399966126479;
static uint64_t last_count = 399966126479;
static uint64_t curr_tick = UINT32_MAX + 10000;
Sample application is attached.
Expected output:
--------------------------- Hello World! nrf52dk_nrf52832
to be printed every 1minute due to k_sleep(K_MINUTES(1)); but is taking more than 10mins to trigger.

Regards,

Raymond

Parents Reply Children
No Data
Related