Program :
/*==================================================================================
Pemrogram : Kelompok EK-2B/4
1.16-Mohammad Darun Nafis NIM 3.32.20.1.16
2.17-Muhammad Abimanyu Nugroho NIM:3.32.20.1.17
3.21-Rizkia Fernanda Berliana NIM 3.32.20.1.21
4.25-Wiroso NIM:3.32.20.1.26
Tgl Pratikum : Rabu, 15 Juli 2022
====================================================================================
Proyek : Trafic Light
File : Trafic-Light.asm
Deskripsi : Program untuk menyalakan LED sesuai kelompok
------------------------------------------------------------------------------------
Materi :
- Timer
------------------------------------------------------------------------------------
Komponen:
- Modul AVR
- LED
==================================================================================*/
///* Daftar Pustaka *
.include "m8535def.inc" ;pustaka ATmega 8535
//* Pengesetan awal *
.org 0x0000 ;alamat awal
rjmp awal
awal:
ldi R24,low(RAMEND) ;alamat tumpukan (SP)
out SPL, R24
ldi R24,high(RAMEND)
out SPH, R24
ldi R24,0xFF ;pintu PA sbg luaran
out DDRA, R24
ldi R24,0xFF ;pintu PC sbg luaran
out DDRC, R24
//* Program Utama *
ulang:
ldi R24, 0b00000001 ;Lampu Hijau A ON
out PORTA, R24
ldi R24, 0b10000100 ;Lampu Merah C dan B ON
out PORTC, R24
rcall tunda2
ldi R24, 0b00000010 ;Lampu Kuning A ON
out PORTA, R24
ldi R24, 0b10000100 ;Lampu Merah C dan B ON
out PORTC, R24
rcall tunda1
ldi R24, 0b00000100 ;Lampu Merah A ON
out PORTA, R24
ldi R24, 0b10000001 ;Lampu Merah C dan B ON
out PORTC, R24
rcall tunda2
ldi R24, 0b00000100 ;Lampu Merah A ON
out PORTA, R24
ldi R24, 0b10000010 ;Lampu Merah C dan Lampu Kuning B ON
out PORTC, R24
rcall tunda1
ldi R24, 0b00000100 ;Lampu Merah A ON
out PORTA, R24
ldi R24, 0b00100100 ;Lampu Hijau C dan Lampu Merah B ON
out PORTC, R24
rcall tunda2
ldi R24, 0b00000100 ;Lampu Merah A ON
out PORTA, R24
ldi R24, 0b01000100 ;Lampu Kuning C dan Lampu Merah B ON
out PORTC, R24
rcall tunda1
rjmp ulang
//* Sub Program *
tunda1: ; Meyala 2 deik
t0:ldi R20,15
t1:ldi R21,100
t2:ldi R22,150
t3:nop
nop
dec R22
brne t3
dec R21
brne t2
dec R20
brne t1
ret
tunda2: ; Meyala 6 deik
t4:ldi R20,15
t5:ldi R21,250
t6:ldi R22,250
t7:nop
nop
dec R22
brne t7
dec R21
brne t6
dec R20
brne t5
ret
Komentar
Posting Komentar