cancel
Showing results for 
Search instead for 
Did you mean: 

Why is the Halt() function not working?

TheUser
Associate II
#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?

5 REPLIES 5
WRost.1
Associate II

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.

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

WRost.1
Associate II

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);

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...

It turned out that the PCB the STM8L151G4 was on had a defect...I did not expect that. So the Halt function does work! Thank you for your suggestions.