STM32 Code Execution Time.

STM32 Code Execution Time.
STM32

It all started when I needed to at least roughly estimate the execution time of a piece of code. It turned out that microcontrollers with a Cortex-M3 core have a special module for this called the Data Watchpoint and Trace Unit, DWT for short. To configure DWT to measure code execution time, we need to set 2 bits. The TRCENA bit in the DEMCR register, setting...