Stufin
Home Quick Cart Profile

ST-Link V2 Programmer

Buy Now on Stufin

Debugging

The programmer enables debuggers to access the target microcontroller's memory and registers, facilitating the identification and correction of errors.

Verification

The programmer can be used to verify the correctness of the programmed firmware, ensuring that the target device operates as intended.

Key Features

  • Compatibility: The ST-Link V2 Programmer is compatible with a wide range of STM32 microcontrollers, including STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7, and STM32L0 series.
  • High-Speed Programming: The programmer supports high-speed programming with a maximum clock frequency of 3MHz, allowing for rapid programming of large flash memories.
  • JTAG and SWD Interfaces: The programmer features both JTAG and SWD interfaces, providing flexibility in choosing the desired communication protocol.
  • USB Interface: The programmer connects to a host computer via a USB interface, making it easy to use with popular development environments such as Keil Vision, IAR Embedded Workbench, and STM32CubeMX.
  • Low Power Consumption: The programmer has low power consumption, making it suitable for use in battery-powered applications.
  • Compact Design: The programmer is compact and lightweight, making it easy to integrate into development environments and prototyping setups.
  • Robustness: The programmer is designed to withstand repeated use and handling, ensuring reliable performance over an extended period.
  • Windows, Linux, and macOS Compatibility: The programmer is compatible with popular operating systems, including Windows, Linux, and macOS.

Technical Specifications

Dimensions

50 mm x 20 mm x 10 mm (1.97 in x 0.79 in x 0.39 in)

Weight

10 g (0.35 oz)

Operating Temperature

0C to 50C (32F to 122F)

Storage Temperature

-20C to 70C (-4F to 158F)

Supply Voltage

5V (from USB interface)

Current Consumption

<50mA (typical)

Software Support

The ST-Link V2 Programmer is supported by a range of software tools, including
STM32CubeMXA graphical software configuration tool that allows for easy configuration and programming of STM32 microcontrollers.

Keil Vision

A popular integrated development environment (IDE) for developing and debugging embedded systems.

IAR Embedded Workbench

A comprehensive IDE for developing and debugging embedded systems.

Overall, the ST-Link V2 Programmer is a powerful and versatile tool that is essential for anyone working with STM32 microcontrollers. Its high-speed programming capabilities, compact design, and robustness make it an ideal choice for a wide range of applications, from rapid prototyping to production programming.

Pin Configuration

  • ST-Link V2 Programmer Pinout Guide
  • The ST-Link V2 Programmer is a popular debugging and programming tool for STMicroelectronics microcontrollers. It features a 10-pin connector that interfaces with the target device. Here's a detailed explanation of each pin, along with guidance on how to connect them:
  • Pinout Structure:
  • The ST-Link V2 Programmer has a 10-pin connector with the following structure:
  • | Pin # | Pin Name | Description |
  • | --- | --- | --- |
  • | 1 | VCC | Target voltage (usually 3.3V or 5V) |
  • | 2 | GND | Ground |
  • | 3 | SWCLK | Clock signal for the target device |
  • | 4 | SWDIO | Data signal for the target device |
  • | 5 | NRST | Reset signal for the target device |
  • | 6 | SWO | Serial Wire Output (optional) |
  • | 7 | GND | Ground |
  • | 8 | TX | UART transmit signal (optional) |
  • | 9 | RX | UART receive signal (optional) |
  • | 10 | VREF | Reference voltage (usually 3.3V) |
  • Pin Descriptions and Connection Guide:
  • 1. VCC (Target Voltage)
  • Connect to the target device's power supply (usually 3.3V or 5V).
  • Ensure the voltage level matches the target device's requirements.
  • 2. GND (Ground)
  • Connect to the target device's ground pin.
  • This pin is a common ground reference for the entire system.
  • 3. SWCLK (Clock Signal)
  • Connect to the target device's clock input (usually SWCLK or CLK).
  • This pin provides the clock signal for the target device's debugging interface.
  • 4. SWDIO (Data Signal)
  • Connect to the target device's data input/output (usually SWDIO or IO).
  • This pin is used for bi-directional data transmission between the ST-Link V2 and the target device.
  • 5. NRST (Reset Signal)
  • Connect to the target device's reset input (usually NRST or RST).
  • This pin is used to reset the target device.
  • 6. SWO (Serial Wire Output)
  • Optional: Connect to the target device's serial wire output (usually SWO or SWV).
  • This pin is used for tracing and debugging purposes.
  • 7. GND (Ground)
  • Connect to the target device's ground pin.
  • This pin is a common ground reference for the entire system.
  • 8. TX (UART Transmit Signal)
  • Optional: Connect to the target device's UART transmit pin (usually TX or UART_TX).
  • This pin is used for serial communication between the ST-Link V2 and the target device.
  • 9. RX (UART Receive Signal)
  • Optional: Connect to the target device's UART receive pin (usually RX or UART_RX).
  • This pin is used for serial communication between the ST-Link V2 and the target device.
  • 10. VREF (Reference Voltage)
  • Connect to the target device's reference voltage input (usually VREF or VDD).
  • This pin provides a reference voltage for the target device's analog-to-digital converter (ADC).
  • Important Notes:
  • Always ensure the voltage levels and pin connections match the target device's specifications.
  • Use a suitable adapter or cable to connect the ST-Link V2 to the target device.
  • Refer to the target device's datasheet and ST-Link V2 documentation for specific connection guidelines and requirements.

