cancel
Showing results for 
Search instead for 
Did you mean: 

Suppressing repurposed SWD pins for debug

MHoss.1
Associate III

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?

2 REPLIES 2
TDK
Guru

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
Associate III

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?