Interface at89s52 with p10 led and ds1307 make a digital Clock


Assalamu’alaikum wr wb

Langsung wae lah Men koyo gawe skripsian

I. Iki Gambar rangkaian atau skematike

Skematik

 

II. Iki Contoh Board PCB, Neng gambar ono konektor ps/2 Next Post sesuk iso dinput running text        go keyboard

Board PCB

 

III. Foto Alat Jadine 

Nek meh nonton Videone hasil jadi neng  kene    Or   HERE

https://www.youtube.com/watch?v=PeRFiom4TK0

JAM

IV. Carane Gawe FONT Neng 16×32 LED

Revisi tambahan menghitung hexa membuat font angka di p10 1 panel

Angka_jam

 

Nek wis dirakit, maringono di jajal lebokne program flashe neng ic iku mikro at89s52

iki contoh listing programe, tenan aku insyaalloh ora ngapusi mesti langsung urip. Tapi dirubah neng

hexa ndisek yo ojo lali. Wassalamu’alaikum wr wb

 

V. Software Code Program Jam Digital

;#define Output_Enable PORTD.0 //Output
;#define Data_A PORTD.1 //Data Merah = 0
;#define Data_B PORTD.2 //Data Merah = 0

;#define HC595_SH_CP PORTD.3 //Shift Clock (SH_CP) pin location
;#define HC595_ST_CP PORTD.4 //Store Clock (ST_CP) pin location
;#define HC595_DS PORTD.5 //Data pin (DS)
;# Programmer Sindhu Harimukti 10 November 2014

; iki etok2e men koyo avr C++

;#########################################################################;
O_E bit p2.0
D_A bit p2.1
D_B bit p2.2

S_H bit p2.3
S_T bit p2.4
D_S bit p2.5

I2C_SCL BIT P3.0
I2C_SDA BIT P3.1

Up bit P1.1
Menu bit p1.2
Down bit p1.3

flag bit p3.3
;#########################################################################;
; alamat Ram
flag_titik bit 22h.0
RTCDetik DATA 23h ;00
RTCMenit DATA 24h ;01
RTCjam DATA 25h ;02
RTCHari DATA 26h ;03
RTCTanggal DATA 27h ;04
RTCBulan DATA 28h ;05
RTCTahun DATA 29h ;06
stanby equ 2ah
Free_0 equ 2bh
Free_1 equ 2ch
Free_2 equ 2dh
Free_3 equ 2eh
TMP equ 2fh
;#########################################################################;
Led_1a equ 30h
Led_2a equ 31h
Led_3a equ 32h
Led_4a equ 33h

Led_1b equ 34h
Led_2b equ 35h
Led_3b equ 36h
Led_4b equ 37h

Led_1c equ 38h
Led_2c equ 39h
Led_3c equ 3ah
Led_4c equ 3bh

Led_1d equ 3ch
Led_2d equ 3dh
Led_3d equ 3eh
Led_4d equ 3fh

LEDDigit1 DATA 40h
LEDDigit2 DATA 41h
LEDDigit3 DATA 42h
LEDDigit4 DATA 43h
LEDDigit5 DATA 44h
LEDDigit6 DATA 45h
DPTR_HIGH equ 4bh
DPTR_LOW equ 4ch
temp_detik equ 4dh
;#########################################################################;
; alamat RAM
; Mulai Jam
rm01 equ 128 ; = 7fH
rm02 equ 142
ram_t2 equ 156 ; Titik 2
rm03 equ 164
rm04 equ 178

rm05 equ 192
rm06 equ 206

;##########################################################################
; Alamat eeprom
;##########################################################################
WRTCMD EQU 11010000b ;WRITE DATA COMMAND Note 3
RRDCMD EQU 11010001b ;READ DATA COMMAND Note 3
WTCMD EQU 10100000B ;WRITE DATA COMMAND Note 3
RDCMD EQU 10100001B ;READ DATA COMMAND Note 3
RDEND EQU 01000000B ;READ HIGH-ENDURANCE BLOCK NUMBER COMMAND
BYTCNT EQU 8
BYTSTR equ 22h ;STORAGE FOR READ DATA
;#########################################################################;

;#########################################################################;
org 0h
;==============================================================;
; Program Utama
;==============================================================;
ProgramLoop: clr o_e
call hapus_ram
call tunda_1_detik
call tunda_1_detik
call tunda_1_detik
call tunda_1_detik
call tunda_1_detik
MOV R1,#10h
MOV A,#11010000b
MOV B,#07 ;address For Control DS1307
Call I2C_WriteByte
setb flag
setb menu
setb up
setb down
call ReadAllRTC
mov a,rtcdetik
mov temp_detik,a

Loop: call ReadAllRTC
mov a,rtcdetik
cjne A,temp_detik,lanjut

jb menu,lanjut_4
jnb menu,$
jmp Kybd_ctrl

lanjut: cpl flag_titik
mov a,rtcdetik
mov temp_detik,a

setb menu
setb up
setb down

