cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to program or connect using Cube Programmer after this code

PSaga.1
Associate II

Hello,

I was trying to understand the leakage in my STM32L073 based board. After programming with this code for 3 different boards I am now unable to connect to board both using the programmer and IDE. I have tried BOOT0 and nRST combo to connect but have failed. What could be the reason and how do deal with this?

 

 

#include "stm32l0xx_hal.h"

void main() {
    // Configure PC10 and PA12 as pull-downs
    GPIO_InitTypeDef GPIO_InitStruct = {0};

    __HAL_RCC_GPIOC_CLK_ENABLE();
    __HAL_RCC_GPIOA_CLK_ENABLE();

    // Configure PC10 as input with pull-down
    GPIO_InitStruct.Pin = GPIO_PIN_10;
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

    // Configure PA12 as input with pull-down
    GPIO_InitStruct.Pin = GPIO_PIN_12;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    // Disable SysTick interrupt
    HAL_SuspendTick();

    // Clear wake-up flag
    PWR->CR |= PWR_CR_CWUF;

    // Enter Stop Mode
    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

    // After wake-up: reinitialize peripherals and resume SysTick
    HAL_ResumeTick();
}

 

 

 Thanks and regards 

1 REPLY 1
STea
ST Employee

Hello @PSaga.1 ,

It seems like you are entering stop mode and not configuring the correct event to get you out of it try to connect in CubePrgrammer with under reset option and then perform a full chip erase.

STea_0-1737130685868.png

Regards

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.