Hi, I programmed the STM32G041C8T6 uC by keil Uvision without using any CMSIS or other library only including some basic files like the startup file and some kernel files about 6 files in total. I developped a basic simple Led program. Configuring port PA8 as output (MODER register) and set it low (ODR register) and a Led (Anode to VCC) lights up. Then enter an endless loop where (by mistake) port PB2 is toggled.I now have no access anymore to the uC. When flashing or erasing it shows 'SWD Communication Failure'. I swapped the ULINK-ME interface and the USB cable. I checked the SWDIO and SWCLK signals by scope and they show a digital behaviour on the corresponding uC pins. The Reset pin stays high. I pulled it low with a resistor and release it restarts the application. (Led lights up). I tried to erase the uC while holding the reset pin low. But then get a message "Could not stop Cortex-M device!"I remember some similair behaviour on another STM32 type which I could resolve by shorting the external oscillator. But by default now the internal 16MHz oscillator is used and can't be stopped.
I did not find a solution. Finally the uC was replaced. The troubling program with a blinking led was flashed and the led blinks. So probably something else went wrong.