Page 1 of 1
Activating SLEEP in Attiny13
Posted: Fri Apr 17, 2020 9:49 am
by iain wilkie
Hi Guys,
How do I execute a SLEEP instruction in an Attiny13 to make it power down.
Prior to executing the instruction I understand I need to set MCUCR register to 0x30 and can use a C block to do this ... but I am not sure what I need to do next to execute the actual instruction in Flowcode ?
Found reference to using sleep(); but I get a compiler error for this !
Can anyone please help ?
Iain
Re: Activating SLEEP in Attiny13
Posted: Fri Apr 17, 2020 12:00 pm
by mnf
Hi Iain,
Need to
(in a C block - before using sleep())
Martin
Re: Activating SLEEP in Attiny13
Posted: Fri Apr 17, 2020 1:08 pm
by iain wilkie
Hi Martin,
After a bit of investigation found that this worked in a C block
asm ("sleep");
iain
Re: Activating SLEEP in Attiny13
Posted: Fri Apr 17, 2020 3:08 pm
by mnf
Good. I think the call to sleep(); just expands to a sleep instruction if you include the header file....
Re: Activating SLEEP in Attiny13
Posted: Fri Apr 17, 2020 4:50 pm
by jgu1
Hi Martin!
I suppose this also is for the Arduino, please, And how do I give it a "

wakeupcall" again?
I have no experience with this feature.
Br Jorgen
Re: Activating SLEEP in Attiny13
Posted: Fri Apr 17, 2020 7:22 pm
by mnf
See
https://microchipdeveloper.com/8avr:avrsleep for a description..
The processor is basically woken by an interrupt or a reset. It can possibly wake itself by generating a wdt (watchdog timer) interrupt..
I posted a 1s flasher using the wdt here
viewtopic.php?f=76&t=21832&hilit=wdt which worked well on the Arduino ATMega328 chip but sadly not on the AtMega8 chi
Martin
Re: Activating SLEEP in Attiny13
Posted: Sat Apr 18, 2020 5:53 am
by jgu1
Thank you Martin.
Jorgen