lanjut_4: CALL StreamRTC
call Konversi_a
call tampil_a
call Konversi_b
call tampil_b
call Konversi_c
call tampil_c
call Konversi_d
call tampil_d
Jmp Loop
;==========================================================================
; Tampilan Dotmatrix
hapus_ram: mov R0,#rm01
mov R1,#120
U_hapus: mov @R0,#0ffh
inc r0
djnz R1,U_hapus
RET
StreamRTC: MOV DPTR_HIGH,DPH
MOV DPTR_LOW,DPL

MOV A,rtcJAM
call swapa
CALL K_M_1
MOV A,rtcJAM
call Anl_A
CALL K_M_2

jb flag_titik,L_titik
call titik_off
jmp L_titik_2

L_titik: CALL TITIK_JAM

L_titik_2: MOV A,rtcMENIT
call swapa
CALL K_M_3
MOV A,rtcMENIT
call Anl_A
CALL K_M_4

MOV DPH,DPTR_HIGH
MOV DPL,DPTR_LOW
Ret

Anl_A: ANL A,#00Fh
Call GetLEDNum
ret
swapa: swap a
call Anl_A
ret

TITIK_JAM: mov R0,#ram_t2
mov @R0,#0E3h
inc r0
mov @R0,#0c7h
inc r0
mov @R0,#0E3h
inc r0
mov @R0,#0c7h
inc r0
mov @R0,#0E3h
inc r0
mov @R0,#0c7h
inc r0
mov @R0,#0ffh
inc r0
mov @R0,#0ffh
RET

TITIK_OFF: mov R0,#ram_t2
mov @R0,#0FFh
inc r0
mov @R0,#0FFh
inc r0
mov @R0,#0FFh
inc r0
mov @R0,#0FFh
inc r0
mov @R0,#0FFh
inc r0
mov @R0,#0FFh
inc r0
mov @R0,#0ffh
inc r0
mov @R0,#0ffh
RET

;##########################################################################
; Subrutine Setting Waktu
;##########################################################################
Kybd_ctrl: call hapus_ram
Loop_jam: call refresh_jame
Jb up,kurang_jam
jnb up,$
call up_jam
jmp loop_jam
Kurang_jam: jb down,cek_out_j
jnb down,$
call down_jam
jmp loop_jam
cek_out_j: jb menu,Loop_jam
jnb menu,$
call Konversi_a
call tampil_a
call Konversi_b
call tampil_b
call Konversi_c
call tampil_c
call Konversi_d
call tampil_d
call hapus_ram

Loop_Mnt: call refresh_menite
Jb up,kurang_Mnt
jnb up,$
call up_Menit
jmp loop_Mnt
Kurang_Mnt: Jb down,cek_out_m
jnb down,$
call down_Menit
jmp loop_Mnt

cek_out_m: Jb menu,Loop_Mnt
jnb menu,$
call tulis_rtc_detik
call hapus_ram
jmp loop

refresh_jame: call readallrtc
MOV A,rtcJAM
call swapa
CALL K_M_1
MOV A,rtcJAM
call Anl_A
CALL K_M_2
call Konversi_a
call tampil_a
call Konversi_b
call tampil_b
call Konversi_c
call tampil_c
call Konversi_d
call tampil_d
ret

refresh_menite: call readallrtc
MOV A,rtcMENIT
call swapa
CALL K_M_3
MOV A,rtcMENIT
call Anl_A
CALL K_M_4
call Konversi_a
call tampil_a
call Konversi_b
call tampil_b
call Konversi_c
call tampil_c
call Konversi_d
call tampil_d
ret

;##########################################################################
; Edit RTC
;########################################################################
up_jam: MOV A,RTCJam
CJNE A,#23h,Up_jam2
MOV A,#0
Jmp Up_jam3
Up_jam2: add a,#1
Up_jam3: da a
MOV RTCJam,A
call tulis_rtc_jam
ret

down_jam: MOV A,rtcjam
call konvert_dec
dec a
CJNE A,#0ffh,down_jam2
MOV A,#23
down_jam2: call konvert_hex
MOV RTCJam,A
call tulis_rtc_jam
ret

up_menit: MOV A,RTCmenit
CJNE A,#59h,Up_menit2
MOV A,#0
Jmp Up_menit3
Up_menit2: add a,#1
Up_menit3: da a
MOV RTCmenit,A
call tulis_rtc_menit
ret

down_menit: MOV A,rtcmenit
call konvert_dec
dec a
CJNE A,#0ffh,down_menit2
MOV A,#59
down_menit2: call konvert_hex
MOV RTCmenit,A
call tulis_rtc_menit
ret
;##########################################################################
T2_r0: inc r0
inc r0
ret

T2_R0_B8: call T2_r0
call konvert_b8
ret
T2_R0_B7: call T2_r0
call konvert_b7
ret
T2_R0_B6: call T2_r0
call konvert_b6
ret
T2_R0_B5: call T2_r0
call konvert_b5
ret
T2_R0_B4: call T2_r0
call konvert_b4
ret
T2_R0_B3: call T2_r0
call konvert_b3
ret
T2_R0_B2: call T2_r0
call konvert_b2
ret
T2_R0_B1: call T2_r0
call konvert_b1
ret
;##########################################################################
Konversi_a: mov R0,#rm01
call konvert_b8
mov led_1a,a
call T2_R0_B8
mov led_2a,a
call T2_R0_B8
mov led_3a,a
call T2_R0_B8
mov led_4a,a

