cancel
Showing results for 
Search instead for 
Did you mean: 

stm32cube not calling __HAL_AFIO_REMAP_SWJ_NOJTAG() in the right order?

noobee
Associate II
Posted on April 04, 2015 at 03:00

hi

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).

thanks

1 REPLY 1
stm32cube-t
Senior III
Posted on April 08, 2015 at 09:11

Hello,

You are correct this is an issue in the generated code.

The __HAL_AFIO_REMAP_SWJ_NOJTAG() call should be done after

__HAL_RCC_AFIO_CLK_ENABLE().

This should be fixed in a future release.