Skip to main content
kraske
Visitor II
October 7, 2016
Solved

Issues when setting SWJ_CFG in AFIO->MAPR to SWJ_NOJTAG

  • October 7, 2016
  • 5 replies
  • 2244 views
Posted on October 07, 2016 at 08:39

I'm using the STM32F103.

Setting the controller to __HAL_AFIO_REMAP_SWJ_NOJTAG on startup. Which means I want to use only the SW pins and the port pins PA15, PB3 and PB4 should be normal IO pins.

I observed the following problem:

Unfortunately the related bits in AFIO->MAPR are write only. Reading these three bits is undefined. In fact, depending on the settings of AFIO->MAPR I observed that a 0x4 is read back if a 0x2 was written. So far it is ok as we can't rely on the read bits.

Unfortunately the code in stm32f1xx_hal_gpio_ex.h relies on these read back bits of SWJ_CFG. This is the case in all of the macros which uses MODIFY_REG(AFIO->MAPR...

These macros reads back AFIO_MAPR. When reading back AFIO_MAPR you also read back the undefined bits of SWJ_CFG. And when writing back to AFIO_MAPR, you write a different (or wrong) value into SWJ_CFG.

    This topic has been closed for replies.
    Best answer by Jalon Wong
    Posted on April 13, 2018 at 08:49

    Hi,I found the problem was solved in new version.Thanks !

    5 replies

    Walid FTITI_O
    Visitor II
    October 7, 2016
    Posted on October 07, 2016 at 11:00

    Hi kraske.robert, 

    Thanks for the feedback. I submit a request internally for investigation in this subject.

    -Hannibal-

    Dmitry Novikov
    Associate
    December 21, 2016
    Posted on December 21, 2016 at 09:20

    Hi, I have same error with F100 MCU.

    https://community.st.com/0D50X00009XkYWnSAN

     
    Jalon Wong
    Associate
    March 20, 2018
    Posted on March 20, 2018 at 03:55

    I also have this problem and I found this problem affects not only MODIFY_REG(AFIO->MAPR but also SET_BIT(AFIO->MAPR, e.g. #define __HAL_AFIO_REMAP_USART1_ENABLE() SET_BIT(AFIO->MAPR, AFIO_MAPR_USART1_REMAP)

    ST Technical Moderator
    March 22, 2018
    Posted on March 22, 2018 at 15:04

    Hello

    jalonwong

    ,

    Please usethenew patch for STM32CubeF1 Firmware Package v1.6.1 and let me know if this problemexists.

    Best Regards,

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Jalon Wong
    Jalon WongBest answer
    Associate
    April 13, 2018
    Posted on April 13, 2018 at 08:49

    Hi,I found the problem was solved in new version.Thanks !