C28x chip CCS7.2 accurately calculates the code running time setting
[Copy link]
In CCS, you can measure the program running time. There are two ways to test the code running time.
Method 1: Use the clock function. This method is simpler and more practical.
To use it, first turn on the clock function. The steps are Run -> clock -> Enable.
A clock icon appears in the lower right corner.
Double-click it to clear it.
Set two breakpoints on the code to be tested, run to the two breakpoints respectively, and you can see the code running cycle.
Use the formula time = 1/CLK to calculate the program running time.
For example, if the clock cycle is 300MHz and the measured data is 1000, then the code running time time = 1000 * (1/300,000,000) = 3.3 μs.
Method 2: Use the Count Event function.
Note: This method is divided into two situations: hardware breakpoints and software breakpoints for analysis. For C28X in CCS official information, there is such a paragraph.
Note: If you are setting software breakpoints (ie code is in RAM) then you can set any number of breakpoints. If they are hardware breakpoints or code is in Flash, then you will only be able to set 1 breakpoint if Count Event is enabled. So you would need to run to the first breakpoint, then disable the first breakpoint and enable the second, and run to the second breakpoint.
If the setting is a software breakpoint, you can use any number of breakpoints. If you use hardware breakpoints, you can only use one breakpoint when Count Event is enabled. So you need to run to the first breakpoint first, then turn off the first breakpoint, then enable the second breakpoint, and then run to the second breakpoint. The complete operation steps will be introduced later.
Tips:
About C28x hardware breakpoints. C28x can only set 2 hardware interrupts. When setting the third one, an error will appear:
Error enabling this function: This task cannot be accomplished with the existing AET resources.
The prerequisite is to make the following settings: Menu Run->Debug Configurations…
When Halt at program termination and Enable CIO function use are not checked, 2 hardware breakpoints can be used.
Case 1: Implementing the Count Event function with software breakpoints (C28x does not recommend this method because when there are more than 2 breakpoints, the program cannot be automatically stopped at the 3rd breakpoint.)
Steps:
1. Now compile and debug the program and download it to the development board. Open the breakpoint window: View->Breakpoints
, then there will be an additional breakpoint window in the upper right corner (default setting). Click the breakpoint drop-down box and select Count Event. As follows:
Select Clock Cycles after the prompt box pops up, then click OK
(Note: Before setting Count Event, the clock function must be turned off, otherwise the following window will pop up. How to turn it off: Run -> clock -> Disable)
2. After step 1, there will be an additional Count Event breakpoint in the breakpoint window. Right-click on Count Event and select Breakpoint Properties to configure this breakpoint.
Change Reset Count on Run to true and click OK to save. That is, the counter will be automatically reset to zero each time you press RUN.
3. Add 2 breakpoints to the code to be tested (double-click the line number on the left of the code where the breakpoint is set), as shown in the figure. If I want to test how long it takes for the program to run from 1 to 2, set a breakpoint on the line where 1 is located and set a breakpoint on 2. At this time, you can see that there are 2 more breakpoints in the breakpoint window. (Note: Each time you press RUN, the counter Count Event will automatically start counting from 0. It will automatically stop when it encounters a breakpoint.)
4. Calculation of running time
As we know from the previous section, it takes 364 machine cycles from code 1 to code 2, and the clock frequency is 60Mhz. Then the running time of this code is 364 * (1/(60*1000000) = 0.00000607, which is about 6.07us.
Case 2: Hardware breakpoint implements Count Event function
. If it is a hardware breakpoint, when count event is enabled, only one hardware breakpoint can be used. The method is: double-click the line number on the left side of the code to set the first breakpoint. Press RUN to run to the first breakpoint first, then turn off the first breakpoint (double-click on the breakpoint), and then set the second breakpoint (double-click the line number on the left side of the code where the breakpoint is set). Then run to the second breakpoint.
|