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
  • Did you read the blog I wrote about instrumenting the softdevice with SystemView? It's here. You can get a very detailed picture of the interrupts which are driving the softdevice and show what it's doing, plus you can see how long it takes to service any of the SVC calls. With all the information in there you can put together a pretty accurate picture of how much time the softdevice is taking to do work.

    I didn't put that together with the FreeRTOS monitoring, I was running without an RTOS in that example, but it wouldn't be too difficult to do that too.

  • Hi Aryan, that's right I was talking about GPIOs because it makes the profiling quite easy without having to use a TRACE debugger (e.g., J-Trace). I wasn't aware of the SystemView software and since it doesn't need the TRACE pins and debugger to work it actually does match my needs. With the link given by RK I have been able to monitor the FreeRTOS+HRS example.

Reply
  • Hi Aryan, that's right I was talking about GPIOs because it makes the profiling quite easy without having to use a TRACE debugger (e.g., J-Trace). I wasn't aware of the SystemView software and since it doesn't need the TRACE pins and debugger to work it actually does match my needs. With the link given by RK I have been able to monitor the FreeRTOS+HRS example.

Children
No Data
Related