mov R0,#rm01
call konvert_b4
mov led_1b,a
call T2_R0_B4
mov led_2b,a
call T2_R0_B4
mov led_3b,a
call T2_R0_B4
mov led_4b,a

mov R0,#rm01+1
call konvert_b8
mov led_1c,a
call T2_R0_B8
mov led_2c,a
call T2_R0_B8
mov led_3c,a
call T2_R0_B8
mov led_4c,a

mov R0,#rm01+1
call konvert_b4
mov led_1d,a
call T2_R0_B4
mov led_2d,a
call T2_R0_B4
mov led_3d,a
call T2_R0_B4
mov led_4d,a
ret
;##########################################################################
Konversi_b: mov R0,#rm01
call konvert_b7
mov led_1a,a
call T2_R0_B7
mov led_2a,a
call T2_R0_B7
mov led_3a,a
call T2_R0_B7
mov led_4a,a

mov R0,#rm01
call konvert_b3
mov led_1b,a
call T2_R0_B3
mov led_2b,a
call T2_R0_B3
mov led_3b,a
call T2_R0_B3
mov led_4b,a

mov R0,#rm01+1
call konvert_b7
mov led_1c,a
call T2_R0_B7
mov led_2c,a
call T2_R0_B7
mov led_3c,a
call T2_R0_B7
mov led_4c,a

mov R0,#rm01+1
call konvert_b3
mov led_1d,a
call T2_R0_B3
mov led_2d,a
call T2_R0_B3
mov led_3d,a
call T2_R0_B3
mov led_4d,a
ret
;##########################################################################
Konversi_c: mov R0,#rm01
call konvert_b6
mov led_1a,a
call T2_R0_B6
mov led_2a,a
call T2_R0_B6
mov led_3a,a
call T2_R0_B6
mov led_4a,a

mov R0,#rm01
call konvert_b2
mov led_1b,a
call T2_R0_B2
mov led_2b,a
call T2_R0_B2
mov led_3b,a
call T2_R0_B2
mov led_4b,a

mov R0,#rm01+1
call konvert_b6
mov led_1c,a
call T2_R0_B6
mov led_2c,a
call T2_R0_B6
mov led_3c,a
call T2_R0_B6
mov led_4c,a

mov R0,#rm01+1
call konvert_b2
mov led_1d,a
call T2_R0_B2
mov led_2d,a
call T2_R0_B2
mov led_3d,a
call T2_R0_B2
mov led_4d,a
ret
;##########################################################################
Konversi_d: mov R0,#rm01
call konvert_b5
mov led_1a,a
call T2_R0_B5
mov led_2a,a
call T2_R0_B5
mov led_3a,a
call T2_R0_B5
mov led_4a,a

mov R0,#rm01
call konvert_b1
mov led_1b,a
call T2_R0_B1
mov led_2b,a
call T2_R0_B1
mov led_3b,a
call T2_R0_B1
mov led_4b,a

mov R0,#rm01+1
call konvert_b5
mov led_1c,a
call T2_R0_B5
mov led_2c,a
call T2_R0_B5
mov led_3c,a
call T2_R0_B5
mov led_4c,a

mov R0,#rm01+1
call konvert_b1
mov led_1d,a
call T2_R0_B1
mov led_2d,a
call T2_R0_B1
mov led_3d,a
call T2_R0_B1
mov led_4d,a
ret
;#########################################################################;
C_data: CLR S_H
CLR S_H
Clr S_T
CLR S_T

mov A,Led_1d
Call HC595_Shift
mov A,Led_1c
Call HC595_Shift
mov A,Led_1b
Call HC595_Shift
mov A,Led_1a
Call HC595_Shift

mov A,Led_2d
Call HC595_Shift
mov A,Led_2c
Call HC595_Shift
mov A,Led_2b
Call HC595_Shift
mov A,Led_2a
Call HC595_Shift

mov A,Led_3d
Call HC595_Shift
mov A,Led_3c
Call HC595_Shift
mov A,Led_3b
Call HC595_Shift
mov A,Led_3a
Call HC595_Shift

mov A,Led_4d
Call HC595_Shift
mov A,Led_4c
Call HC595_Shift
mov A,Led_4b
Call HC595_Shift
mov A,Led_4a
Call HC595_Shift

Clr S_T
Clr S_T
SetB S_T
SetB S_T
Ret

HC595_Shift:MOV R2,#8
HC595_ShLop:RLC A
MOV D_S,C
SetB S_H
SetB S_H
CLR S_H
CLR S_H
DJNZ R2,HC595_ShLop
Ret
;#########################################################################;
Tampil_a: clr d_a
clr d_b
call C_data
setb o_e
call pwm
ret
Tampil_b: setb d_a
clr d_b
call C_data
setb o_e
call pwm
ret
Tampil_c: clr d_a
setb d_b
call C_data
setb o_e
call pwm
ret
Tampil_d: setb d_a
setb d_b
call C_data
setb o_e
call pwm
ret

