cancel
Showing results for 
Search instead for 
Did you mean: 

Pin sharing problem with SWD and SPI3, GPIO

KKIM.6
Senior II

Hi. I'm developing a custom board using STM32WB09TEF7TR microcontroller.

I had a problem re-accessing the microcontroller using SWD once I finished programming one time.

I found that it is due to the SPI3 (PA3) and one GPIO pin (PA2) sharing the pin for SWD (SWCLK and SWDIO).

So, I want to control this microcontroller with two stages, "operation mode" / "programming mode", that change the pin setting from SPI3 / GPIO_out to not assigned pin for SWD.

 

Could you tell me what I can do about this?

I failed to change the pin setting using the function below.

 

void enter_SWD_mode(void)

{

GPIO_InitTypeDef GPIO_InitStruct = {0};

 

GPIO_InitStruct.Pin = GPIO_PIN_3;

GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 

GPIO_InitStruct.Pin = SYNC_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(SYNC_GPIO_Port, &GPIO_InitStruct);

 

APP_DBG_MSG("SWD Mode activated.\r\n");

}

0 REPLIES 0