2017-07-18 11:05 AM
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.
#stm32f103 #afio #njtrst #jntrst #pb4 #remap #swj #stm32 #stm32f1Solved! Go to Solution.
2017-07-19 05:05 AM
Hello!!
you must call first __HAL_RCC_AFIO_CLK_ENABLE();
2017-07-19 05:05 AM
Hello!!
you must call first __HAL_RCC_AFIO_CLK_ENABLE();
2017-07-19 12:29 PM
That was it, thanks!