As we know, the instruction count can be calculated as:
# instructions executed = DWT_CYCCNT - DWT_CPICNT - DWT_EXCCNT - DWT_SLEEPCNT - DWT_LSUCNT + DWT_FOLDCNT
The count register DWT_CPICNT , DWT_EXCCNT , DWT_SLEEPCNT , DWT_LSUCNT , DWT_FOLDCNT is only 8 bit. When the register overflows, the number of statistical instructions is inaccurate. so I think it can't count too many instructions.
Is there another method to count the instructions?