AnsweredAssumed Answered

STM32F103: How to use PB4 as normal GPIO? NJTRST remap not working.

Question asked by Alfonso L on Jul 18, 2017
Latest reply on Jul 19, 2017 by Alfonso L

Hello. I need to use PB4 as a normal GPIO digital output pin. I’m using the HAL for developing the firmware. The code I use for configuring GPIO is:

 

__HAL_AFIO_REMAP_SWJ_NONJTRST();

__HAL_RCC_GPIOB_CLK_ENABLE();

GPIO_InitTypeDef config_gpio = {0};

config_gpio.Pin = GPIO_PIN_4;

config_gpio.Mode = GPIO_MODE_OUTPUT_PP;

config_gpio.Pull = GPIO_NOPULL;

config_gpio.Speed = GPIO_SPEED_FREQ_HIGH;

HAL_GPIO_Init(GPIOB, &config_gpio);

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_RESET);

 

After that, PB4 is always pulled high and I can't set it low, probably because it keeps behaving as NJTRST, so I can’t use it as a normal output.

 

It seems that the macro __HAL_AFIO_REMAP_SWJ_NONJTRST() doesn’t do anything.

 

I would appreciate any advice.

Thanks.

Outcomes