Professional Documents
Culture Documents
CS423
Dick Steflik
AVR ATtiny2313
2313 Features
Gnd ground
Master-slave methodology
SCLK SCLK
MOSI MOSI
MISO MISO
SS1 SS
SS2
SPI Slave 2
SCLK
MOSI
MISO
SS
AVR Programming
GND
API Applications
Sensors
Temperature
Pressure (touch screens)
LCD Panels
int main(){
while(1){
PORTD = _BV(PD4);
_delay_ms(1000);
return(0);
}
Interrupts
1 0x0000 Reset External Pin, POR,
BOR,Watchdog Reset
2 0x0001 INT0 External Interrupt Request
0
3 0x0002 INT1 External Interrupt Request
1
4 0x0003 TIMER1 CAPT Timer/Counter1 Capture
Event
5 0x0004 TIMER1 COMPA Timer/Counter1 Compare
Match A
6 0x0005 TIMER1 OVF Timer/Counter1 Overflow
7 0x0006 TIMER0 OVF Timer/Counter0 Overflow
8 0x0007 USART0,RX USART0 Receive
complete
9 0x0008 USART0 UDRE USART0 Data Register
Empty
10 0x0009 USART0 RX USART0 Transmit
Complete
11 0x000A ANALOG COMP Analog Comparitor
12 0x000B PCINT Pin Change Interrupt
13 0x000C TIMER1 COMPB Timer/Counter1 Compare
Match B
14 0x000D TIMER0 COMPA Timer/Counter0 Compare
Match A
ISR Macro
#include <avr/interrupt.h>
ISR(SIG_INT0)
{ cli(); //disable interrupts
.
.
.
sei(); // enable interrupts
}
INT0 - Pin 6
INT1 Pin 7
ex.
MCUCR = (1<<ISC01) | (1<<ISC00)
int main(void)
{
// set Pin 6 (PD02) as the interrupt pin
PCMSK |= (1<<PIND2);
// turn on interrupts
GIMSK |= (1<<INT0);