2019-09-16 07:22 AM
#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();
}
}
2019-09-16 07:38 AM
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)
2019-09-16 08:07 AM
still not working. I don't know why the mcu is not entering the halt mode
2019-09-18 11:07 AM
Hello!
How do you know it does not enter halt?
2019-09-18 11:42 AM
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