Skip to content

Commit e71f64e

Browse files
committed
tests: nrf5340_audio: Added high CPU load print
Using the high CPU load monitoring feature, print a message using printk when the CPU load exceeds a defined threshold. OCT-3414 Signed-off-by: Kristoffer Skøien <[email protected]>
1 parent d0f84cb commit e71f64e

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

applications/nrf5340_audio/prj.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,9 @@ CONFIG_BT_ATT_TX_COUNT=12
7979

8080
# Suppress the USB deprecation warning
8181
CONFIG_DEPRECATION_TEST=y
82+
83+
# Log high CPU load using printk
84+
CONFIG_CPU_LOAD=y
85+
CONFIG_LOG_PRINTK=n
86+
CONFIG_CPU_LOAD_LOG_PERIODICALLY=5000
87+
CONFIG_CPU_LOAD_LOG_LEVEL_WRN=y

applications/nrf5340_audio/src/utils/peripherals.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@
1414
#include "sd_card.h"
1515
#include "nrf5340_audio_dk_version.h"
1616
#include "device_location.h"
17-
1817
#include "sd_card_playback.h"
1918

19+
#include <zephyr/debug/cpu_load.h>
2020
#include <zephyr/logging/log.h>
2121
LOG_MODULE_REGISTER(peripherals, CONFIG_PERIPHERALS_LOG_LEVEL);
2222

2323
static struct board_version board_rev;
24+
#define CPU_LOAD_HIGH_THRESHOLD_PERCENT 98
25+
26+
static void cpu_load_cb(uint8_t percent)
27+
{
28+
printk("CPU load high: %d %%\n", percent);
29+
}
2430

2531
static int leds_set(void)
2632
{
@@ -153,5 +159,10 @@ int peripherals_init(void)
153159
return ret;
154160
}
155161

162+
ret = cpu_load_cb_reg(cpu_load_cb, CPU_LOAD_HIGH_THRESHOLD_PERCENT);
163+
if (ret) {
164+
return ret;
165+
}
166+
156167
return 0;
157168
}

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ Wi-Fi®
178178
Applications
179179
============
180180

181-
|no_changes_yet_note|
181+
nRF5340 Audio
182+
-------------
183+
184+
* Added:
185+
* High CPU load callback using the Zephyr CPU load subsystem.
186+
The callback uses a printk, as the logging subsystem will be scheduled out if higher priority threads take all CPU time.
187+
This will make it easier to debug high CPU load situations in the application.
182188

183189
Connectivity bridge
184190
-------------------

0 commit comments

Comments
 (0)