Debug
Why is it needed?
Used for debugging STM32 microcontrollers, the SWD interface supports the transfer of debugging information via the SWO output in real time, which is very convenient. Well, the Reset foot is needed to make it more comfortable to flash the controller in case the SWD interface is disabled. The reason is certainly attracted to the ears, because for the firmware it is always possible to press the Reset button with the handles, but let it be. For example, at the dawn of my acquaintance with STM32, I received a debug card from China with a flooded demo blinking LED and SWD turned off, I did not immediately understand how to connect to it.
The revision itself
We’ll need a scalpel, a soldering iron and a few centimeters of a very thin wire, I have this MGTF * some kind *. On these programmers, the connector is divided into two parts: the left one for STM8 and the right one for STM32, so the existing Reset is not suitable for STM32, we will make our own.
First of all, cut off the tracks that go to unnecessary pins. On my first modified programmer, I cut off the Reset and SWIM legs, because I did not plan to work with STM8, but now I will use the excess leads 3.3 and 5 V (they are doubled on the connector) so as not to damage the programmer’s functionality, it will come in handy.
The wires must be soldered to the 18 (Reset) and 31 (SWO) legs of the microcontroller. That is still an activity, but with a certain skill it can be done. My wires went well into the holes on the board, which gave an additional fixation. In general, in an amicable way, we must immediately fix them with glue on the microcontroller. Soldered soldered through small resistors (let there be 22 ohms) to just cut off the pins.
You can close the case and sign new conclusions, so that you do not forget where to find it.
Checking SWO
To use SWO it is necessary:
– Activate the SWD ;
– enable the corresponding output (for microcontrollers STM32F103C this is PB3) on TRACESWO ;
– make sure that the SWO is included in the programming environment, and not semihosting ;
– in the header of the program to connect the library #include “stdio.h” ;
– In the program code, use printf (“Hello STM32 world! R n”) ;
You can view these messages through the terminal in the STM32 ST-LINK Utility program, or right during debugging In my environment (I use the IAR).
Testing the Reset
Suppose for some reason the SWD is disabled on the microcontroller: either you forgot to turn it on during initialization, or a new board came in with a wired demo program. It is possible to be stitched, of course, by pulling the Reset foot to the ground (usually there is a button on the debug cards), but this is not always convenient. You can just connect a contact from the programmer and go in automatic mode.
In the same program STM32 ST-LINK Utility select “Connect under reset” and connect to flash or clear the memory of the microcontroller.
Either in your IDE choose the appropriate item:
This will allow you to flash and enter the debugging mode, but once you get to the initialization of the periphery, the SWD will shut down and communication with the controller will be lost.
Thank you for attention, I hope someone will need it.