Skip to main content
Associate III
September 1, 2026
Solved

Using SWDIO/SWCLK (PA13/PA14) as standard GPIOs on STM32 (STM32H533) - How to still program the MCU?

  • September 1, 2026
  • 2 replies
  • 68 views

Hi everyone,

I'm currently working on a project using an STM32H533RET6, and I am running a bit short on available pins. I am considering reconfiguring PA13 (SWDIO) and PA14 (SWCLK) to use them as standard general-purpose I/Os for my application.

My main concern is about the flashing process. If I reconfigure these pins as regular GPIOs in my firmware, the SWD interface will be disabled as soon as the code starts executing.

My questions are:

  1. Is it generally possible to use PA13 and PA14 as regular GPIOs and still be able to flash new firmware onto the MCU?

  2. If yes, what is the best practice to avoid permanently locking myself out? Do I strictly need to connect the hardware NRST pin to my programmer (ST-LINK) and use "Connect under reset"?

  3. Are there any software tricks (like adding a delay before GPIO initialization) that you would recommend?

Obviously, I know that live debugging won't be possible once the pins are remapped, but I just need to make sure I can still update the flash reliably.

Any advice or shared experiences would be greatly appreciated. Thanks in advance!

Best answer by Andrew Neil

 I am running a bit short on available pins. I am considering reconfiguring PA13 (SWDIO) and PA14 (SWCLK) to use them as standard general-purpose I/Os for my application.

A wise person once said:

“If you don’t have enough resources to devote 10% to debug/diagnostics, then you don’t have enough resources”

(“resources” here includes pins)

You need to think really long and hard before doing this - it can cause you a great deal of grief!

That said:

  1. Is it generally possible to use PA13 and PA14 as regular GPIOs and still be able to flash new firmware onto the MCU?

Yes.

You will need to connect using hardware reset - so you will need to keep the NRST pin available.

Alternatively, provide some means in your code to revert these pins to SWD mode.

Maybe a startup delay?

 

2 replies

Andrew Neil
Andrew NeilBest answer
Super User
September 1, 2026

 I am running a bit short on available pins. I am considering reconfiguring PA13 (SWDIO) and PA14 (SWCLK) to use them as standard general-purpose I/Os for my application.

A wise person once said:

“If you don’t have enough resources to devote 10% to debug/diagnostics, then you don’t have enough resources”

(“resources” here includes pins)

You need to think really long and hard before doing this - it can cause you a great deal of grief!

That said:

  1. Is it generally possible to use PA13 and PA14 as regular GPIOs and still be able to flash new firmware onto the MCU?

Yes.

You will need to connect using hardware reset - so you will need to keep the NRST pin available.

Alternatively, provide some means in your code to revert these pins to SWD mode.

Maybe a startup delay?

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Associate II
September 1, 2026

You need NRST to force the STM32 into debug mode, then you can flash with any ST-Link.