Activating SLEEP in Attiny13

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times
Contact:

Activating SLEEP in Attiny13

Post 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

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Activating SLEEP in Attiny13

Post by mnf »

Hi Iain,

Need to

Code: Select all

#include <avr/sleep.h>
(in a C block - before using sleep())

Martin

iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times
Contact:

Re: Activating SLEEP in Attiny13

Post by iain wilkie »

Hi Martin,

After a bit of investigation found that this worked in a C block

asm ("sleep");

iain

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Activating SLEEP in Attiny13

Post by mnf »

Good. I think the call to sleep(); just expands to a sleep instruction if you include the header file....

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Activating SLEEP in Attiny13

Post by jgu1 »

Hi Martin!

I suppose this also is for the Arduino, please, And how do I give it a " :D wakeupcall" again?

I have no experience with this feature.

Br Jorgen

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Activating SLEEP in Attiny13

Post 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

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Activating SLEEP in Attiny13

Post by jgu1 »

Thank you Martin. :D

Jorgen

Post Reply