;+----------------------------------------------------------------------
;| Titel		: myAVR Beispiel "IN/OUT" für den ATmega168
;+----------------------------------------------------------------------
;| Funktion 	: Solange Taster 1 gedrückt ist, wird eine LED
;|		: eingeschaltet.
;| Schaltung	: PORTD2=Taster1, PORTB0=LED-Rot
;+----------------------------------------------------------------------
;| Prozessor	: ATmega168
;| Takt		: 3,6864 MHz
;| Sprache		: Assembler
;| Datum		: 05.06.2004
;| Version		: 1.5
;| Autor		: Dipl. Ing. Päd. Alexander Huwaldt
;+----------------------------------------------------------------------
.include	"AVR.H"
;------------------------------------------------------------------------
begin:	nop
	rjmp	main	; Reset Handler
	nop
	reti		; EXT_INT0 IRQ0 Handler
	nop
	reti		; EXT_INT1 IRQ1 Handler
	nop
	reti		; PCINT0 PCINT0 Handler
	nop
	reti		; PCINT1 PCINT1 Handler
	nop
	reti		; PCINT2 PCINT2 Handler
	nop
	reti		; WDT Watchdog Timer Handler
	nop
	reti		; TIM2_COMPA Timer2 Compare A Handler
	nop
	reti		; TIM2_COMPB Timer2 Compare B Handler
	nop
	reti		; TIM2_OVF Timer2 Overflow Handler
	nop
	reti		; TIM1_CAPT Timer1 Capture Handler
	nop
	reti		; TIM1_COMPA Timer1 Compare A Handler
	nop
	reti		; TIM1_COMPB Timer1 Compare B Handler
	nop
	reti		; TIM1_OVF Timer1 Overflow Handler
	nop
	reti		; TIM0_COMPA Timer0 Compare A Handler
	nop
	reti		; TIM0_COMPB Timer0 Compare B Handler
	nop
	reti		; TIM0_OVF Timer0 Overflow Handler
	nop
	reti		; SPI_STC SPI Transfer Complete Handler
	nop
	reti		; USART_RXC USART, RX Complete Handler
	nop
	reti		; USART_UDRE USART, UDR Empty Handler
	nop
	reti		; USART_TXC USART, TX Complete Handler
	nop
	reti		; ADC ADC Conversion Complete Handler
	nop
	reti		; EE_RDY EEPROM Ready Handler
	nop
	reti		; ANA_COMP Analog Comparator Handler
	nop
	reti		; TWI 2-wire Serial Interface Handler
	nop
	reti		; 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
	sbi	DDRD,2	;PORTD2 auf Eingang
	sbi	PORTD,2	;PORTD2 Pullup
	sbi	DDRB,0	;PORTB0 auf Ausgang
;------------------------------------------------------------------------
mainloop:	wdr
	cbi	PORTB,0	;Wert bei Taste nicht gedrückt
	sbis	PIND,2	;Taste auswerten
	sbi	PORTB,0	;Wert bei Taste gedrückt
	rjmp	mainloop
;------------------------------------------------------------------------

