cancel
Showing results for 
Search instead for 
Did you mean: 

Can't connect to STM32C011 after setting SWD and SWCLK as ADC.

avi448
Visitor

As the subject says. I am not able to connect and re-program or debug my STM32C011 ICs after I set up SWCLK and SWDATA as ADC on my firmware.

NRST pin is connected and it still doen't work

I know this is expected behaviour, but I should be able to re-program it by connecting the NRST pin to the debugger, however, this is still not fixing the problem.

 

 

1 REPLY 1
TDK
Super User

If you configure the SWD pins as something else, you will be unable to use SWD to access the chip.

To recover, here are your options:

  • Press "Connect" in STM32CubeProgrammer after the chip starts but before the pins get reprogrammed. Depending on how quickly you reassign the pins, this may be difficult, but there is probably a window of at least tens of ms where you can connect.
  • Boot into the bootloader, which will prevent SWD pins from being reassigned. Then you can connect with STM32CubeProgrammer. On most chips, by default, this can be done by holding BOOT0. On the STM32C0, this is not the case.
  • That's it. The "Connect under Reset" option does not do this. Connecting NRST to the programmer will let it control NRST but it will not connect while NRST is low, despite the naming. If your program reassigns SWD pins quickly, this will fail.

Some suggestions:

  • Avoid reassigning SWD pins.
  • If you need to use SWD pins, reconfigure option bytes to boot into the bootloader when BOOT0 is high on reset to recover.
  • If you can't do either of those, put HAL_Delay(250) somewhere before the pins are re-assigned. This gives you a small window to connect after the chip starts up.
If you feel a post has answered your question, please click "Accept as Solution".