pwm: call D_100us
clr o_e
call D_2ms
ret
;#########################################################################;
D_100us: MOV R7,#5 ; waktu on
T1D: MOV R6,#100
DJNZ R6,$
DJNZ R7,T1D
Ret

D_2ms: MOV R7,#1 ; waktu off
T2D: MOV R6,#1
DJNZ R6,$
DJNZ R7,T2D
Ret

Tunda_1s: MOV R7,#6
T2a: MOV R6,#100
T1a: MOV R5,#230
DJNZ R5,$
DJNZ R6,T1a
DJNZ R7,T2a
Ret

;data_H_TI: db 0FFh,0FFh,0FFh,0FFh,0FFh,0F1h,0FFh,0F1h,0FFh,0F1h,0FFh,0FFh,0Ffh,0Ffh ;OK
;##########################################################################
; Geser ke kiri
;##########################################################################
Geser_kiri: mov Free_3,#96
mov R1,#rm01
mov R0,#rm01+2
Geser_kirii: mov a,@r0
mov @R1,a
inc r0
inc r1
mov a,@r0
mov @R1,a
inc r0
inc r1
djnz Free_3,Geser_kirii
ret
;##########################################################################
; KONVERSI 1 ASCII KE DATA DOT MATRIK
;##########################################################################
K_m_1: mov R0,#rm01
JMP sC_h
K_m_2: mov R0,#rm02
JMP sC_h
K_m_3: mov R0,#rm03
JMP sC_h
K_m_4: mov R0,#rm04
JMP sC_h
K_m_5: mov R0,#rm05
JMP sC_h
K_m_6: mov R0,#rm06
JMP sC_h
sC_h: call scan_huruf
ret
;##########################################################################
; Konversi Ascii ke Dot Matrix
; Dibuat oleh Sindhu Harimukti
; Jumat 03 agustus 2012
;##########################################################################
F_14x: mov free_3,#14
mov DPTR_high,dph
mov DPTR_low,dpl
ret

Scan_Huruf:
A_0: cjne a,#’0′,A_1
call F_14x
mov DPTR,#data_H_0
jmp A_d_m
A_1: cjne a,#’1′,A_2
call F_14x
mov DPTR,#data_H_1
jmp A_d_m
A_2: cjne a,#’2′,A_3
call F_14x
mov DPTR,#data_H_2
jmp A_d_m
A_3: cjne a,#’3′,A_4
call F_14x
mov DPTR,#data_H_3
jmp A_d_m
A_4: cjne a,#’4′,A_5
call F_14x
mov DPTR,#data_H_4
jmp A_d_m
A_5: cjne a,#’5′,A_6
call F_14x
mov DPTR,#data_H_5
jmp A_d_m
A_6: cjne a,#’6′,A_7
call F_14x
mov DPTR,#data_H_6
jmp A_d_m
A_7: cjne a,#’7′,A_8
call F_14x
mov DPTR,#data_H_7
jmp A_d_m
A_8: cjne a,#’8′,A_9
call F_14x
mov DPTR,#data_H_8
jmp A_d_m
A_9: cjne a,#’9′,spasi
call F_14x
mov DPTR,#data_H_9
jmp A_d_m
SPASI: cjne a,#’ ‘,keluar
call F_14x
mov DPTR,#data_SPASI
jmp A_d_m
keluar: ret

;##########################################################################
A_d_m : clr a
movc A,@A+DPTR
MOV @R0,A
inc r0
inc dptr
djnz free_3,A_d_m
mov Dph,DPTR_high
mov dpl,DPTR_low
ret
;##########################################################################
; Data Font Matrix 16×16
; Dibuat oleh Sindhu Harimukti
; sunday 03 feb 2013
;##########################################################################
data_H_0: db 0C0h,03h,080h,01h,0BFh,0FDh,0BFh,0FDh,080h,01h,0C0h,03h,0ffh,0ffh ;OKE
data_H_1: db 0F7h,0F9h,0E7h,0F9h,080h,01h,080h,01h,0Ffh,0f9h,0FFh,0F9h,0ffh,0ffh ;OKE
data_H_2: db 0C7h,81h,087h,01h,0BEh,39h,0BCh,079h,080h,0F9h,0C1h,0F9h,0ffh,0ffh ;OKE
data_H_3: db 0C7h,0E3h,08Eh,71h,0BEh,7Dh,0BEh,7Dh,88h,11h,0C1h,83h,0ffh,0ffh ;OKE
data_H_4: db 0C0h,0FFh,080h,7Fh,0FEh,7Fh,0FEh,7Fh,080h,03h,0C0h,01h,0ffh,0ffh ;OKE
data_H_5: db 080h,0E3h,080h,0F1h,09Ch,7Dh,09Eh,7Dh,09Eh,01h,09Fh,03h,0ffh,0ffh ;OKE
data_H_6: db 0C0h,03h,080h,01h,09Ch,0FDh,0BCh,0FDh,0BCh,01h,0BEh,03h,0ffh,0ffh ;OKE
data_H_7: db 09Fh,0F1h,09Fh,0C1h,09Fh,01h,09Ch,7Fh,080h,0FFh,083h,0FFh,0ffh,0ffh ;OK
data_H_8: db 0C1h,83h,080h,01h,0BEh,07Dh,0BEh,07Dh,080h,01h,0C1h,83h,0ffh,0ffh ;OKE
data_H_9: db 0C1h,0F3h,080h,71h,0BEh,07Dh,0BEh,07Dh,080h,01h,0C0h,03h,0ffh,0ffh ;OKE
data_spasi: db 0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh ;OKE
;##########################################################################

