cancel
Showing results for 
Search instead for 
Did you mean: 

Couple of days ago, I configured the mcu (stm8l-discovery) in low power mode to see the current consumption. But if i run the same code again, I was not able to see the same results. The mcu is not entering the low power mode

VSrin
Associate II

#include "iostm8l.h"

#include <stdint.h>

#include <stdio.h>

#include "defs.h"

main()

{

CLK_DIVR = 0x00; // Set the frequency to 16 MHz

 while(1)

{

if (PWR_CSR2 & 0x01 == 0x01)

{

break;

}

}

PWR_CSR2 |= (1<<1);

while (1)

{

halt();

}

}

4 REPLIES 4

I don't know if this is the reason of your troubles (never used STM8), but you have an error in your code: "==" has higher operator precedence than "bitwise AND".

if (PWR_CSR2 & 0x01 == 0x01)

should be

if ((PWR_CSR2 & 0x01) == 0x01)

VSrin
Associate II

still not working. I don't know why the mcu is not entering the halt mode

Cristian Gyorgy
Senior III

Hello!

How do you know it does not enter halt?

When i programmed on friday - 9/13 the current was 0.86uA. When i run the same code again on monday - 9/16, i got current as 0.20mA