Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * BobbycarUnterbodenbeleuchtung.asm
- *
- * Created: 17.09.2014 21:42:51
- * Author: Benjamin
- */
- .include "2313def.inc"
- .def temp = r16
- .def leds = r17 // Ausgaberegister
- .def scene = r18 // Welche Scene wird gespielt
- .def counter = r19 // Was ist der Nächste Schritt der Scene
- .def reset = r20 // Zu Entprellen
- .org 0x0000
- rjmp main ; Reset Handler
- .org OVF0addr
- rjmp timer0_overflow ; Timer Overflow Handler
- main:
- ; Stackpointer initialisieren
- ;ldi temp, HIGH(RAMEND)
- ;out SPH, temp
- ldi temp, LOW(RAMEND)
- out SPL, temp
- ldi temp, 0xFF ; Port D auf Ausgang
- out DDRD, temp
- ldi temp, 0x00 ; Port B auf Eingang
- out DDRB, temp
- ldi temp, 0xFF ; An allen Pins vom Port B die Pullup-Widerstände
- out PORTB, temp
- ldi leds, 0xFF
- ldi temp, (1<<CS00)|(1<<CS02); CS00 setzen: Teiler 1024
- out TCCR0, temp
- ldi temp, (1<<TOIE0) ; TOIE0: Interrupt bei Timer Overflow
- out TIMSK, temp
- ldi temp, (1<<ACD) ; Analog Comperator abschalten
- out ACSR, temp
- sei
- input:
- sbic PINB, 0 // warten bis gedrückt
- rjmp input
- // wurde gedrückt
- sbrs reset,0 // reset ist 0
- rjmp resethin
- rjmp input
- resetweg:
- ldi reset, 0x00
- ret
- resethin:
- ldi reset,0xFF // reset auf 1
- inc scene // nächste LED scene
- ldi counter, 0x00 // Scene neu starten.
- rjmp input
- timer0_overflow:
- sbic PINB, 0
- ldi reset, 0x00 // Wurde der Taster losgelassen dann reset auf 0
- ldi temp, 0x00
- sub temp, scene // Welche Scene wird abgespielt
- breq action0
- ldi temp, 0x01
- sub temp, scene
- breq action1
- ldi temp, 0x02
- sub temp, scene
- breq action2
- ldi temp, 0x03
- sub temp, scene
- breq action3
- ldi scene, 0x00
- reti
- action0: // Dauer leuchten 1 Schritt
- ldi temp, 0x00
- sub temp, counter // Welche LEDs gehen als nächstes an
- breq action00
- action00:
- ldi leds, 0xFF
- out DDRD, leds // !
- ldi counter, 0x00
- reti
- action1: //Alle blinken, 2 Schritte
- ldi temp, 0x00
- sub temp, counter
- breq action10
- ldi temp, 0x01
- sub temp, counter
- breq action11
- action10:
- ldi leds, 0xFF
- out DDRD, leds // !
- inc counter
- reti
- action11:
- ldi leds, 0x00
- out DDRD, leds // !
- ldi counter, 0x00
- reti
- action2: // Paare blinken, 2 Schritte
- ldi temp, 0x00
- sub temp, counter
- breq action20
- ldi temp, 0x01
- sub temp, counter
- breq action21
- action20:
- ldi leds, 0x05
- out DDRD, leds // !
- inc counter
- reti
- action21:
- ldi leds, 0x0A
- out DDRD, leds // !
- ldi counter, 0x00
- reti
- action3: // Jede Einzeln, 4 Schritte
- ldi temp, 0x00
- sub temp, counter
- breq action30
- ldi temp, 0x01
- sub temp, counter
- breq action31
- ldi temp, 0x02
- sub temp, counter
- breq action32
- ldi temp, 0x03
- sub temp, counter
- breq action33
- action30:
- ldi leds, 0x01
- out DDRD, leds // !
- inc counter
- reti
- action31:
- ldi leds, 0x02
- out DDRD, leds // !
- inc counter
- reti
- action32:
- ldi leds, 0x04
- out DDRD, leds // !
- inc counter
- reti
- action33:
- ldi leds, 0x08
- out DDRD, leds // !
- ldi counter, 0x00
- reti
Advertisement
Add Comment
Please, Sign In to add comment