Describe the problem. Is there a compile error? Post it.
Does it compile but not do what you expect? Described how its behavior differs from your expectations.
DrAzzy:
Describe the problem. Is there a compile error? Post it.
Does it compile but not do what you expect? Described how its behavior differs from your expectations.
thanks for reply. It's compile and upload without any problem but the chip can't be sleeping.
swe-dude:
here is what i use the sleep attiny13A, have fun.
#include <avr/sleep.h>
ISR(WDT_vect) {}
int main(void){
init();
{
WDTCR |= (1<<WDP3) | (0<<WDP2) | (0<<WDP1)| (1<<WDP0); //sleep 8s
WDTCR |= (1<<WDTIE);
sei(); // Enable global interrupts
set_sleep_mode(SLEEP_MODE_PWR_DOWN);// Use the Power Down sleep mode
Smajdalf:
How do you know the sleep is not working? There are some strange things in your code but I don't see any mistake that will prevent it to sleep.
I measure the ATTINY13A current with the multimeter it's drain 2.4 mAh but the ATTINY45 drain 900nA.
#include <avr/sleep.h>
#include <avr/interrupt.h>
int main (void) {
cli();
MCUCR=(1<<SE)|(1<<SM1);
sleep_cpu();
}
It simply disables interrupts, enables Power Down sleep and goes to sleep. If it does not sleep the ATTiny properly you either do something wrong or the chip is damaged. If it works there is probably a mistake in your code - it never goes into the branch which invoke sleep or you have a source enabled which wake up the ATTiny as soon as it goes to sleep.
Smajdalf:
Try to make a MWE code. Also you may try this:
#include <avr/sleep.h>
#include <avr/interrupt.h>
int main (void) {
cli();
MCUCR=(1<<SE)|(1<<SM1);
sleep_cpu();
}
It simply disables interrupts, enables Power Down sleep and goes to sleep. If it does not sleep the ATTiny properly you either do something wrong or the chip is damaged. If it works there is probably a mistake in your code - it never goes into the branch which invoke sleep or you have a source enabled which wake up the ATTiny as soon as it goes to sleep.