Skip to main content
Visitor II
March 9, 2019
Solved

TIM2 remap causes an stlink error

  • March 9, 2019
  • 3 replies
  • 1810 views

Hello, please help me.

I use stm32f103rc mcu, stlink v2 and keil uvision5.

So executing

AFIO->MAPR |= AFIO_MAPR_TIM2_REMAP_FULLREMAP;

causes stlik connection error.

Algorithm:

  1. Flash the MCU with keil uvision.
  2. Step to remmaping line in code. In this stage everything works fine.
  3. "Cannot access target" "shutting down debug session"
  4. After this debugger no longer sees MCU. "No target connected" "error: target dll has been cancelled. Debugger aborted!"
  5. Connect to MCU under reset, erase flash.
    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    One might guess that the TIM2 pins conflict with the JTAG or SWD pins PA13/PA14, etc.

    3 replies

    Graduate II
    March 9, 2019

    One might guess that the TIM2 pins conflict with the JTAG or SWD pins PA13/PA14, etc.

    March 9, 2019

    Hi Clive, glad to meet you). No JTAG used, no SWD conflicted. 46SWDIO 49SWCLK 14,15,16,17 TIM2 remap to 50,55,29,30.

    March 10, 2019

    Clive was wright. SWD turn off while execute

    AFIO->MAPR |= AFIO_MAPR_TIM2_REMAP_FULLREMAP;

    I use

    __HAL_AFIO_REMAP_TIM2_ENABLE();

    Instead. Is it because SWJ_CFG bits in AFIO_MAPR is only writable? How it worked in my old project?

    Thank you.

    Visitor II
    March 18, 2019

    I have a stm32f411re board and I have the same problem. But I don't know how to connect under reset mode and erase cpu, can u help me?

    St-link utility or cube programmer erorr says "no stm32 found" or "cannot connect the target"

    Also in the mass storage there is a fail document that says "the interface firmware failed to reset/halt the target mcu"