We have a project with STM32F051 and now we need to use UART2 and the only unused pins are the pins 37 (SWCLK) and 38. I know there is another post with this topic. STM32 Using SWCLK and USART on the same PCB.
In this post Ben Voigt wrote
But you can put the pin configuration code in a conditional (if) and skip switching the pin to UART some of the time.
Now my question:
Is there any possibility to know if the device is in DEBUG mode?
I'd use this as condition to configure the UART or not. For me it's not needed to have this UART pin during debugging, it's only used in normal operation.