cancel
Showing results for 
Search instead for 
Did you mean: 

Using SWD pin as as conventional IO?

astrid
Associate II
Posted on April 08, 2016 at 23:55

Can I, used SWD pin, for example on STM32F0, as SWD

when debugging

and flashing MCU and as little used IO ,

during normal

operation

?

If yes, how?
2 REPLIES 2
mark239955_stm1
Associate II
Posted on April 09, 2016 at 00:26

In principle, yes, you should be able to.

Without knowing your MCU it's hard to be too specific, but in general the pins used for SWD/JTAG default to AF mode on, AF ID 0.  In firmware, you can disable AF mode in the GPIO configuration for those pins using the Mode register.  They will then function as normal GPIO.

You would need some way to detect the requirement to change from SWD to GPIO mode and/or vice versa, perhaps a button or switch on a different pin.

Posted on April 09, 2016 at 00:45

You can just reconfigure the pins. Use them for functions you can easily live without while debugging or single stepping, or use other debugging techniques.

The pins would be ideal for LEDs for example, which would not interfere with debug operation in the finished design.

The BOOT pin should be usable to stop your code from actually running, and permit download, etc.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..