cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L0 How do i disconnect the SW-DB once connected

Kevin Bain
Associate II
Posted on October 31, 2017 at 04:53

Hi, I am using an STM32L053xx in StandBy mode for 500ms and Run mode for 2ms.  I have noticed in StandBy my PCB draws about 120u amps more after the SW-DB has been connected.

To correct this I need to disconnect the SW-DB cable and power down the PCB.  When the PCB powers up it is drawing 120u amps less power.

Now the STM32L0 dosnt have a Batt pin so I have a fat cap keeping the power up for RTC etc.  This means a 'Power On' reset dosen't work or takes a long time.

I am assuming the MCU thinks its got a debugger attached and working harder to keep the debugger happy.

I have tried HAL_GPIO_DeInit(GPIOA, GPIO_PIN_13);    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_14); but still the current wont reduce without a power down reset.

Can anyone help??

I can test if the debugger is connected by using:  (this detects the debugger connected reliably)

   if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_13) && !HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_14)) {

    // Ye change the SW ports to DIO

    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_13);

    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_14);

Is there a flag or function I can call to disconnect the debugger??

Is there a nicer way to test if the debugger is connected??

Thanks

Kevin

1 REPLY 1
Kevin Bain
Associate II
Posted on November 14, 2017 at 02:30

I have found the problem and yes it's a software fix. I added:    

// Hard reset or from standby

volatile uint8_t harderest = ((RCC->CSR & RCC_CSR_PORRSTF) == RCC_CSR_PORRSTF) || ((RCC->CSR &       RCC_CSR_PINRSTF) == RCC_CSR_PINRSTF);

          RCC->CSR |= RCC_CSR_RMVF;

    if (!harderest) {

  // this one has the debugger in

   __HAL_RCC_APB2_FORCE_RESET();

   __HAL_RCC_APB2_RELEASE_RESET();

   }

Forcing this reset when not recovering from StandBy reduces the current by 130uA.

Changing the SW-DP to GPIO didnt effect the current.

Thanks Kevin