;+----------------------------------------------------------------------
;| Titel		: myAVR Beispiel Blinklicht für den ATmega48/88
;+----------------------------------------------------------------------
;| Funktion		: Ein Register wird inkrementiert und verzögert an
;|				: PORTD ausgegeben.
;| Schaltung	: PORTD2=Summer, PORTD3=LED1, PORTD4=LED2, PORTD5=LED3
;+----------------------------------------------------------------------
;| Prozessor	: ATmega48
;| Takt			: 3,6864 MHz
;| Sprache		: Assembler
;| Datum		: 09.10.2005
;| Version		: 0.9
;| Autor		: Dipl. Ing. Päd. Alexander Huwaldt
;+----------------------------------------------------------------------
.include	"AVR.H"
;------------------------------------------------------------------------
;Reset and Interrupt vector             ;VNr.  Beschreibung
begin:	rjmp	main	; Reset Handler
	reti		; EXT_INT0 IRQ0 Handler
	reti		; EXT_INT1 IRQ1 Handler
	reti		; PCINT0 PCINT0 Handler
	reti		; PCINT1 PCINT1 Handler
	reti		; PCINT2 PCINT2 Handler
	reti		; WDT Watchdog Timer Handler
	reti		; TIM2_COMPA Timer2 Compare A Handler
	reti		; TIM2_COMPB Timer2 Compare B Handler
	reti		; TIM2_OVF Timer2 Overflow Handler
	reti		; TIM1_CAPT Timer1 Capture Handler
	reti		; TIM1_COMPA Timer1 Compare A Handler
	reti		; TIM1_COMPB Timer1 Compare B Handler
	reti		; TIM1_OVF Timer1 Overflow Handler
	reti		; TIM0_COMPA Timer0 Compare A Handler
	reti		; TIM0_COMPB Timer0 Compare B Handler
	reti		; TIM0_OVF Timer0 Overflow Handler
	reti		; SPI_STC SPI Transfer Complete Handler
	reti		; USART_RXC USART, RX Complete Handler
	reti		; USART_UDRE USART, UDR Empty Handler
	reti		; USART_TXC USART, TX Complete Handler
	reti		; ADC ADC Conversion Complete Handler
	reti		; EE_RDY EEPROM Ready Handler
	reti		; ANA_COMP Analog Comparator Handler
	reti		; TWI 2-wire Serial Interface Handler
	reti		; SPM_RDY Store Program Memory Ready Handler
;------------------------------------------------------------------------
;Start, Power ON, Reset
main:	ldi	r16,lo8(RAMEND)
	out	SPL,r16
	ldi	r16,hi8(RAMEND)
	out	SPH,r16	;Init Stackpointer
	ldi	r16,0b11111111	;PORTD auf Ausgang
	out	DDRD,r16
	ldi	r16,0b00000000	;alle Bits auf Low
	out	PORTD,r16
	ldi	r17,0b00000000
	ldi	r18,0b00000001	;1 Lauflicht-Bit
;------------------------------------------------------------------------
mainloop:	wdr
	inc	r16	;wait
	brne	skip
	inc	r17	;wait
	brne	skip
	inc	r18	;Bits "blinken" lassen
	out	PORTD,r18	;Ausgabe
skip:	rjmp	mainloop
;------------------------------------------------------------------------