;##########################################################################
konvert_b1: clr a
mov 20h,@r0
jb 20h.0,C00
clr acc.7
jmp c1
c00: setb acc.7

c1: call T2_r0
mov 20h,@r0
jb 20h.0,C11
clr acc.6
jmp c2
c11: setb acc.6

c2: call T2_r0
mov 20h,@r0
jb 20h.0,C22
clr acc.5
jmp c3
c22: setb acc.5

c3: call T2_r0
mov 20h,@r0
jb 20h.0,C33
clr acc.4
jmp c4
c33: setb acc.4

c4: call T2_r0
mov 20h,@r0
jb 20h.0,C44
clr acc.3
jmp c5
c44: setb acc.3

c5: call T2_r0
mov 20h,@r0
jb 20h.0,C55
clr acc.2
jmp c6
c55: setb acc.2

c6: call T2_r0
mov 20h,@r0
jb 20h.0,C66
clr acc.1
jmp c7
c66: setb acc.1

c7: call T2_r0
mov 20h,@r0
jb 20h.0,C77
clr acc.0
jmp c8
c77: setb acc.0

c8: ret
;##########################################################################
konvert_b2: clr a
mov 20h,@r0
jb 20h.1,C00b
clr acc.7
jmp c1b
c00b: setb acc.7

c1b: call T2_r0
mov 20h,@r0
jb 20h.1,C11b
clr acc.6
jmp c2b
c11b: setb acc.6

c2b: call T2_r0
mov 20h,@r0
jb 20h.1,C22b
clr acc.5
jmp c3b
c22b: setb acc.5

c3b: call T2_r0
mov 20h,@r0
jb 20h.1,C33b
clr acc.4
jmp c4b
c33b: setb acc.4

c4b: call T2_r0
mov 20h,@r0
jb 20h.1,C44b
clr acc.3
jmp c5b
c44b: setb acc.3

c5b: call T2_r0
mov 20h,@r0
jb 20h.1,C55b
clr acc.2
jmp c6b
c55b: setb acc.2

c6b: call T2_r0
mov 20h,@r0
jb 20h.1,C66b
clr acc.1
jmp c7b
c66b: setb acc.1

c7b: call T2_r0
mov 20h,@r0
jb 20h.1,C77b
clr acc.0
jmp c8b
c77b: setb acc.0

c8b: ret

;##########################################################################
konvert_b3: clr a
mov 20h,@r0
jb 20h.2,C00c
clr acc.7
jmp c1c
c00c: setb acc.7

c1c: call T2_r0
mov 20h,@r0
jb 20h.2,C11c
clr acc.6
jmp c2c
c11c: setb acc.6

c2c: call T2_r0
mov 20h,@r0
jb 20h.2,C22c
clr acc.5
jmp c3c
c22c: setb acc.5

c3c: call T2_r0
mov 20h,@r0
jb 20h.2,C33c
clr acc.4
jmp c4c
c33c: setb acc.4

c4c: call T2_r0
mov 20h,@r0
jb 20h.2,C44c
clr acc.3
jmp c5c
c44c: setb acc.3

c5c: call T2_r0
mov 20h,@r0
jb 20h.2,C55c
clr acc.2
jmp c6c
c55c: setb acc.2

c6c: call T2_r0
mov 20h,@r0
jb 20h.2,C66c
clr acc.1
jmp c7c
c66c: setb acc.1

c7c: call T2_r0
mov 20h,@r0
jb 20h.2,C77c
clr acc.0
jmp c8c
c77c: setb acc.0

c8c: ret
;##########################################################################
konvert_b4: clr a
mov 20h,@r0
jb 20h.3,C00d
clr acc.7
jmp c1d
c00d: setb acc.7

c1d: call T2_r0
mov 20h,@r0
jb 20h.3,C11d
clr acc.6
jmp c2d
c11d: setb acc.6

c2d: call T2_r0
mov 20h,@r0
jb 20h.3,C22d
clr acc.5
jmp c3d
c22d: setb acc.5

c3d: call T2_r0
mov 20h,@r0
jb 20h.3,C33d
clr acc.4
jmp c4d
c33d: setb acc.4

c4d: call T2_r0
mov 20h,@r0
jb 20h.3,C44d
clr acc.3
jmp c5d
c44d: setb acc.3

c5d: call T2_r0
mov 20h,@r0
jb 20h.3,C55d
clr acc.2
jmp c6d
c55d: setb acc.2

c6d: call T2_r0
mov 20h,@r0
jb 20h.3,C66d
clr acc.1
jmp c7d
c66d: setb acc.1

c7d: call T2_r0
mov 20h,@r0
jb 20h.3,C77d
clr acc.0
jmp c8d
c77d: setb acc.0

