Skip to content

Commit 4154581

Browse files
nordic-seglnordic-piks
authored andcommitted
tests: drivers: timer: Test k_msleep() and k_busy_wait() accuracy
Add test that compares k_msleep() and k_busy_wait() delay with ticks counted by a hardware timer. Check that software delay has decent tolerance. Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
1 parent 53ab63a commit 4154581

29 files changed

Lines changed: 239 additions & 0 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2026 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(delay_accuracy)
11+
12+
target_sources(app PRIVATE src/main.c)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Copyright (c) 2026 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
config TEST_TOLERANCE_PERCENT
8+
int "Accepted tolerance in percent"
9+
default 1
10+
help
11+
When set to the value of 1 then test will pass if difference
12+
between actual timer count and expected timer count is less
13+
than one percent.
14+
15+
config TEST_TIMER_FREQUENCY_MHZ
16+
int "Timer frequency in MHz"
17+
default 4
18+
help
19+
This value must take into account hardware limitations.
20+
Calculations are int32_t based and may overflow on devices
21+
with low accuracy or high frequency of the timer.
22+
23+
source "Kconfig.zephyr"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) 2026 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
config PARTITION_MANAGER
8+
default n
9+
10+
source "share/sysbuild/Kconfig"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
tst_timer: &timer130 {
8+
status = "okay";
9+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_TEST_TIMER_FREQUENCY_MHZ=5
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
tst_timer: &timer120 {
8+
status = "okay";
9+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "nrf54h20dk_nrf54h20_cpuapp.overlay"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "nrf54h20dk_nrf54h20_cpuapp.overlay"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "nrf54l15dk_nrf54l15_cpuapp.overlay"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "nrf54l15dk_nrf54l15_cpuapp.overlay"

0 commit comments

Comments
 (0)