Code Examples

ST-Link V2 Programmer Documentation
Overview
The ST-Link V2 is a popular, low-cost in-circuit debugger and programmer for STM32 microcontrollers. It allows developers to debug and program their STM32-based projects with ease. This documentation provides an overview of the ST-Link V2 programmer, its features, and code examples to demonstrate its usage in various contexts.
Features
In-circuit debugging and programming for STM32 microcontrollers
 Supports JTAG and SWD interfaces
 USB 2.0 full-speed interface
 Compatible with Windows, macOS, and Linux operating systems
 Open-source software support through the OpenOCD project
Code Examples
### Example 1: Programming an STM32F103RB Microcontroller using ST-Link V2 and Keil Vision
In this example, we will program an STM32F103RB microcontroller using the ST-Link V2 programmer and Keil Vision IDE.
Hardware Requirements
STM32F103RB microcontroller
 ST-Link V2 programmer
 Keil Vision IDE (version 5 or later)
Software Requirements
Keil Vision IDE (version 5 or later)
 ST-Link V2 driver (install from Keil Vision IDE)
Code
Create a new project in Keil Vision IDE and add the following code to the `main.c` file:
```c
#include <stdio.h>
#include <stdint.h>
#include "stm32f10x.h"
int main(void) {
    // Initialize the GPIO Peripheral
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
// Set GPIO Pin 5 as Output
    GPIO_InitTypeDef GPIO_InitTypeDef;
    GPIO_InitTypeDef.GPIO_Pin = GPIO_Pin_5;
    GPIO_InitTypeDef.GPIO_Mode = GPIO_Mode_Out;
    GPIO_InitTypeDef.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA, &GPIO_InitTypeDef);
while (1) {
        // Toggle GPIO Pin 5
        GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_SET);
        delay(500);
        GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_RESET);
        delay(500);
    }
}
void delay(uint32_t time) {
    for (uint32_t i = 0; i < time; i++);
}
```
Programming Steps
1. Connect the ST-Link V2 programmer to the STM32F103RB microcontroller.
2. Open Keil Vision IDE and create a new project.
3. Select the STM32F103RB microcontroller and the ST-Link V2 programmer as the debug interface.
4. Compile and download the code to the microcontroller using the ST-Link V2 programmer.
5. Observe the LED connected to GPIO Pin 5 toggling on and off.
### Example 2: Debugging an STM32L476VG Microcontroller using ST-Link V2 and OpenOCD
In this example, we will debug an STM32L476VG microcontroller using the ST-Link V2 programmer and OpenOCD.
Hardware Requirements
STM32L476VG microcontroller
 ST-Link V2 programmer
Software Requirements
OpenOCD (version 0.10 or later)
 ST-Link V2 driver (install from OpenOCD)
Code
Create a simple C program to blink an LED connected to GPIO Pin 5:
```c
#include <stdio.h>
#include <stdint.h>
#include "stm32l4xxxx.h"
int main(void) {
    // Initialize the GPIO Peripheral
    LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
// Set GPIO Pin 5 as Output
    LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_5, LL_GPIO_MODE_OUTPUT);
while (1) {
        // Toggle GPIO Pin 5
        LL_GPIO_TogglePin(GPIOA, LL_GPIO_PIN_5);
        delay(500);
    }
}
void delay(uint32_t time) {
    for (uint32_t i = 0; i < time; i++);
}
```
Debugging Steps
1. Connect the ST-Link V2 programmer to the STM32L476VG microcontroller.
2. Open a terminal and navigate to the OpenOCD installation directory.
3. Run the following command to start the OpenOCD server:
```
openocd -f interface/stlink-v2.cfg -f target/stm32l4x.cfg
```
4. In another terminal, use the `telnet` command to connect to the OpenOCD server:
```
telnet localhost 4444
```
5. Use the `reset` command to reset the microcontroller and start the debug session:
```
reset
```
6. Use the `continue` command to start the program execution:
```
continue
```
7. Observe the LED connected to GPIO Pin 5 toggling on and off.
Note: The above examples are just a demonstration of how to use the ST-Link V2 programmer in different contexts. You may need to modify the code and configuration files to suit your specific project requirements.