c8d: ret
;##########################################################################
konvert_b5: clr a
mov 20h,@r0
jb 20h.4,C00e
clr acc.7
jmp c1e
c00e: setb acc.7

c1e: call T2_r0
mov 20h,@r0
jb 20h.4,C11e
clr acc.6
jmp c2e
c11e: setb acc.6

c2e: call T2_r0
mov 20h,@r0
jb 20h.4,C22e
clr acc.5
jmp c3e
c22e: setb acc.5

c3e: call T2_r0
mov 20h,@r0
jb 20h.4,C33e
clr acc.4
jmp c4e
c33e: setb acc.4

c4e: call T2_r0
mov 20h,@r0
jb 20h.4,C44e
clr acc.3
jmp c5e
c44e: setb acc.3

c5e: call T2_r0
mov 20h,@r0
jb 20h.4,C55e
clr acc.2
jmp c6e
c55e: setb acc.2

c6e: call T2_r0
mov 20h,@r0
jb 20h.4,C66e
clr acc.1
jmp c7e
c66e: setb acc.1

c7e: call T2_r0
mov 20h,@r0
jb 20h.4,C77e
clr acc.0
jmp c8e
c77e: setb acc.0

c8e: ret
;##########################################################################
konvert_b6: clr a
mov 20h,@r0
jb 20h.5,C00f
clr acc.7
jmp c1f
c00f: setb acc.7

c1f: call T2_r0
mov 20h,@r0
jb 20h.5,C11f
clr acc.6
jmp c2f
c11f: setb acc.6

c2f: call T2_r0
mov 20h,@r0
jb 20h.5,C22f
clr acc.5
jmp c3f
c22f: setb acc.5

c3f: call T2_r0
mov 20h,@r0
jb 20h.5,C33f
clr acc.4
jmp c4f
c33f: setb acc.4

c4f: call T2_r0
mov 20h,@r0
jb 20h.5,C44f
clr acc.3
jmp c5f
c44f: setb acc.3

c5f: call T2_r0
mov 20h,@r0
jb 20h.5,C55f
clr acc.2
jmp c6f
c55f: setb acc.2

c6f: call T2_r0
mov 20h,@r0
jb 20h.5,C66f
clr acc.1
jmp c7f
c66f: setb acc.1

c7f: call T2_r0
mov 20h,@r0
jb 20h.5,C77f
clr acc.0
jmp c8f
c77f: setb acc.0

c8f: ret
;##########################################################################
konvert_b7: clr a
mov 20h,@r0
jb 20h.6,C00g
clr acc.7
jmp c1g
c00g: setb acc.7

c1g: call T2_r0
mov 20h,@r0
jb 20h.6,C11g
clr acc.6
jmp c2g
c11g: setb acc.6

c2g: call T2_r0
mov 20h,@r0
jb 20h.6,C22g
clr acc.5
jmp c3g
c22g: setb acc.5

c3g: call T2_r0
mov 20h,@r0
jb 20h.6,C33g
clr acc.4
jmp c4g
c33g: setb acc.4

c4g: call T2_r0
mov 20h,@r0
jb 20h.6,C44g
clr acc.3
jmp c5g
c44g: setb acc.3

c5g: call T2_r0
mov 20h,@r0
jb 20h.6,C55g
clr acc.2
jmp c6g
c55g: setb acc.2

c6g: call T2_r0
mov 20h,@r0
jb 20h.6,C66g
clr acc.1
jmp c7g
c66g: setb acc.1

c7g: call T2_r0
mov 20h,@r0
jb 20h.6,C77g
clr acc.0
jmp c8g
c77g: setb acc.0

c8g: ret
;##########################################################################
konvert_b8: clr a
mov 20h,@r0
jb 20h.7,C00H
clr acc.7
jmp c1H
c00H: setb acc.7

c1H: call T2_r0
mov 20h,@r0
jb 20h.7,C11H
clr acc.6
jmp c2H
c11H: setb acc.6

c2H: call T2_r0
mov 20h,@r0
jb 20h.7,C22H
clr acc.5
jmp c3H
c22H: setb acc.5

c3H: call T2_r0
mov 20h,@r0
jb 20h.7,C33H
clr acc.4
jmp c4H
c33H: setb acc.4

c4H: call T2_r0
mov 20h,@r0
jb 20h.7,C44H
clr acc.3
jmp c5H
c44H: setb acc.3

c5H: call T2_r0
mov 20h,@r0
jb 20h.7,C55H
clr acc.2
jmp c6H
c55H: setb acc.2

c6H: call T2_r0
mov 20h,@r0
jb 20h.7,C66H
clr acc.1
jmp c7H
c66H: setb acc.1

c7H: call T2_r0
mov 20h,@r0
jb 20h.7,C77H
clr acc.0
jmp c8H
c77H: setb acc.0

c8H: ret
;==============================================================;
; Delay
;==============================================================;
Tunda_1_Detik: MOV R7,#13
Tunda1DetikL2a: MOV R6,#100
Tunda1DetikL1a: MOV R5,#230
DJNZ R5,$
DJNZ R6,Tunda1DetikL1a
DJNZ R7,Tunda1DetikL2a
Ret

