First AVR experiment

Z MAM wiki

(Rozdíly mezi verzemi)
Přejít na: navigace, hledání
(LED connection)
(asm codelet)
Řádka 8: Řádka 8:
[[Soubor:AVR-1LED.png|300px]]  
[[Soubor:AVR-1LED.png|300px]]  
[[Soubor:AVR-2LED.png|340px]]
[[Soubor:AVR-2LED.png|340px]]
 +
 +
and let it blink. Frst try it in simulator 2 in AVR Studio, using code similar to this:
 +
 +
<pre>
 +
.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
 +
</pre>

Verze z 23. 2. 2012, 14:38

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
Osobní nástroje