STM32CubeMX generated project for STM32L152C-DISCO board without any modification, however it shows "can't access target. Shutting down debug session" during debugging pass MX_GPIO_Init();
Initialize all peripherals with their default Mode? Yes
Give project name "test"
Toolchain/IDE changed to MDK-ARM (min version v5.27)
Open project in uVision
compile it, and then start debugging
step over HAL_Init();
step over SystemClock_Config();
step over MX_GPIO_Init();();
step over MX_ADC_Init();
at this point, the debug show Debugger - Cortex-M error:"Cannot access target. Shutting down debug session" (as shown in the attached screenshot) and get out of debugger mode after you click on "OK".