 Hello, and welcome back to the STM32Q by D Edmonds debug feature. I'm Bruno, and I'm your host for this video series So let's begin to our serial wire viewer debug session I'm just going to switch to STM32Q by D using the very same code as I've been using so far Before we jump into the debug session I just wanted to highlight that we are also gonna use the serial wire viewer to trace the event in exception, so it's important for us to understand that there are a Few interrupts that can happen on this project and the most common one is the actual cystic handler So we can see here It's basically doing a simple increment tick and is the one responsible to ensure that our hall delay Actually works throughout the entire code, but I'm also going to use the IT import So as you guys remember I had a macro defined here That is pretty much in making use of one of the 32 ITM stimulus ports that we can play and Throughout the code execution. I'm gonna use the very last one So the third one to change from one and two Prior to going into the main loop So this will actually allow me to monitor this transition and the time it's spent in this part of the code Execution as well. All right now that we have the basis layout for what to expect Let's start our debug session. Now that I'm on the debug perspective. All I have to do is go to window Show view, serial wire viewer and select the trace log With the trace log I can actually go to the configuration trace And starting by the ITM stimulus port I need to make sure that the number turn one is the one selected Because it's the one that I'm referring to on my code And just to keep and make sure that our log is pretty clean and remove the exception trace log as well So that way each and every exception is not going to be shown on the log at this point in time So by hitting okay And starting our trace I can actually resume the code And I'm just gonna hit suspend right now Because the very first information that I want is right here at the beginning So we have the sync right at the same cycle We can see that we also have the ITM part number turn one with the data number one So if we roll back to our code, we can actually see That the ITM part is the number 31 and we selected the value one to be placed Two so this one is actually reflected into this particular line of the code And if we do scroll down a little bit We can actually see that we are calling again the same macro But this time we are issuing the number two and we can see these ones reflecting on the code So the very good information is that you are actually have a pretty precise time stamp that it took for performing all these actions So the initialization of the GPIO the TMA the UR and the printF function So all of that took around 0.12 ms upgrade Now we do have the information from the ITM part that we manually selected So that's a very easy way to measure the amount of time spent Without using the usual toggle with this code method And a very useful thing that we're going to actually change right now on our code That we're going to back on the serial wire Settings and I'm actually going to enable the trace exceptions right now So by adding the trace exception to rerun We can now see that the exception is recurring is actually the C-stick So by pausing the program I can actually go into the trace log And I can see that the majority of the exceptions was caused by the C-stick As you may know the C-stick is set to happen every one millisecond So if we analyze the time stamp between the trace exceptions We can actually see the one millisecond being held Here and here and here So it's always one millisecond between the execution trace log All right, so the last feature that I wanted to cover with you guys Is shown through this again window show view serial wire viewer And is the statistical proofing This is the only one that requires the application to be running for a while To then how to show the information So to ensure that we all have the same configuration here Enabling the PC same thing the time stamps I've kept the previous trace exceptions And I'm also using only the port zero as the default I removed the 31 for this particular measurement So by hitting okay, I can Start the trace and then start the code execution I'm going to wait for a few milliseconds And now that we have plenty of time already spent I can suspend the application And it will actually show to us the amount of percentage time it spent on each and every function So of course we are going to spend most of our time on the how delay and the get tick Which is part of the how delay function And we can see that's roughly 99.86% of our application is spent there There's also a lot of time spent on the sys tick handler So all these three functions are part of the Combine how delay and we do have a small amount of time Spend on the itms and char because of the print f functions So if we actually want to make our code slightly More proficient we can see where it's painting most of its time So this is very similar to the task manager of your firmware So you know where you're spending most of your time You can decide if it makes sense or not for your application code In our example, it does a lot of sense because it's using a huge delay And it's taking most of our processing time on that. So that was it guys I hope you had fun watching how to use the through wire viewer Don't forget to like and subscribe for more content And if you need further information, please visit st.com Thank you