Skip to main content
Super User
November 8, 2022
Solved

Incorrectly written AFIO_MAPR.SWJ_CFG bits in CubeF1/LL

  • November 8, 2022
  • 6 replies
  • 2084 views

In stm32f1xx_ll_gpio.h, LL_GPIO_AF_EnableRemap_SWJ(), LL_GPIO_AF_Remap_SWJ_NONJTRST, LL_GPIO_AF_Remap_SWJ_NOJTAG(), LL_GPIO_AF_DisableRemap_SWJ() all use

SET_BIT(AFIO->MAPR, AFIO_MAPR_SWJ_CFG_xxxxx);

which is incorrect, as SET_BIT is

#define SET_BIT(REG, BIT) ((REG) |= (BIT))

and the read value of AFIO_MAPR.SWJ_CFG field according to RM0008 is unpredictable.

JW

    This topic has been closed for replies.
    Best answer by Imen.D

    Hi @Community member​ ,

    Thank you for bringing this issue to our attention.

    I raised this internally along to our development team for fix.

    Internal ticket number: 138603 is created (PS: this is an internal tracking number and is not accessible or usable by customers).

    Imen

    6 replies

    Imen.DAnswer
    Technical Moderator
    November 9, 2022

    Hi @Community member​ ,

    Thank you for bringing this issue to our attention.

    I raised this internally along to our development team for fix.

    Internal ticket number: 138603 is created (PS: this is an internal tracking number and is not accessible or usable by customers).

    Imen

    Super User
    November 9, 2022

    Thanks, Imen!

    Jan

    @Imen DAHMEN​ 

    Super User
    November 12, 2022

    Hi Imen,

    Do folks who look at these tickets have also access/willing to look at the threads here? In other words, does posting additional related information/questions here make sense?

    In particular, as brought up by @Richard Jones​ on January 25, 2018 at 12:26, the following two things are in contradiction to each other:

    0693W00000WIAp8QAH.png 

    As the LL library already uses the "other combination" presumably with "no effect", it appears that the "forbidden" in the table is incorrect. Can this please be clarified once for all, too?

    Thanks,

    Jan

    @Imen DAHMEN​ 

    Super User
    February 17, 2024

    Hi @Imen.D ,

    I've submitted the issue brought up by original post at github.

    However, can you please have a look at the documentation issue from the second post?

    Thanks,

    JW

    Technical Moderator
    February 18, 2024

    Hi @waclawek.jan ,

    1- The Serial wire JTAG configuration APIs was already updated in the latest release of CubeF1 (V1.8.5) to use MODIFY_REG() instead of CLEAR_BIT() / SET_BIT() macros, as follow:

     

     

    __STATIC_INLINE void LL_GPIO_AF_Remap_SWJ_NONJTRST(void)
    {
    MODIFY_REG(AFIO->MAPR, AFIO_MAPR_SWJ_CFG, AFIO_MAPR_SWJ_CFG_NOJNTRST);
    }

     

     

    The other remap API's the AFIO_MAPR_SWJ_CFG bits are forced to 1 by default to avoid unpredictable SWJ_CFG bits. Example the LL_GPIO_AF_Remap_TIM2ITR1_TO_USB() API:

     

     

    __STATIC_INLINE void LL_GPIO_AF_Remap_TIM2ITR1_TO_USB(void)
    {
    SET_BIT(AFIO->MAPR, AFIO_MAPR_TIM2ITR1_IREMAP | AFIO_MAPR_SWJ_CFG);
    }
    

     

     

    2- I highlighted internally your reported doc limitation in the internal ticket number 173730 to push for RM0008 update and enhance the documentation errata correction.

     

    Super User
    February 18, 2024

    Thanks, @Imen.D 

    JW