Skip to main content
Visitor II
May 4, 2020
Question

Why is the Halt() function not working?

  • May 4, 2020
  • 2 replies
  • 2756 views
#include <stm8l15x.h> 
#include <stm8l15x_pwr.h>
 
void main(void)
{
	GPIO_Init(GPIOA, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIOB, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIOC, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIOD, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Fast); 
	
	PWR_UltraLowPowerCmd(ENABLE);
	
	halt(); 
 
	while(1);
}

I'm using the STM8L151G4. I wrote the simplest program that only performs the Halt function. The current draw I'm measuring is 9.7 mA!! It's definitely not going into the ultra low power halt mode. What could cause the Halt function to not work?

    This topic has been closed for replies.

    2 replies

    Visitor II
    May 14, 2020

    Try to implement a short delay before calling "halt" or put it in the main loop. I had a similar issues with STM8L051 and it helped.

    TheUserAuthor
    Visitor II
    May 15, 2020

    I put in a delay before calling halt (even two seconds) and it didn't make a difference...but thanks for the suggestion.

    Visitor II
    May 15, 2020

    9.8 mA is surprising as well. This uC should consume less than 1 mA with default prescaler (16 Mhz / 8). If you are using a bare chip try to remove any peripherials and set up the pins as inputs with pull-ups.

    GPIO_Init(GPIO____, GPIO_Pin_All, GPIO_Mode_In_PU_No_IT);

    TheUserAuthor
    Visitor II
    May 16, 2020

    I was actually able to get halt mode to work on a STM8L151K4 bare chip. It still doesn't work on the STM8L151G4, so I'll have to figure that out...