Skip to content

Commit f1d2609

Browse files
nordic-pikrnordic-piks
authored andcommitted
NCSDK-32785: Extend current consumption testing with changing LFCLK
Add the current measurement for LFRC SYNTH test case Signed-off-by: Piotr Krzyzanowski <[email protected]>
1 parent 1b2abb0 commit f1d2609

File tree

7 files changed

+130
-0
lines changed

7 files changed

+130
-0
lines changed

scripts/ci/tags.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ ci_tests_benchmarks_current_consumption:
11571157
- nrf/tests/benchmarks/power_consumption/
11581158
- nrfxlib/nfc/
11591159
- zephyr/boards/nordic/
1160+
- zephyr/drivers/clock_control/
11601161
- zephyr/drivers/gpio/
11611162
- zephyr/drivers/serial/
11621163
- zephyr/dts/common/nordic/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2025 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+
11+
project(lfrc_idle)
12+
13+
target_sources(app PRIVATE src/main.c)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
aliases {
9+
led = &led0;
10+
/delete-property/ led1;
11+
};
12+
};
13+
14+
/delete-node/ &led1;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CONFIG_GPIO=y
2+
CONFIG_CLOCK_CONTROL=y
3+
4+
CONFIG_PM=y
5+
CONFIG_PM_S2RAM=y
6+
CONFIG_PM_S2RAM_CUSTOM_MARKING=y
7+
CONFIG_PM_DEVICE=y
8+
CONFIG_PM_DEVICE_RUNTIME=y
9+
10+
CONFIG_ASSERT=y
11+
12+
CONFIG_LOG=n
13+
CONFIG_CONSOLE=n
14+
CONFIG_UART_CONSOLE=n
15+
CONFIG_SERIAL=n
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2025, Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <zephyr/devicetree/clocks.h>
8+
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
9+
#include <zephyr/drivers/gpio.h>
10+
11+
const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led), gpios);
12+
const struct device *lfclk_dev = DEVICE_DT_GET(DT_NODELABEL(lfclk));
13+
14+
const struct nrf_clock_spec lfclk_lfrc_mode = {
15+
.frequency = 32768,
16+
.accuracy = 0,
17+
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,
18+
};
19+
20+
const struct nrf_clock_spec lfclk_synth_mode = {
21+
.frequency = 32768,
22+
.accuracy = 30,
23+
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,
24+
};
25+
26+
int main(void)
27+
{
28+
int ret, res;
29+
struct nrf_clock_spec *clk_spec;
30+
struct onoff_client cli;
31+
uint32_t counter = 0;
32+
33+
__ASSERT(gpio_is_ready_dt(&led), "GPIO Device not ready");
34+
__ASSERT(gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE) == 0,
35+
"Could not configure led GPIO");
36+
37+
while (1) {
38+
clk_spec = (struct nrf_clock_spec *)(counter++ % 2 ? &lfclk_lfrc_mode
39+
: &lfclk_synth_mode);
40+
sys_notify_init_spinwait(&cli.notify);
41+
ret = nrf_clock_control_request(lfclk_dev, clk_spec, &cli);
42+
__ASSERT(ret >= 0 && ret <= 2, "Clock control request failed");
43+
do {
44+
ret = sys_notify_fetch_result(&cli.notify, &res);
45+
} while (ret == -EAGAIN);
46+
__ASSERT(ret == 0, "return code: %d", ret);
47+
__ASSERT(res == 0, "response: %d", res);
48+
k_msleep(1000);
49+
gpio_pin_toggle_dt(&led);
50+
ret = nrf_clock_control_release(lfclk_dev, clk_spec);
51+
__ASSERT(ret == ONOFF_STATE_ON, "return code: %d", ret);
52+
}
53+
54+
return 0;
55+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
if(SB_CONFIG_SOC_NRF54H20)
8+
# Add remote project
9+
ExternalZephyrProject_Add(
10+
APPLICATION remote_sleep_forever
11+
SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever
12+
BOARD ${SB_CONFIG_BOARD}/${SB_CONFIG_SOC}/cpurad
13+
BOARD_REVISION ${BOARD_REVISION}
14+
)
15+
endif()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
common:
2+
sysbuild: true
3+
tags:
4+
- ci_tests_benchmarks_current_consumption
5+
- ppk_power_measure
6+
- clock_control
7+
tests:
8+
benchmarks.current_consumption.lfclk_idle:
9+
platform_allow:
10+
- nrf54h20dk/nrf54h20/cpuapp
11+
integration_platforms:
12+
- nrf54h20dk/nrf54h20/cpuapp
13+
harness: pytest
14+
harness_config:
15+
fixture: ppk_power_measure
16+
pytest_root:
17+
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_lfclk_source_change"

0 commit comments

Comments
 (0)