AnsweredAssumed Answered

stm32cube not calling __HAL_AFIO_REMAP_SWJ_NOJTAG() in the right order?

Question asked by noobee on Apr 4, 2015
Latest reply on Apr 8, 2015 by STM32Cube-T

i'm pretty new to stm32, and even newer to the stm32cube HAL code generation.

i tried to configure it for an stm32f103cb device but with PB3/PB4 used for GPIO instead of the standard JTAG signals.

the generated code includes a call to  __HAL_AFIO_REMAP_SWJ_NOJTAG() in HAL_MspInit(). however, at this stage, SystemClock_Config() is not called yet. more important, i think __HAL_RCC_AFIO_CLK_ENABLE() is not called yet. thus, __HAL_AFIO_REMAP_SWJ_NOJTAG() has no effect and PB3/PB4 do not function as GPIO.

if i made another call to __HAL_AFIO_REMAP_SWJ_NOJTAG() just after __HAL_RCC_AFIO_CLK_ENABLE(), then all is working normally.

so, is there a bug in the code generator in that it is trying to set AFIO->MAPR before the AFIO clock is set up? (i would guess that's not supposed to happen).