Skip to main content
VSrin
Associate III
Question

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

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

}

}

    This topic has been closed for replies.

    4 replies

    After Forever
    Senior III

    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
    VSrinAuthor
    Associate III

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

    Cristian Gyorgy
    Associate II

    Hello!

    How do you know it does not enter halt?

    VSrin
    VSrinAuthor
    Associate III

    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