Tunda_1_2_Detik: MOV R7,#3
jmp Tunda1DetikL2a

Hapus_tampilan: clr o_e
Ret
;==============================================================;
; Hexa X desimal
;==============================================================;
tabel_hex:
db 00h,01h,02h,03h,04h,05h,06h,07h,08h,09h,10h
db 11h,12h,13h,14h,15h,16h,17h,18h,19h,20h
db 21h,22h,23h,24h,25h,26h,27h,28h,29h,30h
db 31h,32h,33h,34h,35h,36h,37h,38h,39h,40h
db 41h,42h,43h,44h,45h,46h,47h,48h,49h,50h
db 51h,52h,53h,54h,55h,56h,57h,58h,59h,60h
db 61h,62h,63h,64h,65h,66h,67h,68h,69h,70h
db 71h,72h,73h,74h,75h,76h,77h,78h,79h,80h
db 81h,82h,83h,84h,85h,86h,87h,88h,89h,90h
db 91h,82h,93h,94h,95h,96h,97h,98h,99h

tabel_dec:
db 00,01,02,03,04,05,06,07,08,09,00,00,00,00,00,00
db 10,11,12,13,14,15,16,17,18,19,00,00,00,00,00,00
db 20,21,22,23,24,25,26,27,28,29,00,00,00,00,00,00
db 30,31,32,33,34,35,36,37,38,39,00,00,00,00,00,00
db 40,41,42,43,44,45,46,47,48,49,00,00,00,00,00,00
db 50,51,52,53,54,55,56,57,58,59,00,00,00,00,00,00
db 60,61,62,63,64,65,66,67,68,69,00,00,00,00,00,00
db 70,71,72,73,74,75,76,77,78,79,00,00,00,00,00,00
db 80,81,82,83,84,85,86,87,88,89,00,00,00,00,00,00
db 90,91,82,93,94,95,96,97,98,99,00,00,00,00,00,00
konversi_1: ANL A,#00Fh
Call GetLEDNum
ret
;==============================================================;
; Konversi ke tampilan 7 segment
;==============================================================;
GetLEDNum: Inc A
MOVC A,@A+PC
Ret
;CBAG.FED

CharLED1: DB ’0′ ;0
DB ’1′ ;1
DB ’2′ ;2
DB ’3′ ;3
DB ’4′ ;4
DB ’5′ ;5
DB ’6′ ;6
DB ’7′ ;7
DB ’8′ ;8
DB ’9′ ;9
;==============================================================;
; Ambil data RTC simpan ke RAM mikro
;==============================================================;
konvert_dec: mov DPTR,#tabel_dec
movc A,@A+DPTR
ret
konvert_hex: mov DPTR,#tabel_hex
movc A,@A+DPTR
ret

;==============================================================;
Hps_A: clr a
movc A,@A+DPTR
ret

tampil_14_huruf: call Hps_A
call k_m_1
inc dptr
call Hps_A
call k_m_2
inc dptr

CALL TITIK_JAM

call Hps_A
call k_m_3
inc dptr
call Hps_A
call k_m_4
inc dptr

call Konversi_a
call tampil_a
call Konversi_b
call tampil_b
call Konversi_c
call tampil_c
call Konversi_d
call tampil_d
Ret
;==============================================================;
; pengendali Bus IIC disusun oleh
; Dhanny Dhuzell 2008 Bandar Lampung
; Single Master Sudah diuji-coba dan sangat baik
; Bandwidth sekitar 80 kHz (Mode-Normal-Speed)
; Modul ini butuh “ErrorsEqu.inc”
;==============================================================;
I2C_Start: SetB I2C_SDA
SetB I2C_SCL
JNB I2C_SDA, I2C_BusBusy
JNB I2C_SCL, I2C_BusBusy
Clr I2C_SDA
Push ACC
POP ACC
Clr I2C_SCL
Push ACC
POP ACC
Clr C
Ret
I2C_BusBusy: SetB C
Ret
;==============================================================;
I2C_Stop: Clr I2C_SDA
SETB I2C_SCL
JNB I2C_SCL,$
NOP
NOP
NOP
SetB I2C_SDA
Ret
;==============================================================;
I2C_SendByte: PUSH B
MOV B,#8

