Next Example
Task Load Reporting
Track idle time and task activity so CPU load trends can be observed while demos run.
Run It
Use these commands from the COS workspace when the board and serial adapter are attached.
make -C firmware/lpc51u68_cleveros_load_demo clean allmake -C firmware/lpc51u68_cleveros_load_demo flashpython3 tools/uart_viewer.py --device <serial-device> --baud 9600
What To Look For
- Idle task maintains a baseline counter.
- Each task records activation count.
- The report task prints a stable one-second summary.
static volatile uint32_t g_idle_ticks;
static volatile uint32_t g_task0_runs;
static volatile uint32_t g_task1_runs;
void rtos_idle_hook(void)
{
g_idle_ticks++;
__asm volatile("wfi");
}
static void task_load_report(void)
{
for (;;) {
cos_lpc51u68_uart0_puts("load idle ");
cos_lpc51u68_uart0_put_hex32(g_idle_ticks);
cos_lpc51u68_uart0_puts(" task0 ");
cos_lpc51u68_uart0_put_hex32(g_task0_runs);
cos_lpc51u68_uart0_puts(" task1 ");
cos_lpc51u68_uart0_put_hex32(g_task1_runs);
cos_lpc51u68_uart0_puts("\r\n");
rtos_delay_ticks(1000u);
}
}