AVR: ATtiny13 / ATtiny25 / ATtiny45 / ATtiny85 Sammelsurium

Zuletzt aktualisiert am: 06.09.2017

Übersicht

Microcontroller with xKB of programable memory:
Attiny13 = Microcontroller with 1KB
Attiny25 = Micocontroller with 2KB
Attiny45 = Microcontroller with 4KB
Attiny85 = Microcontroller with 8KB

CPU-Geschwindigkeit:
Attiny13/13A: default: 1,2Mhz (Fuse bit set: CKDIV8)
Attiny25/45/85: default: 1Mhz (Fuse bit set: CKDIV8)
max: 20MHz

Anzahl der Pins: 8Pin(s)
Anzahl der Ein-/Ausgänge: 6I/O(s)
Embedded-Schnittstelle: I2C, SPI

Attiny13/25/45/85:
Versorgungsspannung, min.: 2.7V
Versorgungsspannung, max.: 5.5V

Attiny13A:
Versorgungsspannung, min.: 1.8V
Versorgungsspannung, max.: 5.5V

DC Current per I/O Pin: 40.0 mA
DC Current VCC and GND Pins: 200.0 mA

Pinout

ATtiny Pinout

ISP Programming

2x3-pin ISP headers
2×3-pin ISP headers

ISP Pins

Sleep Modes

Sleep-Modes


/*
 * The 5 different modes are:
 *     SLEEP_MODE_IDLE         -the least power savings
 *     SLEEP_MODE_ADC
 *     SLEEP_MODE_PWR_SAVE
 *     SLEEP_MODE_STANDBY
 *     SLEEP_MODE_PWR_DOWN     -the most power savings
 */ 
set_sleep_mode(SLEEP_MODE_IDLE);

sleep_enable(); // enables the sleep bit in the mcucr register

sleep_cpu();      // here the device is actually put to sleep
	
// -------------------------------------------------
// THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
// -------------------------------------------------
	
sleep_disable();	// disable sleep...

Power consumption

power consumption

Der Stromverbrauch wurde gemessen mit:

  • set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  • ADC deaktiviert

Siehe folgender Artikel: technoblogy.com: ATtiny Low Power

Disable Analog to Digital Converter ADC:


ADCSRA &= ~(1 << ADEN);

Disable ADC Makro:


#define adc_disable() (ADCSRA &= ~(1 << ADEN)) // disable ADC

Arduino Methode:


power_adc_disable();

Interrupt


ISR(PCINT0_vect) {     // pin change interrupt
}
ISR(INT0_vect) {       // external interrupt
}
  • ISR needed for sleep to not reset program after interrupt
  • Every PCINTx will rise PCINT0_vect
  • Typically global variables are used to pass data between an ISR and the main program. To make sure variables shared between an ISR and the main program are updated correctly, declare them as volatile.

GIMSK |= (1 << INT0);          // Enable external Interrupt

MCUCR &= (0 << ISC01);	       // The low level of INT0
MCUCR &= (0 << ISC00);         // generates an interrupt request

Interrupt 0 sense control


sei();          // enable interrupts
cli();          // disable interrupts

Arduino Methode:


interrupts ();// enable interrupts
noInterrupts(); // disable interrupts

Libraries
315Mhz and 433Mhz Manchester encoding RF library which works on Arduino and ATTiny

Nützliche Links
Atmel: ATtiny Datasheet pdf
The pinouts of the most popular AVR processors
mikrocontroller.net: AVR-Tutorial: Interrupts
gammon.com.au: Interrupts
ATtiny: Fuse Restore using HVSP
mikrocontroller.net: Sleep-Mode

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.