[ Log In ]
Newbie Hack Shirt Back
The STM32 ultra basic kit showing all of the components

STM32 Ultra Basic Kit Special Introductory Price!

$34.95
Qty:
The ARM STM32F030 Advanced kit with the book ARM Microcontrollers Programming and Circuit Building Volume 1

ARM Advanced Kit with Book Vol 1

$158.00
Qty:
Arm Microcontrollers programming and circuit building volume 1 by Patrick hood-Daniel front cover
ST Link v2 for STM32 and STM8 microcontrollers top view of all components

ST-Link v2 STM32 and STM8 Programmer

$9.95
Qty:
STM32F0 microcontroller and interface board top view

STM32 M0 MCU and Interface to Breadboard

$14.95
Qty:
Top view of the bluetooth module

Bluetooth Module

$17.50
Qty:
The ARM microcontroller beginners kit

ARM Microcontroller Beginners Kit (STM32F0)

$39.95
Qty:

ARM Microcontroller Intermediate Kit (STM32F0)

$89.95
Qty:

ARM Microcontroller Advanced Kit (STM32F0)

$119.95
Qty:

05. Arduino for Production!! How to Connect the ST-Link v2 to the ARM STM32 Microcontroller

The first circuit is made which is simply connecting the ST-Link v2 to the ARM microcontroller and adding an LED to one of the pins.

Previous Page: Introduction to the CoIDE

At this point, the IDE (Integrated Development Environment) software has been installed. The interface software that connects to the USB port called the ST-link has also been installed. If you don’t have the software installed, follow the links to these videos or go to newbiehack.com for more information.

For the circuits in these videos, I’ll be using a setup like this, which is the microcontroller soldered onto a breakout.

Image of the STM32F0 microcontroller soldered onto a breakout

The breakout is connected to three breadboards which provide access to all of the pins and also provides two tie-strips for each pin in line. You can get this prototyping setup here. In this video we’re going to setup the breadboards and add the components necessary to transfer programs from the IDE, from the computer, to this microcontroller using the ST-Link. The first thing we’ll do is tie all of the power rails from each breadboard together, so we have power (positive which is the VCC) and negative which is ground, so we can provide power to the microcontroller, connecting the power to the appropriate pins.

To do this, we will connect the positive and negative from each breadboard tie strips to the next one so the positive will go to the positive on each breadboard, the negative will go to the negative on each breadboard, so let’s get started. We’ll take the first wire, go from the negative to the negative on the other side, and then from the positive here to the positive.

Image of the first two power lines (gnd and vcc) conecting two of the breadboards

This side is complete, now we’ll do the other side connecting these two power rails together. We’ll start with the negative which is ground, to the negative on the other power rail, and then from the positive back to the positive. You want to make sure that the two wires are not touching. I’m going to move these apart a little bit just in case.

Now we need to find out which of these pins need to connect to ground and VCC. To do this, we’re going to use an STM32 F030 cheat sheet that describes what each pin does on this breakout board. You’ll find the first video explaining the ARM development and scroll down and you’ll see the diagram. Use the scroll bars to be able to see the entire diagram. On the left of the diagram you’ll find pins 1 through 30, then 31, 32, 33, 34 on the bottom. On the right, you’ll find the remaining pins, 35 through 64. So let’s see which pins are associated with power so we can power the microcontroller. Already we can see that the #1 pin is associated with power the VDD Digital Power Supply, so let’s go ahead and connect that one. As on the diagram, the #1 pin is located at the corner of the breakout board.

We’ll first bridge these two tie strips together; that’s associated with the #1 pin.

Image of pin

Now we want to take the #1 pin this tie strip and put it to the plus. For good measure I’m going to add a bypass capacitor which is a .1 microfarad capacitor. In general I’ll put this next to all of the power and ground connections and generally I’ll put them as close to the chip as possible but in this case there is only a single VDD and there is no ground next to it so I’m putting it at the closest place I can to the ground and the power.

Image of pin

