This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ST-Link Debugger - Cortex-M Error

Hello everybody,

I get trouble when I launch the debug session with Keil MDK-Lite Version: 5.26.2.0.
ST-Link/V2 debugger frimware version is V2J33S7.

The microcontroller used for this project is STM32L476 family.

I get this message error when I click "Run" in debug session:

Debugger - Cortex-M Error
Cannot access target.
Shutting down debug session.

Tried solutions:
- Upgrading the firmware of the ST-Link.
- Help of this topic: http://www.keil.com/forum/63355/

For more explanation:
When I do step-by-step at the beginning of the debug session or a run with a breakpoint at _Set_GPIO_PA11(), I didn't get trouble but if I do run I get the previous error message at instruction:

_Set_GPIO_PA11();

When I comment this line, I didn't get in trouble with debug session.

I really don't understand because GPIOA.11 (eq. PA11) is not a system IO or anything else.

The generated code and configuration is made with STM32CubeMX (MX.5.2.0 version) and the "useful" code is below:

/* I tried both macros and still same error message */
//#define _Set_GPIO_PA11()      do { GPIOA->ODR |=  GPIO_ODR_OD11; \ 
//                              } while(0)
#define _Set_GPIO_PA11()        do { GPIOA->BSRR = GPIO_BSRR_BS11; \ 
                                } while(0)
/*
...
some other variables initialization
...
*/
/** Variables initialization -----------------------------------------------*/
/*
    here is the variables initialization but no need to display them
*/
/** MCU Configuration-------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    HAL_Init();

/* Configure the system clock */
    SystemClock_Config();

/*** Initialize all configured peripherals ***/
    MX_GPIO_Init();
    MX_ADC1_Init();
    MX_DAC1_Init();
/* Rangefinder communication bus init */
    MX_I2C1_Init();
/* Temperature sensor communication bus init */
    MX_I2C2_Init();

/* Sequence Timer */
    TIM1_Init();

/* Initialize UART communication */
    USART1_UART_Init();

/*** Rangefinder activation ***/
    /* Set GPIO active */
    _Set_GPIO_PA11();
    /* ...
    code continue
    ... */

If somebody could help me, I will be really grateful :)

Thanks

Louis

  • That's not messing with one of the pins needed by the debugger (ST-Link), is it ... ?

  • Hello Andy,

    I don't think there is a messing with one of the pin of ST-LINK.

    Here is the cable connection I made:

    My application connection       ST-LINK/V2 ISOL connection
    Pin     Signal                  Pin     Signal
    1       P1V8_UC                 1       VAPP
    2       RESETn_JTAG             3       TRST
    3       JTAG_TDI                5       TDI
    4       JTAG_TMS                7       TMS_SWDIO
    5       JTAG_TCK                9       TCK_SWCLK
    6       JTAG_TDO                13      TDO_SWO
    7       UC_RESETn               15      NRST
    8       GND                     12      GND
    9       GND                     18      GND
    10      GND                     20      GND
    

    Here is the ST-LINK/V2 ISOL pinout from 20-pin connector:

    ST-LINK/V2 ISOL connection
    Pin     Signal
    1       VAPP
    2       VAPP
    3       JTAG TRST
    4       NC (not connected)
    5       TDI
    6       NC
    7       TMS_SWDIO
    8       NC
    9       TCK_SWCLK
    10      NC (SWIM)
    11      NC
    12      GND
    13      TDO_SWO
    14      NC (SWIM)
    15      NRST
    16      NC
    17      NC
    18      GND
    19      NC
    20      GND
    


    I don't understand why the debugger is shutting down the debug session while I run the code without breakpoint. The problem is IO PA11 drive low to high. Because when I comment the line:

    _Set_GPIO_PA11();
    


    The code execution is good without any debug session shutting down.

    Have you ever seen this trouble?

    Kind regards,
    Louis

  • So check to be certain!

    To spell it out: is PA11 shared with one of the debug lines ... ?

  • I am certain, every useful pins are well-connected.

    Here is the differents alternative functions mapped on PA11:

    TIM1_CH4
    TIM1_BKIN2
    USART1_CTS
    CAN1_RX
    OTG_FS_DM
    TIM1_BKIN2_COMP1
    EVENTOUT
    

    I tried to change init functions order (GPIO_Init()) is the last init function before variables initialization but still same problem...

  • Former Member
    0 Former Member in reply to Louis Fournier

    Hi,

    Did you ever find a resolution to this issue?  I am having the same error.   I'm using a Nucleo L476RG and Keil.  I don't immediately see a tie in to the debugger on the Nucleo board in my utilized pins.  For my project, I'm using PA2, PB3, PA9, PB13-15.

    Thanks,

    Frank