Uživatel:Krctomas

Z MAM wiki

(Rozdíly mezi verzemi)
Přejít na: navigace, hledání
(Založena nová stránka: Po zmacknuti sviti jen cervena ; ; example LED-show program for ATtiny 2313 ; ; 2-color LED with 300 Ohm resistor in series is supposed to be ; connected between pins 12…)
Řádka 1: Řádka 1:
Po zmacknuti sviti jen cervena
Po zmacknuti sviti jen cervena
 +
<pre>
;  
;  
Řádka 15: Řádka 16:
.EQU DDRB = $17 ; DDRB address
.EQU DDRB = $17 ; DDRB address
.EQU PORTB = $18 ; PORTB address
.EQU PORTB = $18 ; PORTB address
-
    .EQU PINB = $16
+
        .EQU PINB = $16
.EQU LED_X = 0 ; LED_X is on PB0, pin 12 of ATtiny2313
.EQU LED_X = 0 ; LED_X is on PB0, pin 12 of ATtiny2313
Řádka 26: Řádka 27:
; Pins connected to LED are outputs, DDRx=1 (set):
; Pins connected to LED are outputs, DDRx=1 (set):
-
SBI DDRB, LED_X ; SBI - Set Bit in I/O Register
+
SBI DDRB, LED_X ; SBI - Set Bit in I/O Register
-
SBI DDRB, LED_Y
+
SBI DDRB, LED_Y
SBI DDRD, 4
SBI DDRD, 4
SBI PORTB, 2
SBI PORTB, 2
GO:
GO:
-
RCALL   COLOR1
+
RCALL COLOR1
-
RCALL WAIT
+
RCALL WAIT
-
SBIS PINB, 2
+
SBIS PINB, 2
-
RJMP   GOP
+
RJMP GOP
-
RCALL WAIT
+
RCALL WAIT
-
RJMP GO
+
RJMP GO
GOP:
GOP:
-
RCALL COLOR2
+
RCALL COLOR2
-
SBIC PINB, 2
+
SBIC PINB, 2
-
RJMP   GO
+
RJMP GO
-
RJMP   GOP
+
RJMP GOP
;;;
;;;
Řádka 52: Řádka 53:
SMALLWAIT:
SMALLWAIT:
-
    LDI R16, 100
+
        LDI R16, 100
SMALLWAIT1:
SMALLWAIT1:
-
INC R1 ; INC - Increment
+
INC R1 ; INC - Increment
-
BRNE SMALLWAIT1 ; BRNE - Branch if Not Equal (Z flag) ; RET - Return from Subroutine
+
BRNE SMALLWAIT1 ; BRNE - Branch if Not Equal (Z flag)
-
DEC R16
+
DEC R16
-
BRNE WAIT1
+
BRNE WAIT1
-
RET
+
RET             ; RET - Return from Subroutine
WAIT:
WAIT:
-
LDI R16, 4 ; LDI - Load Immediate
+
LDI R16, 4 ; LDI - Load Immediate
-
WAIT1: INC R1          ; Bezi az do R1=255, dalsi krok - preteceni, R1=0
+
WAIT1: INC R1          ; Bezi az do R1=255, dalsi krok - preteceni, R1=0
-
BRNE WAIT1 ; Pokud v R1 neni 0, skoc na WAIT1
+
BRNE WAIT1 ; Pokud v R1 neni 0, skoc na WAIT1
-
INC R2
+
INC R2
-
; BRNE WAIT1
+
; BRNE WAIT1
-
; DEC R16
+
; DEC R16
-
BRNE WAIT1
+
BRNE WAIT1
RET
RET
COLOR1:
COLOR1:
-
    SBI PORTB, LED_X
+
        SBI PORTB, LED_X
-
CBI PORTB, LED_Y ; CBI - Clear Bit in I/O Register
+
CBI PORTB, LED_Y ; CBI - Clear Bit in I/O Register
-
RET
+
RET  
-
 
