Question about DWT on STM32L431
I have a straightforward question regarding the DWT counter. I am using the DWT->CYCCNT counter to count clock cycle differences in the STM32L431CC, and I noticed that CYCCNT is 32-bits wide. If I were to use HSI16 as my internal clock source, the CYCCNT would still go up to the maximum value of a uint32_t which is 4294967295, and not 16000000 based on my HSI16 clock source right?
Thanks!
timestamp_1 = DWT->CYCCNT;
DoSomeTask();
timestamp_2 = DWT->CYCCNT;
if(timestamp_2 < timestamp_1)
{
/* I originally filled 16000000 instead of MAX_INT here */
timedifference = timestamp_2 + MAX_INT - timestamp_1;
}
else
{
timedifference = timestamp_2 - timestamp_1;
}