Open thejpster opened 5 years ago
You can configure a system timer to increment only when CPU is active, not when CPU is asleep - if you compare this against another system timer that runs always, you can easily compute CPU usage during the intervening period. Or always take the CPU usage on a fixed line (e.g. 0) to that the number of ticks since the previous measurement is fixed (i.e. 1/60 second * 80 MHz).
The wfvbi() API could grab a timer value (maybe SysTick @ 1MHz or something) on entry and exit, and return some fractional value to indicate how loaded the CPU is - maybe a number between 0 and 99. You can then display this on screen in your game to know how much more 'work' you can do each frame.