Im using PA_14 (SWCLK) as Output mode in stm32f030f4 microcontroller.
I change state of this pin to output mode for a buzzer that is not in service at all time. At the end of the buzzer function I always try to configure the pin back to its default state(SWCLK) to make the chip ready for programming.
Im using this code to configure the PA_14 back to its SWCLK mode:
GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = GPIO_PIN_14; GPIO_InitStruct.Mode = GPIO_AF0_SWCLK; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH ; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
But after any small change in the state of pin, SWD mode never works and I can not program the microcontroller. I test other mode like Input mode too.
How is it possible to re enable the SWD mode at run time as discussed in this link: