0:07
hello everyone welcome to controllers
0:11
tech I got a lot of requests about
0:14
making videos with stm32 cube ID so I
0:18
will give it a shot today in this video
0:21
I am going to show you guys how to use
0:24
live expressions SWV trace and printf
0:28
debugging in cube ID using of course
0:32
stm32 I am using stm32f4 for 6r II
0:38
controller although it should work with
0:41
others too if you follow the procedure
0:44
properly so let's start the ide and
0:48
create our project in qmx select the
0:52
microcontroller here I am going to name
0:55
it as printf debug.trace click finish
1:00
and wait for the project to open first
1:04
thing I am going to do is set the clock
1:07
to the external crystal this is it
1:10
pretty much we don't need any additional
1:13
setup here I am going to set the onboard
1:20
led as output you don't have to do this
1:24
now let's move to the clock section I
1:28
have external crystal of 8 megahertz and
1:32
I am going to configure it to give me a
1:35
frequency of 180 megahertz
1:44
you can configure to any clock you want
1:54
so everything looks okay go to file and
1:59
click Save this will generate the
2:02
project next open the main dot C file
2:19
here first of all we need to include
2:22
stdio.h head of file for the printf to
2:52
next we need to overwrite the write
2:55
function with the following code printf
2:59
rely on write function and we are
3:02
modifying it to send the data to the ITM
3:06
so all the printf commands will forward
3:22
I am declaring a variable called count
3:25
which I will increment and then trace it
3:29
on SWV trace let's write the main
3:33
function now I will toggle the onboard
4:02
then increment the count variable then
4:12
print the value of the count variable on
4:46
and give a small delay for all these
5:17
compile the code and hit the debug
5:33
choose stm32 application
5:46
in the debugger tab make sure the debug
5:51
scroll down and enable serial wire
5:55
viewer in the core clock typing your HC
5:59
LK frequency mine is set to 180
6:04
megahertz that I set up in the clock
6:06
configuration also make sure that the
6:09
live expressions is enabled hit OK and
6:13
wait for the debugger to launch
6:35
in the debugger we need to enable the
6:38
monitoring first go to the window show
6:42
view and enable the SWV trace and SWV I
7:00
click on any of these view go to setting
7:04
for the trace we need to input the
7:07
variable name comparator one is for the
7:11
ITM to print the printf output make sure
7:15
you select the ITM simulus port 0 press
7:31
the red button to enable the record
7:49
type the variable in the live expression
7:52
that you want to monitor
8:03
and finally start the debug
8:17
you can see all the features working
8:19
properly the delay I declared was very
8:35
let me just increase that to one second
9:01
let's launch the debug session again
9:09
this time I will not select the trace so
9:14
we will only monitor the print F output
9:22
sorry I forgot to turn on the record
9:25
button we can see the print F output now
9:35
and there is no trace as expected we can
9:47
go to settings enable the trace reset
9:50
the controller and start and it is back
10:01
similarly if you only want to use the
10:04
trace just remove the other from the
10:22
and you can see that only trace is
10:27
enabled now this is it guys
10:30
I hope you understood this video and you
10:33
will use these features in your programs
10:36
I will continue making videos with cube
10:39
IDE now if it doesn't screw up as it
10:42
used to you can read the description for