Skip to main content
MHoss.1
Associate III
March 25, 2020
Question

Suppressing repurposed SWD pins for debug

  • March 25, 2020
  • 2 replies
  • 558 views

In my project the debug pins are used for the release version but naturally I would like to debug the code. Right now I have a debug macro and using #ifndef in the middle of MX_GPIO_Init function to avoid initializing debug pins. These conditions are outside of the user defined code and will be overwritten when the code is regenerated. Is there any descent way around it other than just remembering to add them every time?

This topic has been closed for replies.

2 replies

TDK
March 25, 2020

You can make your own code to re-initialize them anywhere within the user code. No need to rely on parts of CubeMX's you don't want. Make them SWD in CubeMX, and initialize them somewhere else in user code once you've identified a "release" version.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MHoss.1
MHoss.1Author
Associate III
March 25, 2020

This works great, thank you. The only thing is that if I leave those pins in reset_state (or mark them as SWD), then the label will be taken off in the CubeMX. This is an easy fix on my side, I just add them in a user code block in main.h but if a hardware person opens up the cube file, they will not find it. Anyway around it?