Skip to main content
Visitor II
September 16, 2019
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

  • September 16, 2019
  • 3 replies
  • 672 views

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

    3 replies

    Visitor II
    September 16, 2019

    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)

    VSrinAuthor
    Visitor II
    September 16, 2019

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

    Visitor II
    September 18, 2019

    Hello!

    How do you know it does not enter halt?

    VSrinAuthor
    Visitor II
    September 18, 2019

    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