On the STM32 F030 cheat sheet, we can see that there are ground and power supply pins at 12 and 13 but these are VSSA which is ground and VDDA which is power, but for the analog to digital converter. We’re not going to be connecting anything to these pins at this time since we’re not going to be using the analog to digital converter. Scrolling down, we do notice that pin 31 is VSS which is ground, and pin 32 which is the same as pin 1. We’re going to go ahead and plug both of these into the power rails, the ground into the minus and the VDD supply into the plus. Just like on pin 31 we’re going to extend the tie strips by connecting them together (31 and 32).

Image of pins

Take the 31 pin and connect it to minus rail and pin 32 goes to the plus rail.

Image of pins

Again we’ll use the bypass capacitor which is .01 uf and we’ll put it between the power and ground pins as close to the board as possible. The capacitor is spanning between pins number 31 and 32.

Image of a capacitor connecting across pins

Let’s check the other side of the board to see if there are any more. We have 63 and 64, ground and positive supply so let’s go ahead and connect those. We’ll do the same thing with the tie strips.

Image of pins 63 and 64 for power on the breakout

Image of pins 63 and 64 connecting their respective tie strips on the breadboard

63 is ground so we’ll take that one to the ground rail or negative rail. 64 is positive so take that one to the plus rail.

Image of pins 63 and 64 being connected to the power rails

Add another capacitor between pins 63 and 64.

Image show the .1 uf capacitor connected between pins 63 and 64

Now we need to connect the ST-Link v2 to the microcontroller.

Image of the ST-Link v2 and the pinout of the ST-Link v2 STM32 interface.

This will give us the ability to transfer programs to the microcontroller using this as an interface between the computer and the microcontroller. The ST-Link comes with a cable that has four female headers on each end that will connect to four pins on the back of the ST-Link.

The cable with female headers that is used to connect the ST-Link v2 tothe microcontroller

The pins we’re going to be using as the SWCLK, SWDIO, the SWCLK is the clock and the SWDIO is the data, input/output. We’ll be using the ground (GND) and the 3.3v. You also have a 5v connection if you need it, it gives you the option to use 5v on you board. You’ll notice there is a notch which corresponds to the notch that is on the left hand side of the diagram on the ST-Link. We’ll be using the ones on the other side and the pins that we’ll be using will be the ones on the top right looking from this direction. The first that we’ll connect is the SWCLK which is the clock and we’ll use the green wire for that.

First SWCLK wire connected to the back of the ST-Link v2 interface

So we have the green wire connected to the first pin and now we’ll go in order so we’ll use the blue for the SWDIO.

Second pin connection of SWDIO at the back of the ST-Link v2 programming interface

The ground pin is next, which is the next wire in the ribbon cable, which is purple.

Connecting the femal header to the 3.3v pin of the ST-Link v2 interface

The final pin is 3.3v, the power supply, and we’ll use the last pin, the gray one.

Connecting the ground pin on the ST-Link v2

Now we have all of our headers inserted into our pins connected. We can put the other side on the appropriate pins on the breadboard, but first we need to make these pins male so we can plug them into the breadboard. I’m going to use a header strip, and break off one for each female header.

Image of a strip of male header pins to be used to convert the female headers to male headers

I need to prepare this so I’ll have enough metal to go into the breadboard and go into the female header snugly, so I’m simply going to bring it between these pliers and bring it down even. When all four are done, each one can be inserted into the female header.

Image showing the male header inserted into the female header

They are now snug so they should stay in without a problem. Now we need to find out where to plug these into the breadboard.

The only pins we really need to find are for the SWCLK and the SWDIO. Let’s take a look and see where we can find them. The SWCLK is at pin 49 and the SWDIO is at pin 46. We don’t really need to be concerned with the ground and 3.3v because we’re just going to put those in the power rails anyway, so the 3.3v pin will go to the plus rail and the ground will go to the minus rail. The SWCLK which is my green wire is connected to pin 49 and the SWDIO which is my blue wire is on pin 46.

The SWDIO and SWCLK wires from the ST-Link v2 interface connected to the cooresponding STM32 microcontroller pins 46 and 49 on the breadboard

The pulling high and pulling low of these two pins (mentioned in the next paragraph) may not be necessary. Only use this technique if you have problems uploading code to the microcontroller. This condition is actually resolved internally within the microcontroller.

