You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If millis() function appears anywhere in loop(), it prevents enetering to sleep mode. The position of millis() doesn`t matter, it could be after sleep_cpu().
micros() works normally.
#include <avr/sleep.h>
#include <avr/interrupt.h>
#include <avr/power.h>
#define LED PB0
void setup() {
pinMode(LED, OUTPUT);
delay(500);
}
void loop() {
analogWrite(LED, 0);
delay(200);
analogWrite(LED, 250);
delay(200);
analogWrite(LED, 0);
system_sleep();
millis();//commenting this line let attiny13 enter to sleep, if i uncomment it, led blinks continously
}
void system_sleep() {
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sei();
sleep_cpu();
}
The text was updated successfully, but these errors were encountered:
millis() in the MicroCore are watchdog timer based.
Do you still need help with this?
WDTCR &= ~(1 << WDTIE); because of the implementation of the millis() function it is necessary to disable the watchdog interrupt before entering sleep mode WDTCR |= (1 << WDTIE); after waking the cpu from sleep mode it is necessary to enable the watchdog interrupt again, otherwise the millis() function does not work
If millis() function appears anywhere in loop(), it prevents enetering to sleep mode. The position of millis() doesn`t matter, it could be after sleep_cpu().
micros() works normally.
The text was updated successfully, but these errors were encountered: