This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Proper way to monitor CPU load with GPIO while using FreeRTOS ?

Hi !

I'm running the ble_app_hrs_freertos example from SDK11 on the nRF52 dev. kit.

I would like to toggle some GPIOs to monitor the CPU activity and the FreeRTOS context. More specifically I would like to :

  1. Have a GPIO in logic state low while the CPU is asleep and in logic state high while the CPU is running (in softdevice, in a task, in an interrupt, etc.)
  2. Have a GPIO in logic state high while the CPU is working in the softdevice part and in logic state low when it isn't

Can you help me achieve this ? I already know how to monitor FreeRTOS tasks activity by redefining traceTASK_SWITCHED_OUT and traceTASK_SWITCHED_IN but I can't find how to monitore softdevice activity and the overall CPU activity. This also allow to monitor the Idle task activity, but it doesn't cover the softdevice and interrupts parts, does it ?

Here are my traceTASK_SWITCHED_OUT and traceTASK_SWITCHED_IN macros (25 being the GPIO I use for the Idle task) :

#ifndef traceTASK_SWITCHED_OUT
/* Called before a task has been selected to run.  pxCurrentTCB holds a pointer
to the task control block of the task being switched out. */
#define traceTASK_SWITCHED_OUT() if(xTaskGetIdleTaskHandle() == pxCurrentTCB)  \
	{ nrf_gpio_pin_clear(25); } \
	else { nrf_gpio_pin_clear((int)pxCurrentTCB->pxTaskTag ); }
#endif

#ifndef traceTASK_SWITCHED_IN
/* Called after a task has been selected to run.  pxCurrentTCB holds a pointer
to the task control block of the selected task. */
#define traceTASK_SWITCHED_IN() if(xTaskGetIdleTaskHandle() == pxCurrentTCB)  \
	{ nrf_gpio_pin_set(25); } \
	else { nrf_gpio_pin_set((int)pxCurrentTCB->pxTaskTag ); }
#endif
Parents
  • Hello Aryan, thanks for your answer. Too bad it's not possible, it doesn't seem realistic to me not to be able to know the exact CPU active time. How can you say that any basic application is not taking 95% of CPU time if there's a part of the application you can't monitor ?

    In my opinion this kind of feature should be a priority for the softdevice team. It's ok to consider the BLE stack as a black box, but we should be able to know when this black box is active...

Reply
  • Hello Aryan, thanks for your answer. Too bad it's not possible, it doesn't seem realistic to me not to be able to know the exact CPU active time. How can you say that any basic application is not taking 95% of CPU time if there's a part of the application you can't monitor ?

    In my opinion this kind of feature should be a priority for the softdevice team. It's ok to consider the BLE stack as a black box, but we should be able to know when this black box is active...

Children
No Data
Related