BASIC1 : Move Port


Contoh program di bawah ini adalah memindahkan kondisi dari portC dengan push botton kemudian di keluarkan ke portA dengan LED..

.include”m8535def.inc”
.org 0x00
.def buffer = r16
rjmp lompek
lompek:
;inis Stack
ldi buffer,low(RAMEND)
out SPL,buffer
ldi buffer,high(RAMEND)
out SPH,buffer

;inisialisasi
ldi buffer,0x00
out ddrc,buffer ; portC as input

ldi buffer,0xff
out porta,buffer ; matikan semua led di portA
out ddra,buffer ; portA as output
out portc,buffer

;program utama
paniang:
in buffer,PINC ;baca kondisi penekanan tombol di portC
out PORTA,buffer ;pindahkan ke portA
rjmp paniang

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: