First AVR experiment

Z MAM wiki

(Rozdíly mezi verzemi)
Přejít na: navigace, hledání
(asm codelet)
(wait loop etc.)
Řádka 25: Řádka 25:
RJMP HOP
RJMP HOP
</pre>
</pre>
 +
 +
Then connect AVR Dragon:
 +
 +
[[soubor:DW-Dragon-ATtiny2313.png|672px]]
 +
 +
and try the same in reality. You may use wait loop similar to this:
 +
 +
<pre>
 +
WAIT:
 +
LDI R16, 4 ; LDI - Load Immediate
 +
WAIT1: INC R1
 +
BRNE WAIT1
 +
INC R2
 +
BRNE WAIT1
 +
DEC R16
 +
BRNE WAIT1
 +
RET
 +
</pre>
 +
 +
See [[První pokus v simulátoru AVR|this page]] for more complex code example.
 +
 +
 +
Post the resulting code on your personal wiki page here!

Verze z 23. 2. 2012, 14:44

We will use ATtiny2313:

Soubor:ATtiny2313.png

and connect LED in one of these ways:

and let it blink. Frst try it in simulator 2 in AVR Studio, using code similar to this:

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

	.EQU LED_X = 0		; LED_X is on PB0, pin 12 of ATtiny2313

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

	SBI	DDRB, LED_X	; SBI - Set Bit in I/O Register
HOP:
	SBI	PORTB, LED_X
	CBI	PORTB, LED_X
	RJMP HOP

Then connect AVR Dragon:

and try the same in reality. You may use wait loop similar to this:

WAIT:
	LDI	R16, 4			; LDI - Load Immediate
WAIT1:	INC	R1
	BRNE	WAIT1
	INC	R2
	BRNE	WAIT1
	DEC	R16
	BRNE	WAIT1
	RET

See this page for more complex code example.


Post the resulting code on your personal wiki page here!

Osobní nástroje