First AVR experiment

Z MAM wiki

Přejít na: navigace, hledání

We will use ATtiny2313:

Soubor:ATtiny2313.png

and connect LED in one of these ways (you can omit switch on the left):

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! (Septama Hery Dian did this with excellent details.)

Osobní nástroje