We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
While running a multi-threaded system on coretx-M0+ using RTX, I want to measure percentage of time spent in each task on the CPU and time spent in idle task. Can anyone suggest a way to do that?
change the state of a port pin on a task switch and scope it
Thanks for the response! I actually want to display it on a LCD screen that is handled by a task. I'm sorry I did not make it clear. So, I have a multi-threaded system running on the cortex-M0+ based board. It handles a resistive touch panel, LCD screen and accelerometer. I have created a task for handling each of them. When I touch a button on the screen, it should display the percentage of time spent in each task and time spent in idle task. For that, I have to keep profiling, i.e. keep a track of time spent in each task and display it when needed.
You can enable DBG_MSG in RTX
#ifdef DBG_MSG #define DBG_INIT() dbg_init() #define DBG_TASK_NOTIFY(p_tcb,create) if (dbg_msg) dbg_task_notify(p_tcb,create) #define DBG_TASK_SWITCH(task_id) if (dbg_msg && (os_tsk.new!=os_tsk.run)) \ dbg_task_switch(task_id) #else #define DBG_INIT() #define DBG_TASK_NOTIFY(p_tcb,create) #define DBG_TASK_SWITCH(task_id) #endif
DBG_TASK_SWITCH will be called every task swtich. If ms is a good enough resolution for you, you can use the SysTick to keep track of the time spent in each task. If it is not good enough you will need to enable a higher resolution timer and use that.
Sorry - you will want to replace these routines with your routines. Using the ITM is not going to do what you want. Or just use this as an example. It is making the calls in the locations that you want.