I2C_SendByteL: RLC A ;1MC |
MOV I2C_SDA,C ;2MC |
SETB I2C_SCL
JNB I2C_SCL,$
NOP
NOP
NOP
Clr I2C_SCL ;1MC +-+
DJNZ B,I2C_SendByteL ;2MC |
SETB I2C_SCL
JNB I2C_SCL,$
NOP
NOP
NOP
NOP
MOV C,I2C_SDA ;1MC | read ACK/NOACK
Clr I2C_SCL ;1MC +-+
NOP
NOP
NOP
POP B ;2MC |
RET
; Low = 6MC High = 5MC
;==============================================================;
I2C_GetByte: PUSH B
PUSH PSW ;Save CY
MOV B,#8
SetB I2C_SDA ;1MC |
I2C_GetByteL: SETB I2C_SCL
JNB I2C_SCL,$
NOP
NOP
NOP
MOV C,I2C_SDA ;1MC |
RLC A ;1MC |
Clr I2C_SCL ;1MC +-+
NOP
NOP
NOP
DJNZ B,I2C_GetByteL ;2MC |
POP PSW ;1MC | Load CY
MOV I2C_SDA,C ;2MC |
SETB I2C_SCL
JNB I2C_SCL,$
NOP
NOP
NOP
Clr I2C_SCL ;1MC +-+
SetB I2C_SDA ;1MC |
NOP
NOP
POP B ;1MC | Load CY
RET
; Low = 6MC High = 5MC
;==============================================================;
I2C_WriteByte: Call I2C_Start
JC l_ERROR1
Clr ACC.0
Call I2C_SendByte ;Send SlaveAddress
JC l_ERROR2
MOV A,B
Call I2C_SendByte ;Send Word Address
JC l_ERROR3
MOV A,R1
Call I2C_SendByte ;Send Data Byte
JC l_ERROR4
Call I2C_Stop
Clr C
Call I2C_WriteDelay
Clr A
MOV B,A ;max 5mS
I2C_WriteByteL: DJNZ ACC,I2C_WriteByteL
DJNZ B,I2C_WriteByteL
Ret
; ACC = SlaveAddress, B = WordAddress, R1 = Data byte
;==============================================================;
I2C_ReadByte: Call I2C_Start
JC l_ERROR1
MOV DPL,A ;Save SlaveAddress
Clr ACC.0
Call I2C_SendByte ;Send SlaveAddress
JC l_ERROR2
MOV A,B
Call I2C_SendByte ;Send Word Address
JC l_ERROR3
Call I2C_Start
JC l_ERROR1
MOV A,DPL ;Load SlaveAddress again
SetB ACC.0
Call I2C_SendByte ;Send SlaveAddress
JC l_ERROR2
SetB C ;Set to NOACK
Call I2C_GetByte ;Get Data Byte
Call I2C_Stop
Clr C
Ret
; ACC = SlaveAddress, B = WordAddress
;==============================================================;
I2C_WriteData: Call I2C_Start
JC l_ERROR1
Clr ACC.0
Call I2C_SendByte ;Send SlaveAddress
JC l_ERROR2
MOV A,B
Call I2C_SendByte ;Send Word Address
JC l_ERROR3
I2C_WriteDataL: MOV A,@R1
call I2C_SendByte ;Send Data Byte
INC R1
JC l_ERROR4
DJNZ R2,I2C_WriteDataL
I2C_WriteDataE: Call I2C_Stop
Clr C
Call I2C_WriteDelay
I2C_WriteDelay: Clr A
MOV B,A ;max 5mS (( 2 *256 ) * 256 )
I2C_WriteDataF: DJNZ ACC,I2C_WriteDataF
DJNZ B,I2C_WriteDataF
Ret
; ACC = SlaveAddress, B = WordAddress, R1 = DataMemoryOffset, R2 = Counter,
;==============================================================;
l_ERROR1: MOV A,#11
Call I2C_Stop
Ret
l_ERROR2: MOV A,#12
Call I2C_Stop
Ret
l_ERROR3: MOV A,#13
Call I2C_Stop
Ret
l_ERROR4: MOV A,#14
Call I2C_Stop
Ret
;==============================================================;
I2C_ReadData: Call I2C_Start
JC l_ERROR1
MOV DPL,A ;Save SlaveAddress
Clr ACC.0
Call I2C_SendByte ;Send SlaveAddress
JC l_ERROR2
MOV A,B
Call I2C_SendByte ;Send Word Address
JC l_ERROR3
Call I2C_Start
JC l_ERROR1
MOV A,DPL ;Load SlaveAddress again
SetB ACC.0
Call I2C_SendByte ;Send SlaveAddress
JC l_ERROR2
DEC R2
I2C_ReadDataL: Clr C ;Set to ACK
Call I2C_GetByte ;Get Data Byte
MOV @R1,A
INC R1
DJNZ R2,I2C_ReadDataL
SetB C ;Set to NOACK
Call I2C_GetByte ;Get Data Byte
MOV @R1,A
Call I2C_Stop
Clr C
Ret
; ACC = SlaveAddress, B = WordAddress, R1 = DataMemoryOffset, R2 = Counter
;##########################################################################
; Tulis / baca rtc
;##########################################################################
ReadAllRTC: MOV A,#11010001b ;SlaveAddress
MOV B,#0
MOV R1,#RTCDetik
MOV R2,#7
Call I2C_ReadData ; ACC = SlaveAddress, B = WordAddress, R1 = DataMemoryOffset, R2 = Counter
ret
Tulis_rtc_jam: MOV A,#11010000b
mov B,#02h ;Alamat
mov R1,rtcjam ;datanya
JMP I2C_W
Tulis_rtc_menit: MOV A,#11010000b
mov B,#01h
mov R1,rtcmenit
JMP I2C_W

Tulis_rtc_Detik: MOV A,#11010000b
mov B,#00h
mov R1,#00h
JMP I2C_W
I2C_W: Call I2C_WriteByte
ret
end