OBJECTIVE:
- Students understand the microcontroller interface circuit with 7 segments
- Students can understand assembly programs to display data to 7 segments.
- Students understand some basic assembly instructions, MOV, Setb, Clr, and delay time.
7 segment common anode
74LS138 Configuration
Table 3.1. Truth table of 74LS138
| INPUT SELECTOR | | | ENABLE | | | OUTPUT | | | | | | | |
|-----------------|---|---|--------|------|------|--------|----|----|----|----|----|----|----|
| C | B | A | G1 | /G2A | /G2B | Y1 | Y2 | Y2 | Y3 | Y4 | Y5 | Y6 | Y7 |
| 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
In the truth table, it appears that the seven segments that are on depend on the output of the 74LS138 decoder, which is outputting a low logic "0", so that out of the 8 displays, only one display will always be turned on. In order for the displays to appear on simultaneously, the three displays must be turned on alternately with a certain delay time.
In the image, the seven segment common anode is controlled using a PNP transistor through a 74LS138 decoder. If there is low logic on the base of the transistor, the 7 segment will light up and vice versa it will go out.
Figure 3.2 Single 7 Segment Module
Table 3.2. 7 Segment Display Data
| P0.6 | P0.5 | P0.4 | P0.3 | P0.2 | P0.1 | P0.0 | Display |
|------|------|------|------|------|------|------|---------|
| g | f | e | d | c | b | a | |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
| 0 | 1 | 1 | 0 | 0 | 0 | 0 | 3 |
| : | : | : | : | : | : | : | : |
| 0 | 0 | 0 | 1 | 0 | 0 | 0 | A |
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | b |
In the table it can be seen that to turn on a segment, low logic data "0" must be sent and conversely to turn off a segment, high logic data "1" must be sent.
Experiment 3.1. Write a Character on 7 Segment (Display 1)
In this experiment, the character 'A' will be displayed on 7 Segment Display 1. To perform this experiment, do the following steps:
- Connect jumper 7Segment_EN, to enable the 74LS138 Decoder.
- Connect the Microcontroller Trainer module to the +5V power supply.
- Connect the Microcontroller Trainer module to the programmer circuit
- Open the M-IDE Studio for MCS-51 program, as a program editor and compiler.
- Type the following program: ( download file prog31a.asm )
org 0h start: clr P3.5 ; P3.5 = '0' clr P3.6 ; P3.6 = '0' clr P3.7 ; P3.7 = '0' mov P0,#10001000b ; Cetak Karakter 'A' sjmp start ; Lompat ke start end
- Save the program you typed and name it: prog31a.asm
- In the MIDE program, select Build /F9 or to compile the program from *.asm to *.hex.
- Program the microcontroller using the ISP Software Program (See Instructions for Use)
- Make observations on the LED.
- Make modifications to the program to print other characters, according to the table:
| Nama Karakter | Posisi Display |
|---------------|----------------|
| C | Display 2 |
| E | Display 5 |
| 3 | Display 8 |
Experiment 3.2. Write Three Characters on 7 Segments
In this experiment, the character 'AbC' will be displayed on 7 Segment Display 1, Display 2 and Display 3 sequentially. To do this experiment, do the following steps:
- Connect jumper 7Segment_EN, to enable the 74LS138 Decoder.
- Connect the Microcontroller Trainer module to the +5V power supply.
- Connect the Microcontroller Trainer module to the programmer circuit
- Open the M-IDE Studio for MCS-51 program, as a program editor and compiler.
- Type the following program: ( download file prog32a.asm )
org 0h start: clr P3.5 ; P3.5 = '0' clr P3.6 ; P3.6 = '0' clr P3.7 ; P3.7 = '0' mov P0, #10001000b ; Cetak Karakter 'A' call delay ; Panggil Waktu Tunda ; setb P3.5 ; P3.5 = '1' clr P3.6 ; P3.6 = '0' clr P3.7 ; P3.7 = '0' mov P0,#10000011b ; Cetak Karakter 'b' call delay ; Panggil Waktu Tunda ; clr P3.5 ; P3.5 = '0' setb P3.6 ; P3.6 = '1' clr P3.7 ; P3.7 = '0' mov P0,#11000110b ; Cetak Karakter 'C' call delay ; Panggil Waktu Tunda ; sjmp start ; Lompat ke start ;============================================= ;subroutine delay created to rise delay time ;============================================= delay: mov R1,#25 del1: mov R2,#25 del2: djnz R2,del2 djnz R1,del1 ret end
- Save the program you typed and name it: prog32a.asm
- In the MIDE program, select Build /F9 or to compile the program from *.asm to *.hex.
- Program the microcontroller using the ISP Software Program (See Instructions for Use)
- Make observations on the LED.
- Make modifications to the program to print other characters, according to the table:
| Nama Karakter | Posisi Display |
|---------------|---------------------------------|
| EFG | Display 1, Display 2, Display 3 |
| HJL | Display 3, Display 4, Display 5 |
| 1A3 | Display 6, Display 7, Display 8 |
Experiment 3.3. Write 8 Characters in 7 Segments
In this experiment, the character '12345678' will be displayed on 7 Segment Display 1, Display 2 and Display 3 to Display 8 sequentially. To perform this experiment, do the following steps:
- Connect jumper 7Segment_EN, to enable the 74LS138 Decoder.
- Connect the Microcontroller Trainer module to the +5V power supply.
- Connect the Microcontroller Trainer module to the programmer circuit
- Open the M-IDE Studio for MCS-51 program, as a program editor and compiler.
- Type the following program: ( download the file prog33a.asm )
org 0h start: clr P3.5 clr P3.6 clr P3.7 mov P0,#11111001b ; Cetak Karakter '1' call delay ; setb P3.5 clr P3.6 clr P3.7 mov P0,#10100100b ; Cetak Karakter '2' call delay ; clr P3.5 ; setb P3.6 clr P3.7 mov P0,#10110000b ; Cetak Karakter '3' call delay ; setb P3.5 setb P3.6 clr P3.7 mov P0,#10011001b ; Cetak Karakter '4' call delay ; clr P3.5 clr P3.6 setb P3.7 mov P0,#10010010b ; Cetak Karakter '5' call delay ; setb P3.5 clr P3.6 setb P3.7 mov P0,#10000010b ; Cetak Karakter '6' call delay ; clr P3.5 setb P3.6 setb P3.7 mov P0,#11111000b ; Cetak Karakter '7' call delay ; setb P3.5 setb P3.6 setb P3.7 mov P0,#10000000b ; Cetak Karakter '8' call delay ; sjmp start ; Lompat ke Start ;============================= ;subroutine delay created to rise delay time ;============================= delay: mov R1,#25 del1: mov R2,#25 del2: djnz R2,del2 djnz R1,del1 ret end
- Save the program you typed and name it: prog33a.asm
- In the MIDE program, select Build /F9 or to compile the program from *.asm to *.hex.
- Program the microcontroller using the ISP Software Program (See Instructions for Use)
- Make observations on the 7 Segments.
- Make modifications to the program to print other characters, according to the table:
| Nama Karakter | Posisi Display | |---------------|----------------| | LAbMIkro | - | | HAlloguy | - | | YournAme | - |
Experiment 3.4. Setting Up/Dn and Enter with 7 Segment Display
In this experiment, a simulation of setting UP (P2.1)/ DN (P2.2) and pressing the Enter button (P2.0) will be made, and displayed on the 7 Segment display. The display data will increase from 00 to 99 or decrease from 99 to 00, according to the pressing of the UP/ DN button. If the Enter button is pressed, the UP/ DN button will no longer function. To do this experiment, do the following steps: - Connect jumper 7Segment_EN, to enable the 74LS138 Decoder.
- Connect the Microcontroller Trainer module to the +5V power supply.
- Connect the Microcontroller Trainer module to the programmer circuit
- Open the M-IDE Studio for MCS-51 program, as a program editor and compiler ( download the file prog34a.asm )
- Type the following program:
Org 0h ratusan equ 30h puluhan equ 31h satuan equ 32h ; start: mov R7,#1 ;inisialisasi data setting Setup: mov A,R7 ;simpan data R7 ke A call bin2dec call display2sevensegmen jnb p2.0,getout;bila sw1(P2.0) ditekan mk getout(selesai) jb P2.1,SetDn ;bila sw2(P2.1) ditekan mk INC R7 inc R7 ;R7:=R7+1 acall delay ;waktu tunda lama penekanan tombol cjne R7,#100d,setup;deteksi apakah setting=100d mov R7,#1 ;reset R7 -> 1 sjmp Setup ; SetDn: Mov A,R7 ;simpan data R7 ke A call bin2dec call display2sevensegmen jnb P2.0,getout;bila sw1(P2.0) ditekan mk getout(selesai) jb p2.2,Setup ;bila sw2(P2.1) ditekan mk INC R7 dec R7 ;R7:=R7-1 acall delay ;waktu tunda lama penekanan tombol cjne R7,#0d,setDn;deteksi apakah setting=0d mov R7,#99d ;reset R7 -> 99 sjmp Setdn getout: sjmp getout ; Display2SevenSegmen: mov A,puluhan mov DPTR,#Data7segmen movc A,@A+DPTR mov P0,A clr P3.5 ; Setb P3.6 Setb P3.7 call delay ; mov A,satuan mov DPTR,#Data7segmen movc A,@A+DPTR mov P0,A Setb P3.5 ; Setb P3.6 Setb P3.7 call delay ret ; Bin2Dec: mov b,#100d div ab mov ratusan,a mov a,b mov b,#10d div ab mov puluhan,a mov satuan,b ret ; delay: mov R0,#0 delay1:mov R2,#0fh djnz R2,$ djnz R0,delay1 ret ; Data7segmen: db 11000000b,11111001b,10100100b,10110000b,10011001b db 10010010b,10000010b,11111000b,10000000b,10010000b end
- Save the program you typed and name it: prog34a.asm
- In the MIDE program, select Build /F9 or to compile the program from *.asm to *.hex.
- Program the microcontroller using the ISP Software Program (See Instructions for Use)
- Make observations on the 7 Segments.
Reading Keypad, Input Data to RAM & Display to 7 Segment
Assembly Program to Read Keypad, Input Data to RAM and Display to 7 Segment
;- BAB3_16.ASM -------------------------------------------------------------------
;
; Program Untuk Membaca Keypad Dan Memasukkan Data Ke RAM dan
; Menampilkan Isi RAM Tersebut Ke Display 7 Segment
;
; --------------------------------------------------------------------------------
DATA_INP EQU 35H
KOLOM EQU 30H
DATA_5 EQU 31H
PER_BARIS EQU 32H
BAN_P3 EQU 33H
COMMON EQU 34H
KEYPRESS EQU 36H
BOUNC EQU 37H
;
ORG 0H
;
LCALL CLEAR_BUFFER ; lakukan pembersihan buffer terlebih dahulu
MULAI:
MOV A,KEYPRESS ; Lihat Apakah Ada Tombol Ditekan
CJNE A,#0,LOMPAT ; Bila Ada, Loncat Ke Label LOMPAT
LCALL SCAN_TOMBOL ; Lakukan pengecekan tombol (SCAN_TOMBOL)
LCALL DISPLAY ; Tampilkan ke 7-segment
SJMP MULAI
LOMPAT:
MOV BOUNC,#0Fh ; Cek Apakah Tombol Betul-Betul
LOMPAT1: ; Ditekan / Untuk Menghindari
LCALL DISPLAY ; Bouncing Diulang Sampai 5x
MOV P2,COMMON
MOV A,P3
CJNE A,#0FFH,LOMPAT
DJNZ BOUNC,LOMPAT1
MOV KEYPRESS,#0 ; Buat Keypress = 0 Bila Tombol dilepas
SJMP MULAI ; Ulangi lagi dari awal
; --------------------------------------------------------------------------------
;
; Subrutin SCAN_TOMBOL, untuk melakukan pengecekan tombol di P3
;
; --------------------------------------------------------------------------------
SCAN_TOMBOL:
MOV KOLOM,#4 ; Jumlah kolom Tombol Matrik (4 kolom)
MOV COMMON,#0FEH ; Data awal scan Untuk Port 2 (1111 1110)
MOV DPTR,#ANGKA ; DPTR menunjuk pada ANGKA
MOV DATA_5,#0 ; Untuk Hitungan Data baris awal
ULANG:
MOV BAN_P3,#7FH ; Data awal Pembanding masukan P3 (0111 1111)
MOV PER_BARIS,#0 ; Hitungan Data Baris per kolom
ULANG1:
MOV P2,COMMON ; data scan dikirimkan ke P2
MOV A,P3 ; baca status tombol-tombol di P3 ke akumulator
CJNE A,BAN_P3,GESER1 ; Apakah ada tombol yang ditekan?
MOV A,PER_BARIS ; ADA! Lakukan penjumlahan antara data baris
ADD A,DATA_5 ; per kolom yg dicek dengan data baris
MOVC A,@A+DPTR ; sehingga menunjuk pada data
MOV DATA_INP,A ; yang akan ditampilkan ke 7-segmen
MOV KEYPRESS,#1 ; Ubah status KEYPRESS (Ada Tombol Ditekan)
LCALL ISI_BUFFER ; Isi Data tampilan Ke Buffer
RET
GESER1:
INC PER_BARIS ; TIDAK ADA! Naikkan jumlah baris yang telah dicek
MOV A,BAN_P3 ; Data scan digeser ke kanan
RR A ; per bit
MOV BAN_P3,A ; melalui akumulator
MOV A,PER_BARIS ; Periksa melalui akumulator
CJNE A,#5,ULANG1 ; apakah sudah 5 baris dicek?
; BELUM! ulangi lagi (ULANG1)
NEXTSCAN:
MOV A,DATA_5 ; SUDAH! siapkan untuk kolom berikutnya
ADD A,#5 ; atur hitungan data baris
MOV DATA_5,A ; dengan hitungan sebelumnya + 5
MOV A,COMMON ; siapkan data scan untuk kolom
RL A ; berikutnya dengan merotasi kekiri
MOV COMMON,A ; per bit melalui akumulator
DJNZ KOLOM,ULANG ; apakah semua kolom sudah discan?
; BELUM! ulangi untuk kolom berikutnya
MOV P2,#0FFH ; SUDAH! matikan tampilan 7-segmen
RET
; --------------------------------------------------------------------------------
;
; subrutin ISI_BUFFER untuk mengisi data tombol ke buffer
;
; --------------------------------------------------------------------------------
ISI_BUFFER:
MOV A,DATA_INP
CJNE A,#60H,BUFFER1 ; Apakah ditekan tombol 'A'
MOV A,77H ; YA! Buat tampilan '.'
ANL A,#0DFH ; melalui memori lokasi 77h
MOV 77H,A ; dan akumulator
RET
BUFFER1:
CJNE A,#0c0H,BUFFER2 ; TIDAK! Apakah tombol C (=Clear)
LCALL CLEAR_BUFFER ; YA! Bersihkan buffer
RET
BUFFER2:
MOV A,KEYPRESS ; TIDAK! Apakah
CJNE A,#1,NOPRESS ; Tombol Ditekan?
MOV R2,#7 ; YA! Lakukan inisialisasi
MOV R1,#70H ; R0, R1 dan R2
MOV R0,#71H
ISI_LAGI:
MOV A,@R0 ; Salin isi memori 71h ke
MOV @R1,A ; ke 70h
INC R0 ; naikkan isi R0
INC R1 ; naikkan isi R1
DJNZ R2,ISI_LAGI ; Sudah 7 lokasi?
; BELUM! ulangi lagi (ISI_LAGI)
MOV A,DATA_INP ; SUDAH! simpan data masukan
MOV 77H,A ; ke lokasi 77h
NOPRESS: ; TIDAK! kembali dari subrutin
RET
; --------------------------------------------------------------------------------
;
; SUBRUTIN UNTUK MENAMPILKAN DATA DARI BUFFER
;
; --------------------------------------------------------------------------------
DISPLAY:
MOV 7BH,#08H ; R6 = 8 =Jumlah Digit 7 Segment
MOV R1,#70H ; R0 = Alamat Buffer Display
MOV 78H,#0FEH ; 78h = Comm
ULANG2:
MOV A,@R1 ;
MOV P0,A ; Keluarkan Data A Ke Mulai
INC R1
MOV A,78H ; Pindahkan Data Ram Alamat Mulai Ke A
MOV P2,A ; Keluarkan Data A Ke Port 2
RL A
MOV 78H,A
LCALL DELAY ; Mulai
MOV P0,#0FFH
MOV P2,#0FFH
DJNZ 7BH,ULANG2 ; Ulangi S/D 8 Kali (Jml Digit 7 Segmen)
RET
; --------------------------------------------------------------------------------
;
; subrutin DELAY untuk tundaan
;
; --------------------------------------------------------------------------------
DELAY: MOV 79H,#090H ;Isi Ram Alamat Mulai Dengan 0
DJNZ 79H,$
RET ;Kembali Ke Langkah Setelah Perintah
; ;Acall
; --------------------------------------------------------------------------------
;
; subrutin CLEAR_BUFFER untuk membersihkan buffer
;
; --------------------------------------------------------------------------------
CLEAR_BUFFER: ; Subrutin Untuk Menghapus
MOV 78H,#8 ; Buffer
MOV R0,#70H
CLEAR1:
MOV @R0,#0FFH
INC R0
DJNZ 78H,CLEAR1
RET
;
ANGKA: DB 0c0H,0f9H,0a4H,0b0H,99H,92H,82H,0f8H,80H,90H,0A8H
DB 28H,29H,71H,0BAH,0E8H,21H,20H,67H,0E0H
END
Hope this is useful & happy learning!
8x7 Segment Data Display Assembly Program
8x7 Segment Data Display Assembly Program
Part 1
;- BAB3_17.ASM -------------------------------------------------------------------
;
; Program untuk menghidupkan tampilan 8 x 7-Segmen
; untuk menampilkan tulisan -eLins--
;
; --------------------------------------------------------------------------------
ORG 0H
;
MULAI:
MOV DPTR,#ELINS ; Isi data pointer dg alamat data '-elins--'
MOV R6,#08H ; R6 = 8 = Jumlah digit 7 segment
MOV R1,#7FH ; R1 = untuk Common (awal 0111 1111)
ULANG: CLR A ; Isi Akumulator dengan 0
MOVC A,@A+DPTR ; Pindahkan data ke n ke A
INC DPTR ; DPTR menunjuk ke data berikutnya
MOV P0,A ; Keluarkan data A ke port 0
MOV A,R1 ; kirimkan data common ke
MOV P1,A ; port 1 melalui akumulator
RR A ; putar geser ke kanan per bit isi akumulator
MOV R1,A ; kembalikan isi R1
;
MOV R2,#0FFH ; lakukan penundaan
DELAY: DJNZ R2,DELAY ; sesaat (ulang 255x)
MOV P0,#0FFH ; Buat P0 berlogika 1 (semua LED padam)
DJNZ R6,ULANG ; Ulangi sampai 8 kali (8 digit)
JMP MULAI ; ulangi lagi dari awal
; --------------------------------------------------------------------------------
; DATA AREA
; --------------------------------------------------------------------------------
ELINS:
;
; '-' 'e' 'l' 'i' 'n' 's' '-' '-'
;
DB 0FDH,0A0H,0BAH,77H,62H,29H,0FDH,0FDH
END
Part 2
;- BAB3_17.ASM -------------------------------------------------------------------
;
; Program untuk menghidupkan Display 8 x 7-segmen
; untuk menampilkan tulisan -eLins-- berkedip=kedip
;
; --------------------------------------------------------------------------------
ORG 0H
;
ULANG: MOV R5,#144 ; Register 5 diisi 144 untuk keperluan
; jumlah pengulangan tampilan hidup
HIDUP: MOV DPTR,#ELINS ; Isi data pointer dengan alamat data '-elins--'
MOV R6,#08H ; R6 = 8 = Jumlah digit 7 segment
MOV R1,#7FH ; R1 = untuk Common (awal 0111 1111)
ULANG1:
CLR A ; Isi Akumulator dengan 0
MOVC A,@A+DPTR ; Pindahkan data ke n ke A
INC DPTR ; Data Pointer menunjuk ke data berikutnya
MOV P0,A ; Keluarkan data A ke port 0
MOV A,R1 ; kirimkan data common ke
MOV P1,A ; port 1 melalui akumulator
RR A ; putar geser ke kanan per bit isi akumulator
MOV R1,A ; kembalikan isi R1
ACALL DELAY ; lakukan penundaan sesaat
;
MOV P0,#0FFH ; Buat P0 berlogika 1 (semua LED padam)
DJNZ R6,ULANG1 ; Ulangi sampai 8 kali (8 digit)
DJNZ R5,HIDUP ; ulangi proses ini 144 (=90h) kali
MOV R5,#0 ; Isi register 5 dengan 0 (untuk 256x ulang)
MATI: ACALL DELAY
ACALL DELAY
ACALL DELAY
DJNZ R5,MATI ; ulangi hingga 256 kali
JMP ULANG ; Ulangi semua langkah diatas
; --------------------------------------------------------------------------------
;
; subrutin DELAY
;
; --------------------------------------------------------------------------------
DELAY: MOV R2,#0
LAGI: DJNZ R2,$
RET
; --------------------------------------------------------------------------------
; DATA AREA
; --------------------------------------------------------------------------------
ELINS:
;
; '-' 'e' 'l' 'i' 'n' 's' '-' '-'
;
DB 0FDH,0A0H,0BAH,77H,62H,29H,0FDH,0FDH
END
END
Hope this is useful & happy learning!
Assembly Program Displays Shifted Text
Assembly Program Displays Sliding Text
;- BAB3_17.ASM -------------------------------------------------------------------
;
; Program untuk menampilkan tulisan secara bergeser
; --------------------------------------------------------------------------------
; Pemakaian RAM :
; 70h-77h = data segment display / 70h = kiri
; 78h = data common display
; 79h = untuk delay display 1 common
; 7Ah = untuk delay display 8 common
; 7Bh = utk counter RAM to PORT display
; 7Ch = utk counter buffer RAM display
; 7Dh = jumlah text
; 7Eh = pointer untuk tentukan DPTR
; --------------------------------------------------------------------------------
ORG 0H
;
LJMP MULAI
; --------------------------------------------------------------------------------
;subrutin untuk mengisi buffer RAM Display
; --------------------------------------------------------------------------------
ISI_BUFFER:
MOV 7CH,#08H ; Jumlah digit 7 segment
MOV R0,#70H
ULANG:
MOV A,7EH ; Isi A dengan isi dari alamat 7Eh (data DPTR)
MOVC A,@A+DPTR ; Pindahkan data ke n ke A
MOV @R0,A ; Pindahkan isi A ke alamat yang ditunjuk R0
INC DPTR ; Siapkan data berikutnya
INC R0 ; tambahkan isi R0 dengan 1
DJNZ 7CH,ULANG ; Ulangi sampai 8 kali (jml digit 7 segment)
RET
; --------------------------------------------------------------------------------
;subrutin untuk menampilkan isi RAM buffer display ke 8 x 7 segment
; --------------------------------------------------------------------------------
DIS8SEG:
MOV 7BH,#08H ; Isi RAM 7Bh dg 8 = jumlah digit 7 segment
MOV R1,#70H ; R1 = Alamat buffer display
MOV 78H,#07FH ; Isi memory 78h dg FEh = data Common display
ULANG2:
MOV A,@R1 ; pindahkan isi RAM yang ditunjuk oleh R1 ke A
MOV P0,A ; Keluarkan data A ke port 0 (data segment)
INC R1
MOV A,78H ; Pindahkan isi RAM 78h ke A
MOV P1,A ; Keluarkan data A ke port 1 (data common)
RR A
MOV 78H,A
LCALL DELAY
MOV P0,#0FFH ; matikan display sesaat (u/ menghindari
; bayangan)
MOV P1,#0FFH
DJNZ 7BH,ULANG2 ; Ulangi sampai 8 kali (jml digit 7 segment)
RET
;
DELAY: MOV 79H,#0E0H ; Isi RAM 79h dengan 0E0 (hex)
DELAY1: DJNZ 79H,DELAY1 ;
RET ; Kembali ke langkah setelah perintah Acall
;
DISPLAY:
MOV 7AH,#050H ; Isi RAM 7Ah dengan 050 (hex)
DISPLAY1:
LCALL DIS8SEG
DJNZ 7AH,DISPLAY1
RET
MULAI:
; teks keluar dari kanan ke kiri
MOV 7EH,#1
MOV 7DH,#8 ; RAM 7Dh diisi jumlah karakter yang akan
NEXTDATA: ; di tampilkan
MOV DPTR,#ELINS ; Isi DPTR dengan alamat dg label Awal
LCALL ISI_BUFFER
LCALL DISPLAY
INC 7EH ; RAM 7Eh untuk counter data berikutnya
DJNZ 7DH,NEXTDATA ; Ulangi sejumlah karakter yang diingikan
LCALL DISPLAY
LCALL DISPLAY
LCALL DISPLAY
; teks digeser masuk ke kiri
NEXTDATA2:
DEC 7EH ; RAM 7E untuk counter data berikutnya
MOV DPTR,#ELINS
LCALL ISI_BUFFER
LCALL DISPLAY
MOV A,7EH
CJNE A,#0,NEXTDATA2
LCALL DISPLAY
LCALL DISPLAY
LCALL DISPLAY
LJMP MULAI
; --------------------------------------------------------------------------------
; DATA AREA
; --------------------------------------------------------------------------------
ELINS: DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FDH,0A0H,0BAH, 77H, 62H, 29H,0FDH,0FDH
;
END