Skip to content

Profiling

Alejandro Gonzalvo edited this page Mar 12, 2023 · 4 revisions

First, we will need to slightly change the IOC of template-project. Go to Trace and debug, Debug, and change the only selector from JTAG4 to Trace Asynchronous SW : image

Then we will need to change our debugging configurations. To change those, click on the arrow on the right of the debug icon, then select debug configuration. There you will need to check 2 things. First check the debugging interface on the SWD mode. Second activate Serial Wire Viewer and change the core clock to the correct value. Using Cube generated code with the template-project IOC is 275 MHz, Using the ST-LIB start for a nucleo with the template project IOC is 88 MHz (as ST-LIB start changes one preescaler which affects the core clock). For any other use just measure the Core clock frequency with SystemCoreClock variable (which comes with the HAL) and divide it by 2.

image image

Now we need to start the debugging session (but not run the code yet!) and open the statistic profiler window. We go to window -> show view -> SWV -> SWV statistic profiling. If you didn t start the debugging session you will not see the SWV on the show view.

image

We will see something like this. Now we need to click on the configurate trace button (the one with the wrench and the screwdiver) and modify it. Enable both PC sampling and Time Stamps (upper left section), activate trace exceptions (upper middle section) and at last activate the ITM stimulus port 0 (its the default port for sending messages, and the one SWV statistic profiler). It should look somewhat like this: image

Now we have everything configurated! Just press OK, activate the data tracing by pressing the red button (the one at the right of the configurate trace) and start the code using the resume button (or press F8 key). Run it a few seconds and pause it with the suspend button and there you go, if everything gone well you should have the statistics of each function call on the code. It should look something like this when you paused it:

image

If you have nonsense data or nothing at all is printed then something is going wrong, most probably the clock configuration on the debugging configuration.

Last thing to mention, the datasheet of the H723ZG boards warns you that for the SWV to work you need to connect the SB32 bridge and disconnect the SB26 bridge. The SB32 is already connected but the SB26 is also connected, and theorically should be unwelded for it to work. I tested with SB26 connected and it seems to work fine with some boards, so you may not need to use the welder; but if nothing works and it seems that everything is configurated correctly, then checking that may be worth the time

Clone this wiki locally