Spotreba ATtiny v pwr-down mode
Rosko, Peter
Peter.Rosko@siemens.com
Středa Srpen 5 14:00:28 CEST 2009
zdravim,
mam problem s jednou minimalistickou aplikaciou, attiny13v, jedna LED+R
a jedno tlacidlo. cele to je vlastne watchdog s blikajucou LED ako
vystupom.
chcem to napajat z baterie, preto sa samozrejme snazim o minimalizovanie
spotreby. zapinam PWR-down mode a pri napajani cca 3V mam spotrebu nieco
cez 1mA. meriam to na 30 Ohm odpore v napajani.
detaily: kontaktne pole, Attiny13V (s attiny13 to iste), nadrotovany
konektor na ISP, jeden 100n kondik, ledka obycajna na PB0, tlacidlo na
PB1 voci zemi. cele to funguje ako ma. ako hodiny mam wdt oscilator,
pokial cas neexpiroval tak sa MCU zobudza kazde 2 sec. fuse su
vsetky(okrem SPIEN) povypinane
preco do haja to zerie tolko?
podla asm vypisu je vsetko spravne..., tuna je program
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
volatile uint16_t timer;
volatile uint8_t timecntr;
int main(void)
{
MCUSR = 0;
GIMSK = _BV(PCIE);
PCMSK = _BV(PCINT1);
DDRB = _BV(PB0); //outputs
PORTB = 0xff; //pull up for inputs
timer = 0;
sei();
for (;;)
{
if (timer == 0)
{
uint16_t i;
PORTB |= _BV(PB0); //single blink after
start/button press
for (i = 0; i < 2000; i++ );
}
if (timer >= 100)
{
//wdt_reset(); //faster period for blinking
WDTCR |= _BV(WDCE);
WDTCR = _BV(WDTIE) | _BV(WDP2);
PORTB &= ~_BV(PB0);
timecntr++;
if (timecntr == 1) PORTB |= _BV(PB0);
if (timecntr == 4) PORTB |= _BV(PB0);
if (timecntr > 30) timecntr = 0;
timer--; //against overflow
}
else
{
PORTB &= ~_BV(PB0);
//wdt_reset(); //slower period for counting
WDTCR |= _BV(WDCE);
WDTCR = _BV(WDTIE) | _BV(WDP2) | _BV(WDP1) |
_BV(WDP0);
}
set_sleep_mode(SLEEP_MODE_PWR_DOWN); //pwrdown
sleep_mode();
}
}
ISR (WDT_vect) //every 2 sec
{
timer++;
}
ISR (PCINT0_vect)
{
timer = 0;
}
ISR(__vector_default)
{
// error in interrupt handling
// allows return to code
}
vdaka za nakopnutie, p.rosko
Další informace o konferenci Hw-list