2021-05-21 02:21 AM
Hi.
I need to estimate the cpu load and output the data as a percentage to a variable ram and to an LED. I use stm 32h 743. The microcontroller works without sleep. It is advisable to make accounting and interruptions. Can you suggest a solution?
2021-05-21 05:36 AM
One way is to use a software counter. Pseudocode:
volatile uint32_t x = 0;
uint32_t start_tick = TICKS;
while (last_tick - TICKS < DURATION) {
++x;
}
Run that under idle conditions to establish a baseline, then run it under load conditions with other interrupts happening. Under 50% load, your final value for x will be half of the idle/baseline value.