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

More questions in this forum