;----------------------------------------------------------------------
; Titel		: myAVR Beispiel "IN/OUT" für den ATmega88
;----------------------------------------------------------------------
; Funktion 		: Solange Taster 1 gedrückt ist, wird eine LED
;		: eingeschaltet
; Schaltung		: PORTD.2=Taster1, PORTB.0=LED-Rot
;----------------------------------------------------------------------
; Prozessor		: ATmega88
; Takt		: 3,6864 MHz
; Sprache		: Assembler
; Datum		: 09.11.2007
; Version		: 1.0
; Autor		: Renaldo Badke
;----------------------------------------------------------------------
.equ	F_CPU,	3686400
.include	"AVR.H"
;------------------------------------------------------------------------
;Reset and Interruptvectoren	;VNr.	Beschreibung
begin:
	rjmp	main	;  1 Reset Handler
	reti		;  2 EXT_INT0 IRQ0 Handler
	reti		;  3 EXT_INT1 IRQ1 Handler
	reti		;  4 PCINT0 PCINT0 Handler
	reti		;  5 PCINT1 PCINT1 Handler
	reti		;  6 PCINT2 PCINT2 Handler
	reti		;  7 WDT Watchdog Timer Handler
	reti		;  8 TIM2_COMPA Timer2 Compare A Handler
	reti		;  9 TIM2_COMPB Timer2 Compare B Handler
	reti		; 10 TIM2_OVF Timer2 Overflow Handler
	reti		; 11 TIM1_CAPT Timer1 Capture Handler
	reti		; 12 TIM1_COMPA Timer1 Compare A Handler
	reti		; 13 TIM1_COMPB Timer1 Compare B Handler
	reti		; 14 TIM1_OVF Timer1 Overflow Handler
	reti		; 15 TIM0_COMPA Timer0 Compare A Handler
	reti		; 16 TIM0_COMPB Timer0 Compare B Handler
	reti		; 17 TIM0_OVF Timer0 Overflow Handler
	reti		; 18 SPI_STC SPI Transfer Complete Handler
	reti		; 19 USART_RXC USART, RX Complete Handler
	reti		; 20 USART_UDRE USART, UDR Empty Handler
	reti		; 21 USART_TXC USART, TX Complete Handler
	reti		; 22 ADC ADC Conversion Complete Handler
	reti		; 23 EE_RDY EEPROM Ready Handler
	reti		; 24 ANA_COMP Analog Comparator Handler
	reti		; 25 TWI 2-wire Serial Interface Handler
	reti		; 26 SPM_RDY Store Program Memory Ready Handler
;------------------------------------------------------------------------
;Start, Power ON, Reset
main:
	ldi	r16,hi8(RAMEND)
	out	SPH,r16
	ldi	r16,lo8(RAMEND)	;Stack Initialisierung
	out	SPL,r16	;Init Stackpointer

	cbi	DDRD,2	;PORTD2 auf Eingang
	sbi	PORTD,2	;PORTD2 Pullup
	sbi	DDRB,0	;PORTB0 auf Ausgang
;------------------------------------------------------------------------
mainloop:
	cbi	PORTB,0	;Wert bei Taste nicht gedrückt
	sbis	PIND,2	;Taste auswerten
	sbi	PORTB,0	;Wert bei Taste gedrückt
	rjmp	mainloop
;------------------------------------------------------------------------