Because the SWDIO and SWCLK are floating pins, they need to be externally pulled high or pulled low. For the SWCLK, that pin needs to be pulled low. First I’m going to put a resistor on each pin. What I’m doing is taking this tie strip from the pin on the breakout board and I’m jumping to the next tie strip using a resistor. Since these tie strips aren’t connected, I can put a resistor across those and now I have a resistance between this tie strip and this tie strip. Now all we have to do is connect these tie strips to the appropriate power rail to bring this one low and this one high. We’ll start with the SWCLK and we’ll bring that low. We’ll place it on the tie strip and then the next pin will go to the negative rail. Now for the SWDIO, we’ll place that first on the positive and then on the tie strip for SWDIO. The SWCLK has a resistor and is being connected to the low, and the SWDIO has a resistor and is connected to the high which is 3.3v.

Now we’ll take the remaining wires which are the ground and 3.3v. The ground was the purple one and the 3.3v was the gray one. We’ll connect those to the power rail. We’ll take the ground (purple) and place it on the negative rail, and the 3.3v (gray) and place it on the positive rail.

The 3.3v and ground wires from the ST-Link v2 interface connected to the ground the VCC power rails on the breadboard

We’ve connected everything we need to be able to communicate to the microcontroller and send programs to it, but we haven’t added anything to the board that will communicate to us that the program is working. We’re going to add an LED to one of the pins and we’ll turn the LED on and off by controlling that particular pin. For the simple function of turning on and off an LED, I’m going to select pin PC6 which is connected to pin 37 on the breakout board. Since LEDs need resistors I’m going to add a 330 ohm resistor across the two tie strips that is connected to pin 37.

The 330 ohm resistor connecting across the two ties aligned with pin 37 PORTC Pin 6

The LED will be connected from that tie strip to the ground because when the pin is powered it will be on the positive side of the LED and then the negative side of the LED will be on ground. The ground side of the LED will be the side of the LED that has the flat.

Image of the LED connecting from the tie strip aligned with pin 37 of the STM microcontroller

The flat side of the ground side is the cathode, and the other side which is the positive side is the anode. This completes the circuit building for the first project, connecting the ST-Link interface to the microcontroller and connecting some device to be able to view our program working.


01. Arduino for Production!! Introduction to ARM Microcontrollers
02. Arduino for Production!! How to Instal and Set up the Arduino IDE (Integrated Development Environment) for the ARM Microcontroller
03. Arduino for Production!! How to Connect the ST-Link v2 ARM Programmer to your Computer
04. Arduino for Production!! How to Use the CoIDE (Adruino IDE) for ARM Microcontroller Development
05. Arduino for Production!! How to Connect the ST-Link v2 to the ARM STM32 Microcontroller
06. Arduino for Production!! How to Output to a Pin to Blink an LED on the ARM Microcontroller Part 1
07. Arduino for Production!! How to Output to a Pin to Blink an LED on the ARM Microcontroller Part 2
08. Arduino for Production!! How to Output to a Pin to Blink an LED on an ARM Microcontroller Part 3
09. Arduino for Production!! Can Not Connect to Target! How to Establish a Connection Again.
10. Arduino for Production!! How to Receive Input from a Pin for Push Button Input (GPIO) on the ARM Microcontroller
11. Arduino for Production!! How to Receive Push Button Input on the ARM Microcontroller Part 2
12. Arduino for Production!! How to Receive Stable GPIO Push Button Input on the ARM Microcontroller - Software Debouncing Part 1
13. Arduino for Production!! How to Receive Stable GPIO PUSH Button Input onthe ARM Microcontroller - Software Debouncing Part 2
14. Arduino for Production - How to Establish Software Debouncing on the ARM Microcontroller Exclusive
15. Arduino for Production!! How to Interface an LCD on the ARM Microcontroller Part 1
16. Arduino for Production!! How to Interface an LCD on the ARM Microcontroller Part 2
17. Arduino for Production!! How to Interface an LCD to an ARM Microcontroller Part 3
18. Arduino for Production!! How to Interface an LCD to the ARM Microcontroller Part 4
STM32 Microcontroller Experiments Livestream 5