From: hackbard Date: Mon, 8 Dec 2003 01:20:56 +0000 (+0000) Subject: ports (d) 3-7 blinken lights test *g* X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=0db4149eab38040a94266a3ad7121c7dd865a3d6;p=my-code%2Fatmel.git ports (d) 3-7 blinken lights test *g* --- diff --git a/beginners/test_port_d.asm b/beginners/test_port_d.asm index 8dc6e44..36b7419 100644 --- a/beginners/test_port_d.asm +++ b/beginners/test_port_d.asm @@ -1,55 +1,48 @@ +; +; portd 3-7 blinken lights ;) +; +; author: hackbard@hackdaworld.dyndns.org +; + .include "../include/2313def.inc" INIT: -ldi r31,0 ; wait counter -ldi r30,0 ; decide counter -ldi r29,0 ; another wait counter -ldi r28,1 ; constant -out DDRD,r30 ; select all pins as input -rjmp DECIDE ; goto decide - -DECIDE: -add r30,r28 ; add 1 to decission counter .. so we start with SET_1 -cpi r30,0 -breq SET_0 -cpi r30,1 -breq SET_1 -cpi r30,2 -breq SET_2 -ldi r30,0 ; now begin with SET_0 -rjmp DECIDE +ldi r30,2 ; light counter +ldi r28,1 ; constants +ldi r27,0x7f ; +out DDRD,r27 ; select all pins as output +rjmp LIGHT -SET_0: -ldi r16,0 -sbr r16,14 ; ports 3,4,5 -out PORTD,r16 -rjmp WAIT - -SET_1: -ldi r16,0 -sbr r16,48 ; ports 6,7 +LIGHT: +ldi r31,0 ; reset wait counter +lsl r30 +cpi r30,128 +breq RESET_L +ldi r16,0xff +sub r16,r30 out PORTD,r16 rjmp WAIT -SET_2: -ldi r16,0 -sbr r16,42 ; ports 3,5,7 -out PORTD,r16 -rjmp WAIT +RESET_L: +ldi r30,2 ; again start with 1 +rjmp LIGHT WAIT: ldi r29,0 ; reset inner wait counter add r31,r28 ; increment wait counter cpi r31,0xff ; after 255 steps -breq RESET ; reset wait counter +breq LIGHT rjmp WAIT_MORE WAIT_MORE: +ldi r25,0 ; reset inner inner wait counter add r29,r28 ; increment inner wait loop counter cpi r29,0xff ; goto first wait loop after 255 cycles breq WAIT -rjmp WAIT_MORE +rjmp WAIT_MORE_MORE -RESET: -ldi r31,0 -rjmp DECIDE +WAIT_MORE_MORE: +add r25,r28 ; inc inner inner wait counter +cpi r25,0x05 ; goto wait_more loop +breq WAIT_MORE +rjmp WAIT_MORE_MORE