KEIL5 debugging timing, measuring program running time, suitable for STM32\MK60\IM6U and other microcontrollers based on Cortex-M architecture processors

1. Background

In a real-time system, a specified task needs to be completed within a specified time. A platform with excellent performance can be completed in a shorter time to ensure that the task must be completed within the specified time, but it also means higher costs. Secondly, estimating the running time from the time complexity of the algorithm can only estimate an approximate time, and practical applications require more accurate running time measurement. For example, the best time complexities of quick sort and heap sort are both (log2n), but in actual operation, the time is not the same.

2. Implementation method

2.1 Using the timer

For example, the author used to test the sorting algorithm before. Use a timer to keep time.

2.2 Timing with debug mode

This method is exactly what this article will introduce. The specific operation process is introduced below.

3. Operation process

3.1 Parameter setting

        Fill in the actual operating frequency of the processor in this interface.

 

 Select the Debug tab and click Setting

 In the pop-up interface, set the operating frequency of the processor again, and pay attention to whether the tick in the red box is marked.

 Finally, click Debug,

In the register interface, find Sec in Internal, this is the time from the start of operation to the present.

To measure the running time of a function, simply break the point before running it, and record the time. After running, break the point, record the time again, and subtract the two times, which is the actual running time of the function. 

Guess you like

Origin blog.csdn.net/Fairchild_1947/article/details/122313068