Skip to main content
Explorer
January 17, 2025
Question

Unable to program or connect using Cube Programmer after this code

  • January 17, 2025
  • 2 replies
  • 680 views

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 

    This topic has been closed for replies.

    2 replies

    ST Employee
    January 17, 2025

    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

    Graduate
    January 21, 2025

    If there is a RESET key, try press and hold the RESET key while start programming.

    Wait until you see the connection prompt, release the RESET key and let the programmer to connect to the MCU.

    By setting BOOT0 to level HIGH, the MCU boot from internal bootloader other than your app in flash memory. If BOOT0 is set to HIGH and you can't connect to MCU, then check the clock signals.