hi,
I'm trying to switch the tiny13 in my circuit to power down mode. The following asm-code assembled with AvrStudio causes a current consumption of 0.2uA, which according to the datasheet is what is to be expected:
however, the same code in C, on the same circuit and same setup, compiled with avr-gcc produces a current consumption of 2.6uA:
Now I need to know what causes the extra 2.4uA when using avr-gcc.
Commenting out the PORTB stuff (leaving the ports undefined) makes no difference btw and neither does defining all ports as output or disabling the pullup resistor for PB4. I've also tried using the asm sleep function instead of avr-libc's sleep_cpu() function, but to no avail.
Any help would be greatly appreciated, I've already posted this in several other forums, but so far nobody has been able to figure out whats going on here.
thanks in advance,
Dominik
I'm trying to switch the tiny13 in my circuit to power down mode. The following asm-code assembled with AvrStudio causes a current consumption of 0.2uA, which according to the datasheet is what is to be expected:
Code:
CSEG
rjmp start
start: nop
nop
cli
ldi r16 ,LOW (RAMEND) // initialize stack pointer
out SPL ,r16
ldi r16 ,0b00110000 // set SE and SM1 bits (power down mode)
out MCUCR ,r16
sleep
however, the same code in C, on the same circuit and same setup, compiled with avr-gcc produces a current consumption of 2.6uA:
Code:
#include <avr/io.h>
#include <stdint.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
int main(void)
{
cli();
DDRB=0xff; // PB1-5 = Output
DDRB&=~(1<<4); // PB4 = Input
PORTB|=(1<<4); // Pullup for input
MCUCR=0b00110000;
// asm("sleep");
sleep_cpu();
while(1)
{
}
return 0;
}
Now I need to know what causes the extra 2.4uA when using avr-gcc.
Commenting out the PORTB stuff (leaving the ports undefined) makes no difference btw and neither does defining all ports as output or disabling the pullup resistor for PB4. I've also tried using the asm sleep function instead of avr-libc's sleep_cpu() function, but to no avail.
Any help would be greatly appreciated, I've already posted this in several other forums, but so far nobody has been able to figure out whats going on here.
thanks in advance,
Dominik