I need to measure sleep time of my Cortex-M4 processor (STM32F4xx).
I looked at DWT where I also use normal tick counter and I enabled SLEEPCNT counter.
However, I noticed that it is 8-bit register with event generation support.
Now, there is my question.
How can I know how many events was triggered with this timer if MCU sleeps for example 1 second?
Currently, I'm using like this:
before = DWT->CYCCNT;
/* Read current instruction time */
/* Go sleep, wait interrupt */
after = DWT->CYCCNT - before;
/* Get different */
The first problem I see here is that this method also measures the time when I was in interrupt and do stuff in method which wake up processor.
It would be very nice, if someone can point me to direction how to handle events from SLEEPCNT when I'm in sleep mode.
SLEEPCNT timer is working, I can get different values when I read it but it probably overlaps from 8-bits like 1000 times before MCU is awake again and I read register.
Thanks in advance.
PS: I want to create a very primitive "CPU monitor" to measure CPU load when it is active or when it sleeps.
Maybe you, clive1 have a solution? :D