+
COLOR2:
COLOR2:
-
    SBI PORTB, LED_Y
+
        SBI PORTB, LED_Y
-
CBI PORTB, LED_X
+
CBI PORTB, LED_X
RET
RET
COL3W:
COL3W:
-
LDI R16, 2
+
LDI R16, 2
-
COL3X: RCALL COLOR1
+
COL3X: RCALL COLOR1
-
RCALL SMALLWAIT
+
RCALL SMALLWAIT
-
RCALL COLOR2
+
RCALL COLOR2
-
RCALL SMALLWAIT
+
RCALL SMALLWAIT
-
;INC R2
+
;INC R2
-
;BRNE COL3X
+
;BRNE COL3X
-
DEC R16
+
DEC R16
-
BRNE COL3X
+
BRNE COL3X
RET
RET
DARK:
DARK:
-
    CBI PORTB, LED_X
+
        CBI PORTB, LED_X
-
CBI PORTB, LED_Y
+
CBI PORTB, LED_Y
RET
RET
 +
 +
</pre>

Verze z 13. 3. 2013, 15:50

Po zmacknuti sviti jen cervena


; 
; example LED-show program for ATtiny 2313
;
; 2-color LED with 300 Ohm resistor in series is supposed to be
; connected between pins 12 (PB0, LED_X) and 13 (PB1, LED_Y).
;
; Color1 shines when LED_X is high and LED_Y is low
; Color2 shines when LED_Y is high and LED_X is low
; LED is off when LED_Y and LED_X are both low or both high


	.EQU DDRB = $17		; DDRB address
	.EQU PORTB = $18	; PORTB address
        .EQU PINB = $16

	.EQU LED_X = 0		; LED_X is on PB0, pin 12 of ATtiny2313
	.EQU LED_Y = 1		; LED_Y is on PB1, pin 13 of ATtiny2313

	.EQU DDRD = $11
	.EQU PORTD = $12
	.EQU PIND = $10

; Pins connected to LED are outputs, DDRx=1 (set):

	SBI DDRB, LED_X	; SBI - Set Bit in I/O Register
	SBI DDRB, LED_Y

	SBI DDRD, 4
	SBI PORTB, 2
GO:
	RCALL COLOR1
	RCALL WAIT
	SBIS PINB, 2
	RJMP GOP
	RCALL WAIT
	RJMP GO

GOP:
	RCALL COLOR2
	SBIC PINB, 2
	RJMP GO
	RJMP GOP

;;;
;;;
;;; P R O C E D U R E S
;;;
;;;
	
SMALLWAIT:
        LDI R16, 100
SMALLWAIT1:
	INC R1		; INC - Increment
	BRNE SMALLWAIT1	; BRNE - Branch if Not Equal (Z flag) 				
	DEC R16
	BRNE WAIT1
	RET             ; RET - Return from Subroutine

WAIT:
	LDI R16, 4	; LDI - Load Immediate
WAIT1:	INC R1          ; Bezi az do R1=255, dalsi krok - preteceni, R1=0
	BRNE WAIT1	; Pokud v R1 neni 0, skoc na WAIT1
	INC R2
;	BRNE WAIT1
;	DEC R16
	BRNE WAIT1
	RET
	
COLOR1:
        SBI PORTB, LED_X
	CBI PORTB, LED_Y	; CBI - Clear Bit in I/O Register
	RET 
COLOR2:
        SBI PORTB, LED_Y
	CBI PORTB, LED_X
	RET

COL3W:
	LDI R16, 2
COL3X: 	RCALL COLOR1
	RCALL SMALLWAIT
	RCALL COLOR2
	RCALL SMALLWAIT
	;INC R2
	;BRNE COL3X
	DEC R16
	BRNE COL3X
	RET

DARK:
        CBI PORTB, LED_X
	CBI PORTB, LED_Y
	RET

Osobní nástroje