cancel
Showing results for 
Search instead for 
Did you mean: 

Using SWD pins as GPIO

Ricko
Senior III

Hi,

at the moment on the STM32U5G9 we have the SWD pins (SWDIO and SWCLK) set to DEBUG, but we would like to also use them as GPIO after programming.

 

How do we switch them to GPIO at runtime?

 

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
STOne-32
ST Employee

Dear @Ricko ,

 

You can by software anytime at your application change the GPIOA_MODER to either Input or Output as below

IMG_0511.jpeg

 

IMG_0510.jpeg

 then  also  to remove or keep the internal pull-up/down resistors .  Routing these signals also is important at PCB  as they share with Debug connector or test points .

hope it helps you,

STOne-32

View solution in original post

4 REPLIES 4
STOne-32
ST Employee

Dear @Ricko ,

 

You can by software anytime at your application change the GPIOA_MODER to either Input or Output as below

IMG_0511.jpeg

 

IMG_0510.jpeg

 then  also  to remove or keep the internal pull-up/down resistors .  Routing these signals also is important at PCB  as they share with Debug connector or test points .

hope it helps you,

STOne-32

MM..1
Chief III

You can use normal init as for any other pins, but on moment init is executed, debuger lost connection.


@Ricko wrote:

we would like to also use them as GPIO after programming.


I would strongly advise against doing that!

as @MM..1 said, that means you will have no debug access.

If you must, then be sure to include access to NRST in your debug connector - otherwise you won't even be able to connect for programming.

Also, put in a time delay after startup before you re-purpose the pins - to give a chance to connect.

Thank you all ! :)

Good point about the NRST. I do have it connected already because I thought you always need it for programming.