ST-Link Debugger - Cortex-M Error

Hello everybody,

I get trouble when I launch the debug session with Keil MDK-Lite Version:
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:

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:


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. */

/* Configure the system clock */

/*** Initialize all configured peripherals ***/
/* Rangefinder communication bus init */
/* Temperature sensor communication bus init */

/* Sequence Timer */

/* Initialize UART communication */

/*** Rangefinder activation ***/
    /* Set GPIO active */
    /* ...
    code continue
    ... */

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



More questions in this forum