DEV Community

Hedy
Hedy

Posted on

What is the R pin on the STM32 Blue Pill?

What is the "R" Pin?
On the STM32 Blue Pill board, the pin labeled "R" is connected to the Reset (NRST) signal of the STM32 microcontroller.

  • "R" stands for Reset.
  • It is electrically connected to the NRST pin of the STM32F103C8T6 chip.
  • Its function is to restart the microcontroller when pulled to a low logic level.

Technical Details & Function
Electrical Characteristics:

  • Type: Active-Low (the reset action happens when the signal is at a LOW voltage, i.e., 0V).
  • Normal State: The pin is normally pulled HIGH (to 3.3V) by an external pull-up resistor (typically 10kΩ) on the Blue Pill board.
  • Reset Trigger: When you momentarily connect this pin to GND (LOW), the microcontroller immediately resets.

What Happens During a Reset:
When the "R" pin is pulled low, the STM32:

  1. Immediately halts all program execution.
  2. Resets all peripherals (GPIO, UART, Timers, etc.) to their default states.
  3. The Program Counter (PC) jumps to the reset vector (the start of your program).
  4. The main() function is executed again from the beginning.
  5. The contents of SRAM are not guaranteed to be preserved (unless it's a software reset under specific conditions).

Physical Location on the Blue Pill
The "R" pin is located on the smaller pin header on the board, which is the "SWD Header".

text

  Blue Pill Top View
  ___________________
 | o o o o o o o o o |  <- Larger header (GPIOs)
 |_|_|_|_|_|_|_|_|_|_|
 | o o o o | | o o o |  <- Smaller header (Debug & Power)
    G  R  3 5  3  G
    N  .  . .  .  N
    D      3 V  D D
          V     A A
               T T
Enter fullscreen mode Exit fullscreen mode

From left to right on the small header, the pins are often labeled as:

  1. G - GND
  2. R - Reset (This is the "R" pin)
  3. 3.3V - 3.3V Power
  4. 5V - 5V Power (Input)
  5. 3.3V - 3.3V Power
  6. G - GND
  7. D - SWDIO
  8. D - SWCLK

Common Use Cases
1. Manual Reset Button
The Blue Pill has a physical push button labeled "RESET" (usually near the USB connector). Pressing this button physically connects the "R" pin to GND, causing a reset.

2. External Reset Circuit
You can connect an external switch, a microcontroller, or another digital circuit to the "R" pin to trigger a reset remotely.

Example Circuit:

text

"R" Pin ---/ --- GND
        (Switch)
Enter fullscreen mode Exit fullscreen mode

When the switch closes, it connects "R" to GND and resets the MCU.

3. Programmer/Debugger Control
When using an ST-LINK/V2 programmer/debugger, one of its wires (usually the one labeled NRST or RST) must be connected to the "R" pin. This allows the debugger to:

  • Reset the MCU before uploading new code.
  • Halt and resume program execution during debugging.
  • Perform a hard reset when necessary.

ST-LINK Connection to Blue Pill:

  • ST-LINK 3.3V → Blue Pill 3.3V
  • ST-LINK GND → Blue Pill GND
  • ST-LINK SWDIO → Blue Pill DIO
  • ST-LINK SWCLK → Blue Pill CLK
  • ST-LINK NRST → Blue Pill R <-- This connection is crucial!

4. System Supervision
In complex systems, a external watchdog circuit or a power management IC can be connected to the "R" pin to reset the STM32 if it crashes or behaves unexpectedly.

Important Notes & Troubleshooting
1. Floating Reset Pin:
If the "R" pin is left unconnected (floating), electrical noise can cause accidental resets. The onboard pull-up resistor prevents this, but in noisy environments, additional precautions might be needed.

2. Programming Issues:
If you are having trouble programming the Blue Pill (especially with a "Cannot connect to target" error), one of the first things to check is:

  • Is the ST-LINK's NRST pin properly connected to the Blue Pill's "R" pin?
  • Try manually pressing the RESET button on the Blue Pill just before starting the programming process.

3. Not a General Purpose I/O:
The "R" pin is dedicated for reset. You cannot use it as a regular GPIO pin for reading buttons or controlling LEDs. Attempting to configure it in software will have no effect or could cause problems.

4. Reset during Operation:
If your Blue Pill is resetting unexpectedly, check for:

  • Power supply issues (brown-outs)
  • Software bugs triggering the watchdog timer
  • Hardware shorts accidentally connecting the "R" pin to GND

Summary

  • The "R" pin = Reset Pin (NRST).
  • It's an active-low input that restarts the microcontroller.
  • Its primary uses are for the manual reset button and connecting to a debugger (ST-LINK).
  • It is essential for reliable programming and debugging.
  • It is not a configurable GPIO pin.

Top comments (0)