File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
applications/nrf5340_audio
doc/nrf/releases_and_maturity/releases Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -79,3 +79,11 @@ CONFIG_BT_ATT_TX_COUNT=12
7979
8080# Suppress the USB deprecation warning
8181CONFIG_DEPRECATION_TEST=y
82+
83+ # Log high CPU load using printk
84+ CONFIG_CPU_LOAD=y
85+ # Disable LOG_PRINTK to ensure printk messages are displayed even under high CPU load,
86+ # by preventing them from being processed by the logging subsystem.
87+ CONFIG_LOG_PRINTK=n
88+ CONFIG_CPU_LOAD_LOG_PERIODICALLY=5000
89+ CONFIG_CPU_LOAD_LOG_LEVEL_WRN=y
Original file line number Diff line number Diff line change 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>
2121LOG_MODULE_REGISTER (peripherals , CONFIG_PERIPHERALS_LOG_LEVEL );
2222
2323static 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
2531static int leds_set (void )
2632{
@@ -153,5 +159,11 @@ 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+ LOG_ERR ("Failed to register CPU load callback" );
165+ return ret ;
166+ }
167+
156168 return 0 ;
157169}
Original file line number Diff line number Diff line change @@ -178,7 +178,13 @@ Wi-Fi®
178178Applications
179179============
180180
181- |no_changes_yet_note |
181+ nRF5340 Audio
182+ -------------
183+
184+ * Added high CPU load callback using the Zephyr CPU load subsystem.
185+ The callback uses a :c:func: `printk ` function, as the logging subsystem is scheduled out if higher priority threads take all CPU time.
186+ This makes debugging high CPU load situations easier in the application.
187+ The threshold for high CPU load is set in :c:file: `peripherals.c ` using :c:macro: `CPU_LOAD_HIGH_THRESHOLD_PERCENT `
182188
183189Connectivity bridge
184190-------------------
You can’t perform that action at this time.
0 commit comments