Вы находитесь на странице: 1из 128

RF ID

ATTENDENCE
RECORD
LOGIC.

In this project we show the concept of auto attendance recorder with the
HELP OF THE RF ID DATA TRANSFER. As the teacher or any person is
enter in the room, then first of all he SEND ITS RF DATA , if the card data
base is match with the data base then door is open for some time. When
door is open then for that day and that time this is to be recorded in the data
base. Now in the evening it is possible to check the record of the this smart
card for which time he enter in the area and for which time he exit from the
area by enter in the menu driven program. In the menu driven program the
we check the card number and card number show the detail of the card
automatically.
Data base is to be recorded in the external memory. Here we use ic 24c02
memory to record all the data. For the time calculation we use

RTC

interface. RTC is a real time clock and with the help of this RTC clock it is
possible to maintain the record of the date, time and day also.

Main components:

Rf module ask 433 Mhtz tx and rx


Microcontroller 89s51
Lcd 2 by 16.
Encoder and decoder HT 12E and HT12D
In every card we use one encoder ic with digital data base, this digital
data base may be 16 bit or 32 bit. In this project we use 4 bit data
base to show the basic concept of this project. There are many type
of encoder and decoder are available in the market. Easily available
encoder and decoders are HT12 E and HT 12D. HT12 E is encoder
ic and HT 12D is

decoder ic. These encoder and decoder ic is

designed by the HOLTEK company. We use 18 pin version of


encoder and decoder ic.

Selection Table
General Description

The 212 encoders are a series of CMOS LSIs for remote control
system applications.
They are capable of encoding

information which consists of N address bits and 12_N data bits.


Each address/data input can be set to

one of the two logic states. The programmed addresses/ data are
transmitted together with the header

bits via an RF or an infrared transmission medium upon receipt of a


trigger signal. The capability to select a TE

trigger on the HT12E or a DATA trigger on the HT12A further


enhances the application flexibility of the 212 series

of encoders. The HT12A additionally provides a 38kHz carrier for


infrared systems.

Features
_ Operating voltage
_ 2.4V~5V for the HT12A
_ 2.4V~12V for the HT12E
_ Low power and high noise immunity CMOS
technology
_ Low standby current: 0.1_A (typ.) at VDD=5V
_ HT12A with a 38kHz carrier for infrared transmission
medium
_ Minimum transmission word
_ Four words for the HT12E
_ One word for the HT12A
_ Built-in oscillator needs only 5% resistor
_ Data code has positive polarity
_ Minimal external components
_ Pair with Holtek_s 212 series of decoders
_ 18-pin DIP, 20-pin SOP package
Applications
_ Burglar alarm system
_ Smoke and fire alarm system

_ Garage door controllers


_ Car door controllers
_ Car alarm system
_ Security system
_ Cordless telephones
_ Other remote control systems

CorelDRAW 11.lnk

Pin no 1 to pin no 8 is for the address line . If we use one encoder and one
decoder ic then we give a same address in encoder and decoder ic. In this
project we connect all the address pin to join together and connect to the
ground pin. So we provide a 00 address to all the pin of the address pin. So
we provide a same data to the decoder ic by connecting all the address pin to
the same ground voltage Pin no 9 is Vss pin , so we provide a negative

voltage to the Vss pin. Pin no 10 to pin no 13 is for the data line. In this
project we connect a changeable

data base logic to these point. By

connecting a DIP switch to these pins. Dip switch is for the external data
base. By changing the slide switch we change the data base..
Pin no 15 and 16 is for the oscillator pin. On this pin we connect one resistor
to these pin. On these pin we connect 1 M ohm resistor. Pin no 17 is for
digital output pin. When we press the pin no 14 then data available on the
pin no 10-13 is transmit from the pin no 17 in serial mode. On this pin we
connect a rf module. Rf module transfer the data in air. There are two type
of rf module available in the market. ASK AND FSK . Here in theses project
we use ASK rf module. FSK is better then ASK module, but fsk is not
easily available. Pi no 18 is for the positive voltage , on this pin we provide
a positive supply .

Data from the rf transmitter

is receive by the

rf receiver module .

Modulation frequency of the transmitter and receiver is same 433 Mhtz. So


every time when receive the data then rf modulrt receive the data and
transfer this data serially into decoder ic. Decoder ic receive the data serially
and decoder deliver a data parallel.

The TWS-434 and RWS-434 are extremely small, and are excellent
for applications requiring short-range RF remote controls. The
transmitter module is only 1/3 the size of a standard postage stamp,
and can easily be placed inside a small plastic enclosure.
TWS-434: The transmitter output is up to 8mW at 433.92MHz with a
range of approximately 400 foot (open area) outdoors. Indoors, the
range is approximately 200 foot, and will go through most walls.....

TWS-434A

The TWS-434 transmitter accepts both linear and digital inputs, can
operate from 1.5 to 12 Volts-DC, and makes building a miniature
hand-held RF transmitter very easy. The TWS-434 is approximately
the size of a standard postage stamp.

TWS-434 Pin Diagram

Sample Transmitter Application Circuit

RWS-434: The receiver also operates at 433.92MHz, and has a


sensitivity of 3uV. The RWS-434 receiver operates from 4.5 to 5.5
volts-DC, and has both linear and digital outputs.

Click on picture for larger image

RWS-434 Receiver

RWS-434 Pin Diagram

Sample Receiver Application Circuit

The example above shows the receiver section using the HT-12D decoder IC
for a 4-bit RF remote control system. The transmitter and receiver can also use
the Holtek 8-bit HT-640/HT-648L remote control encoder/decoder combination for
an 8-bit RF remote control system. Here are the schematics for an 8-bit RF
remote control system:

Transmitter is connected to the pin no 11 of the ic. This pin is for the serial
data transfer. Transmitter is connected with this pin with one transistor
circuit. Receiver is also connected with the pin no 10 which is rx pin of the
serial buffer through one npn transistor circuit.
Components used in the receiver circuit.
89s51 controller.
40 pin base
lcd 2 by 16 with base
crystal 12 mhz
step down transformer 9-0-9 ac
diode in 4007 (2)
regulator 7805 (1)
transmitter 433 Mhz
RF MODELULE IS CONNECTED WITH THE MICROCONTROLLER
VIA DECODER IC HT 12 D.

LCD : in this project we use 2 by 16 lcd . On This lcd we show all the
detail, for day, time, clock and all the data base system. Here we use 2 by 16
lcd. Here 2 means 2 lines and 16 means 16 character. In this lcd there is total
8 pins for the data input/ output and 3 pin for control the command mode
and data mode. In the command mode we send the command and in the data
mode we send the data. These three pin s are RS, RW, enable.
Supply voltage of the lcd is 5 volt dc.

5 VOLT REGULATED POWER SUPPLY


CIRCUIT.
In this project firstly we use one step down transformer. Step down
transformer step down the voltage from 220 volt Ac to 12 volt Ac. This Ac
voltage is further converted into DC with the help of rectifier circuit. In
rectifier circuit we use four diode. All the diodes are arranges as a bridge
rectifier circuit. Output of this rectifier is pulsating Dc. To convert this
pulsating DC into smooth dc we use one capacitor as a filter components.
Capacitor converts the pulsating Dc into smooth DC with the help of its
charging and discharging effect.
Output of the rectifier is now regulated with the help of IC regulator circuit.
In this project we use positive voltage regulator circuit. Here we use three
pin regulator. Output of this regulator is regulated voltage. If we use 7805
regulator then its means its is 5 volt regulator and if we use 7808 regulator
then its means that it is 8 volt regulator circuit.

PIN CONNECTION OF CONTROLLER WITH INPUT AND OUTPUT


DEVICES.

In this project we use 89s51 controller to control all the input and output of
the project. This controller is 40 pin ic. Pin no 40 of the ic is connected to
the positive supply. Pin no 20 of the controller is connected to the negative
supply. Pin no 18 and 19 of the ic is connected to the external crystal
oscillator circuit. With the help of this crystal we control the speed of the
microcontroller. Two 27 pf ceramic capacitor is grounded from the crystal
to reduce the ripples IN the oscillator frequency. Pin 9 is reset pin. On this
pin we connect one capacitor and resistor to provide a auto reset option.
With the help of this option it is possible to provide a auto reset logic to
the controller. When power is on then capacitor charge to the peak value
and reset automatically with the help of 10 k ohm resistor and provide a
auto reset option to the circuit.

Data from card is transmit in the air by the Radio frequency Module. This
data is receive by the radio frequency receiver and this data is demodulate by

The Rf receiver and converted into serial. This serial data is further decoded
by the H 12 D decoder. Output of the HT 12 D decoder is further connected
to the microcontroller for data base comparison
and from decoder is connected to the port p1 , which is pin no 1,2,3,4 and
12 , Pin no 12 is special pin for check the ack data signal.. Pin no 17 of the
H 12 d decoder is connected to this pin. Along with the data we check the
ACK signal also.
Pin 31 is also connected to the positive line with pin no 40. Pin no 31

is

excess enable pin. If we provide a positive voltage on this pin then

it

means that we use the internal memory of the ic. If we use external memory
then we connect a pin no 31 to the negative line. This memory means ROM
memory , not ram memory

Pin no 16 and 17 of the ic is connected to the external ram memory. Here we


use 24c02 memory to store the ram data. On this memory we store the detail
of the all the card. This ic is a 8 pin ic. Pin no 8 of the ic is connected to the
positive supply. Pin no 1,2,3,4 and 7 is also connected to the ground pin. Pin
no 5 and 6 is connected to the microcontroller.

+V
1
2
3
2
4c0
2
6
4
5
7
8

16
17
10

L.E.D
470

For the real time clock we use 8563 ic. 8563 is a 8 pin ic. Pin no 8 connected
to the positive supply. Pin no 4 is connected to the ground pin. Pin no 1 and
2 is connected to the external crystal to provide a constant frequency for
long time. External battery from battery backup is connected to the pin no8
To provide a battery backup for long time.

5v
In4148
10k

3.6v

13
14

32 khz

7
8563
2
6
5
3
4

General description
The PCF8563 is a CMOS real time clock/calendar optimized for low
power consumption. A programmable clock output, interrupt output
and voltage-low detector are also provided. All address and data are
transferred serially via a two-line bidirectional I2C-bus. Maximum bus
speed is 400 kbit/s. The built-in word address register is incremented
automatically after each written or read data byte.
2.Features
Provides year, month, day, weekday, hours, minutes and seconds
based on 32.768 kHz quartz crystal
Century flag
Clock operating voltage: 1.8 V to 5.5 V

Low backup current; typical 0.25 A at VDD =and Tamb = 25 C


400 kHz two-wire I2C-bus interface (at VDD =
Programmable clock output for peripheral devices (32.768 kHz, 1
024 Hz, 32 Hz and 1 Hz)
Alarm and timer functions
Integrated oscillator capacitor
Internal power-on reset
I2C-bus slave address: read A3h and write A2h
Open-drain interrupt pin
ElectroStatic Discharge (ESD) protection exceeds 2 000 V Human
Body Model (HBM) per JESD22-A114, 200 V Machine Model (MM)
per JESD22-A115 and 2 000 V Charged Device Model (CDM) per
JESD22-C101
Latch-up testing is done to JEDEC standard JESD78 which
exceeds 100 mA
3.Applications
Mobile telephones
Portable instruments

Electronic metering
Battery powered products

OSCI

oscillator input

OSCO

oscillator output

n.c

not connected

INT

interrupt output (open-drain; active LOW)

VSS

ground

SDA

serial data input and output

SCL

serial clock input

CLKOUT

clock output, open-drain

VDD

positive supply voltage

n.c

10

not connected

Components used in this project.


Step down transformer 220 volt ac to 9 volt ac.
Diode in 4007 (2)
Capacitor 1000mfd (2)
7805 regulator to provide 5 volt regulated power supply.
10 mfd capacitor for reset.
Moc 3011 slotted optocoupler.
( 5 pc)
crystal 12 mhz. for microcontroller clock.
Crystal 32 k hz for rtc
Ic 8563 RTC.
Ic 24co2 memory ic.
Lcd 2 by 16 digit
Microcontroller 89s51.
Cmos battery for 3.6 volt with 8563 ic.
1o k ohm pull up resistor 5 pc.
10 k pull resisitor array with port p0 to provide a external pull up resistor.
4.7 k ohm preset to control the constrast of lcd
4 switch for different inputs provided to the different operation of the smart card.

Program code of this project.


LCD_DATA
equ
P0
cd_rs
bit
P2.7
lcd_rw
bit
P2.6
lcd_en
bit
P2.5
bit
30h
31h
32h
33h
34h
35h
36h
37h

axs_in_minutes equ
axs_in_hours
equ
axs_out_minutes equ
axs_out_hours equ
seconds
equ
minutes
equ
hours
equ
days
equ
weekdays
equ
months
equ
39h
years
equ
3ah
RTC_ADD
RTC_ADD_DATA
axs_flag
axs_flag1
equ
chanj
axs_data
key0
key1
key2
key3
output
WRITE_C
READ_C
ACK_READ

flahlh.7

38h
equ
equ
equ

3bh
3ch
3dh

3eh
equ
p1
bit
bit
bit
bit

equ

bit

3fh
p2.3
p2.2
p2.0
p2.1
p3.0

EQU
EQU
EQU

0a2h
0a3h
8ah

First of all when we switch on the project then it takes few second to display
the time day and other detail on the lcd, once its appear on the lcd then we
insert the card in slotted opto coupler. When we enter a card then first of all
card is compare with the data base.
org 0000h
ljmp main
lcall CLR_LCD
mov dptr,#MSG5
lcall LINE_1
mov a,axs_data
In the logic we get a data from the card sytem to accumulator. Axs data is a
variable where the data is to be stored
cpl

anl

a,#0fh

cjne a,#1d,axs_data_nxt0

if the data base is compare then we open the door and store this card data in
external memory with real time interface.

clr

output

jb

flag32,axs_add0_nxt0

setb flag32
mov 1ah,minutes
mov 1bh,#4d
LCALL write
mov 1ah,hours
mov 1bh,#5d
LCALL write
ljmp axs_data_nxt12
axs_add0_nxt0:
jb

flag44,axs_add1_nxt0

setb flag44
mov 1ah,minutes
mov 1bh,#6d
LCALL write
mov 1ah,hours

mov 1bh,#7d
LCALL write
axs_add1_nxt0:
ljmp axs_data_nxt12
axs_data_nxt0:
cjne a,#2d,axs_data_nxt1
clr output
jb

flag33,axs_add0_nxt1

setb flag33
mov 1ah,minutes
mov 1bh,#8d
LCALL write
mov 1ah,hours
mov 1bh,#9d
LCALL write
ljmp axs_data_nxt12
axs_add0_nxt1:
jb

flag45,axs_add1_nxt1

setb flag45
mov 1ah,minutes

mov 1bh,#10d
LCALL write
mov 1ah,hours
mov 1bh,#11d
LCALL write
axs_add1_nxt1:
ljmp axs_data_nxt12
axs_data_nxt1:
cjne a,#3d,axs_data_nxt2
clr

output
jb

flag34,axs_add0_nxt2

setb flag34
mov 1ah,minutes
mov 1bh,#12d
LCALL write
mov 1ah,hours
mov 1bh,#13d
LCALL write
ljmp axs_data_nxt12
axs_add0_nxt2:

jb

flag46,axs_add1_nxt2

setb flag46
mov 1ah,minutes
mov 1bh,#14d
LCALL write
mov 1ah,hours
mov 1bh,#15d
LCALL write
axs_add1_nxt2:
ljmp axs_data_nxt12
axs_data_nxt2:
cjne a,#4d,axs_data_nxt3
clr

output
jb

flag35,axs_add0_nxt3

setb flag35
mov 1ah,minutes
mov 1bh,#16d
LCALL write
mov 1ah,hours
mov 1bh,#17d

LCALL write
ljmp axs_data_nxt12
axs_add0_nxt3:
jb

flag47,axs_add1_nxt3

setb flag47
mov 1ah,minutes
mov 1bh,#18d
LCALL write
mov 1ah,hours
mov 1bh,#19d
LCALL write
axs_add1_nxt3:
ljmp axs_data_nxt12
axs_data_nxt3:
cjne a,#5d,axs_data_nxt4
clr

output
jb

flag36,axs_add0_nxt4

setb flag36
mov 1ah,minutes
mov 1bh,#20d

LCALL write
mov 1ah,hours
mov 1bh,#21d
LCALL write
ljmp axs_data_nxt12
axs_add0_nxt4:
jb

flag48,axs_add1_nxt4

setb flag48
mov 1ah,minutes
mov 1bh,#22d
LCALL write
mov 1ah,hours
mov 1bh,#23d
LCALL write
axs_add1_nxt4:
ljmp axs_data_nxt12
axs_data_nxt4:
cjne a,#6d,axs_data_nxt5
clr

output
jb

flag37,axs_add0_nxt5

setb flag37
mov 1ah,minutes
mov 1bh,#24d
LCALL write
mov 1ah,hours
mov 1bh,#25d
LCALL write
ljmp axs_data_nxt12
axs_add0_nxt5:
jb

flag49,axs_add1_nxt5

setb flag49
mov 1ah,minutes
mov 1bh,#26d
LCALL write
mov 1ah,hours
mov 1bh,#27d
LCALL write
axs_add1_nxt5:
ljmp axs_data_nxt12
axs_data_nxt5:

cjne a,#7d,axs_data_nxt6
clr

output
jb

flag38,axs_add0_nxt6

setb flag38
mov 1ah,minutes
mov 1bh,#28d
LCALL write
mov 1ah,hours
mov 1bh,#29d
LCALL write
ljmp axs_data_nxt12
axs_add0_nxt6:
jb

flag50,axs_add1_nxt6

setb flag50
mov 1ah,minutes
mov 1bh,#30d
LCALL write
mov 1ah,hours
mov 1bh,#31d
LCALL write

axs_add1_nxt6:
ljmp axs_data_nxt12
axs_data_nxt6:
cjne a,#8d,axs_data_nxt7
clr

output
jb

flag39,axs_add0_nxt7

setb flag39
mov 1ah,minutes
mov 1bh,#32d
LCALL write
mov 1ah,hours
mov 1bh,#33d
LCALL write
ljmp axs_data_nxt12
axs_add0_nxt7:
jb

flag51,axs_add1_nxt7

setb flag51
mov 1ah,minutes
mov 1bh,#34d
LCALL write

mov 1ah,hours
mov 1bh,#35d
LCALL write
axs_add1_nxt7:
ljmp axs_data_nxt12
axs_data_nxt7:
cjne a,#9d,axs_data_nxt8
clr

output
jb

flag40,axs_add0_nxt8

setb flag40
mov 1ah,minutes
mov 1bh,#36d
LCALL write
mov 1ah,hours
mov 1bh,#37d
LCALL write
ljmp axs_data_nxt12
axs_add0_nxt8:
jb
setb flag52

flag52,axs_add1_nxt8

mov 1ah,minutes
mov 1bh,#38d
LCALL write
mov 1ah,hours
mov 1bh,#39d
LCALL write
axs_add1_nxt8:
ljmp axs_data_nxt12
axs_data_nxt8:
cjne a,#10d,axs_data_nxt9
clr

output
jb

flag41,axs_add0_nxt9

setb flag41
mov 1ah,minutes
mov 1bh,#40d
LCALL write
mov 1ah,hours
mov 1bh,#41d
LCALL write
ljmp axs_data_nxt12

axs_add0_nxt9:
jb

flag53,axs_add1_nxt9

setb flag53
mov 1ah,minutes
mov 1bh,#42d
LCALL write
mov 1ah,hours
mov 1bh,#43d
LCALL write
axs_add1_nxt9:
ljmp axs_data_nxt12
axs_data_nxt9:
cjne a,#11d,axs_data_nxt10
clr

output
jb

flag42,axs_add0_nxt10

setb flag42
mov 1ah,minutes
mov 1bh,#44d
LCALL write
mov 1ah,hours

mov 1bh,#45d
LCALL write
ljmp axs_data_nxt12
axs_add0_nxt10:
jb

flag54,axs_add1_nxt10

setb flag54
mov 1ah,minutes
mov 1bh,#46d
LCALL write
mov 1ah,hours
mov 1bh,#47d
LCALL write
axs_add1_nxt10:
ljmp axs_data_nxt12
axs_data_nxt10:
cjne a,#12d,axs_data_nxt11
clr

output
jb

flag43,axs_add0_nxt11

setb flag43
mov 1ah,minutes

mov 1bh,#48d
LCALL write
mov 1ah,hours
mov 1bh,#49d
LCALL write
ljmp axs_data_nxt12
axs_add0_nxt11:
jb

flag55,axs_add1_nxt11

setb flag55
mov 1ah,minutes
mov 1bh,#50d
LCALL write
mov 1ah,hours
mov 1bh,#51d
LCALL write
axs_add1_nxt11:
ljmp axs_data_nxt12
axs_data_nxt11:
lcall DELAY11
lcall CLR_LCD

mov dptr,#MSG6
lcall LINE_1
axs_data_nxt12:
mov 1ah,24h
mov 1bh,#1d
LCALL write
mov 1ah,25h
mov 1bh,#2d
LCALL write
mov 1ah,26h
mov 1bh,#3d
LCALL write
lcall DELAY11
lcall DELAY11
lcall DELAY11
lcall DELAY11
lcall DELAY11
setb output
lcall CLR_LCD
mov ie,#85h

mov tcon,#01h
pop acc
pop psw
reti
sir_int1:
push psw
push acc
setb flag0
pop acc
pop psw
reti

main:
lcall DELAY11
mov psw,#00h
mov sp,#070h
mov tmod,#00h
mov tcon,#01h
mov scon,#00h
mov ie,#85h
mov ip,#00h
mov tl1,#00h
mov th1,#00h
mov p0,#0ffh
mov p1,#0ffh
mov p2,#0ffh
mov p3,#0ffh
setb output
mov

20h,#00h

mov

21h,#01h

mov

22h,#03h

mov

23h,#00h

mov

24h,#00h

mov

25h,#00h

mov

26h,#00h

mov

axs_flag,#00h

mov

axs_flag1,#00h

mov

axs_in_minutes,#00h

mov

axs_in_hours,#00h

mov

axs_out_minutes,#00h

mov

axs_out_hours,#00h
mov seconds,#00h

mov minutes,#00h
mov hours,#00h
mov days,#00h
mov weekdays,#00h
mov months,#00h
mov years,#00h
clr lcd_rs
clr lcd_rw
clr lcd_en

MOV RTC_ADD,#0DH
MOV RTC_ADD_DATA,#83h
MOV RTC_ADD,#02H
lcall READBYTE
MOV seconds,RTC_ADD_DATA
MOV RTC_ADD,#03H
lcall READBYTE
MOV minutes,RTC_ADD_DATA
MOV RTC_ADD,#04H
lcall READBYTE
MOV a,RTC_ADD_DATA
ANL a,#3fh
MOV hours,a
MOV RTC_ADD,#05H
lcall READBYTE
MOV a,RTC_ADD_DATA
ANL a,#3fh
MOV days,a
MOV RTC_ADD,#06H
lcall READBYTE

MOV a,RTC_ADD_DATA
ANL a,#07h
MOV weekdays,a
MOV RTC_ADD,#07H
lcall READBYTE
MOV a,RTC_ADD_DATA
ANL a,#1fh
MOV months,a
MOV RTC_ADD,#08H
lcall READBYTE
MOV years,RTC_ADD_DATA
lcall WRITBYTE
lcall data_cheke
lcall INIT_LCD
lcall CLR_LCD
mov dptr,#MSG0
lcall LINE_1
mov dptr,#MSG1
lcall LINE_2
lcall DELAY11

lcall CLR_LCD
setb flag0
WAIT:
lcall keyboard
lcall display
jnb

flag0,WAIT

clr

flag0

MOV RTC_ADD,#02H
lcall READBYTE
MOV a,RTC_ADD_DATA
MOV seconds,a
jnz

back

MOV RTC_ADD,#03H
lcall READBYTE
MOV a,RTC_ADD_DATA
MOV minutes,a
jnz

back

MOV RTC_ADD,#04H
lcall READBYTE
MOV a,RTC_ADD_DATA

ANL a,#3fh
MOV hours,a
jnz

back

MOV RTC_ADD,#05H
lcall READBYTE
MOV a,RTC_ADD_DATA
ANL a,#3fh
MOV days,a
MOV RTC_ADD,#06H
lcall READBYTE
MOV a,RTC_ADD_DATA
ANL a,#07h
MOV weekdays,a
MOV RTC_ADD,#07H
lcall READBYTE
MOV a,RTC_ADD_DATA
ANL a,#1fh
MOV months,a
MOV RTC_ADD,#08H
lcall READBYTE

MOV years,RTC_ADD_DATA
lcall data_chanj
back:

ljmp WAIT

display:
jnb

flag26,goto_nxt

setb flag16
ret
goto_nxt:
mov dptr,#MSG2
mov LCD_DATA,#080h
lcall COMMAND_BYTE
mov a,hours
swap a
anl a,#0fh
add a,#30h
mov LCD_DATA,a
jnb

flag12,lpl_yh

mov LCD_DATA,#20h
lpl_yh:

lcall DATA_BYTE

mov LCD_DATA,#081h

lcall COMMAND_BYTE
mov a,hours
anl a,#0fh
add a,#30h
mov LCD_DATA,a
jnb

flag12,lph_yh

mov LCD_DATA,#20h
lph_yh:

lcall DATA_BYTE

mov LCD_DATA,#082h
lcall COMMAND_BYTE
mov a,#':'
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#083h
lcall COMMAND_BYTE
mov a,minutes
swap a
anl a,#0fh
add a,#30h
mov LCD_DATA,a

jnb

flag13,lpl_tl

mov LCD_DATA,#20h
lpl_tl:

lcall DATA_BYTE
mov LCD_DATA,#084h
lcall COMMAND_BYTE
mov a,minutes
anl a,#0fh
add a,#30h
mov LCD_DATA,a
jnb

flag13,lph_tl

mov LCD_DATA,#20h
lph_tl:

lcall DATA_BYTE

mov LCD_DATA,#085h
lcall COMMAND_BYTE
mov a,#':'
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#086h
lcall COMMAND_BYTE
mov a,seconds

swap a
anl a,#0fh
add a,#30h
mov LCD_DATA,a
jnb

flag14,lpl_th

mov LCD_DATA,#20h
lpl_th:

lcall DATA_BYTE

mov LCD_DATA,#087h
lcall COMMAND_BYTE
mov a,seconds
anl a,#0fh
add a,#30h
mov LCD_DATA,a
jnb

flag14,lph_th

mov LCD_DATA,#20h
lph_th:

lcall DATA_BYTE

mov LCD_DATA,#0c3h
lcall COMMAND_BYTE
mov a,days
swap a

anl a,#0fh
add a,#30h
mov LCD_DATA,a
jnb

flag9,lpl_dl

mov LCD_DATA,#20h
lpl_dl:

lcall DATA_BYTE

mov LCD_DATA,#0c4h
lcall COMMAND_BYTE
mov a,days
anl a,#0fh
add a,#30h
mov LCD_DATA,a
jnb

flag9,lph_dl

mov LCD_DATA,#20h
lph_dl: lcall DATA_BYTE
mov LCD_DATA,#0c5h
lcall COMMAND_BYTE
mov a,#'/'
mov LCD_DATA,a
lcall DATA_BYTE

mov LCD_DATA,#0c6h
lcall COMMAND_BYTE
mov a,months
swap a
anl a,#0fh
add a,#30h
mov LCD_DATA,a
jnb

flag10,lpl_dh

mov LCD_DATA,#20h
lpl_dh:

lcall DATA_BYTE

mov LCD_DATA,#0c7h
lcall COMMAND_BYTE
mov a,months
anl a,#0fh
add a,#30h
mov LCD_DATA,a
jnb

flag10,lph_dh

mov LCD_DATA,#20h
lph_dh:

lcall DATA_BYTE

mov LCD_DATA,#0c8h

lcall COMMAND_BYTE
mov a,#'/'
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#0c9h
lcall COMMAND_BYTE
mov a,#'2'
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#0cah
lcall COMMAND_BYTE
mov a,#'0'
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#0cbh
lcall COMMAND_BYTE
mov a,years
swap a
anl a,#0fh
add a,#30h

mov LCD_DATA,a
jnb

flag11,lpl_yl

mov LCD_DATA,#20h
lpl_yl:

lcall DATA_BYTE

mov LCD_DATA,#0cch
lcall COMMAND_BYTE
mov a,years
anl a,#0fh
add a,#30h
mov LCD_DATA,a
jnb

flag11,lph_yl

mov LCD_DATA,#20h
lph_yl:

lcall DATA_BYTE

mov LCD_DATA,#08dh
lcall COMMAND_BYTE
mov b,weekdays
mov a,#3d
mul

ab

add

a,#0d

MOVC A,@A+DPTR

mov LCD_DATA,a
jnb

flag15,lp1_w

mov LCD_DATA,#20h
lp1_w:

lcall DATA_BYTE

mov LCD_DATA,#08eh
lcall COMMAND_BYTE
mov b,weekdays
mov a,#3d
mul

ab

add

a,#1d

MOVC A,@A+DPTR
mov LCD_DATA,a
jnb

flag15,lp2_w

mov LCD_DATA,#20h
lp2_w:

lcall DATA_BYTE

mov LCD_DATA,#08fh
lcall COMMAND_BYTE
mov b,weekdays
mov a,#3d
mul

ab

add

a,#2d

MOVC A,@A+DPTR
mov LCD_DATA,a
jnb

flag15,lp3_w

mov LCD_DATA,#20h
lp3_w:

lcall DATA_BYTE
setb flag16
ret

display1:
mov LCD_DATA,#0c3h
lcall COMMAND_BYTE
mov a,axs_flag1
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#084h
lcall COMMAND_BYTE
mov a,axs_flag
swap a
anl a,#0fh
add a,#30h

mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#085h
lcall COMMAND_BYTE
mov a,axs_flag
anl a,#0fh
add a,#30h
mov LCD_DATA,a
lcall DATA_BYTE
ret
display2:
mov LCD_DATA,#08bh
lcall COMMAND_BYTE
mov a,axs_in_hours
swap a
anl a,#0fh
add a,#30h
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#08ch

lcall COMMAND_BYTE
mov a,axs_in_hours
anl a,#0fh
add a,#30h
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#08eh
lcall COMMAND_BYTE
mov a,axs_in_minutes
swap a
anl a,#0fh
add a,#30h
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#08fh
lcall COMMAND_BYTE
mov a,axs_in_minutes
anl a,#0fh
add a,#30h
mov LCD_DATA,a

lcall DATA_BYTE
mov LCD_DATA,#0cbh
lcall COMMAND_BYTE
mov a,axs_out_hours
swap a
anl a,#0fh
add a,#30h
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#0cch
lcall COMMAND_BYTE
mov a,axs_out_hours
anl a,#0fh
add a,#30h
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#0ceh
lcall COMMAND_BYTE
mov a,axs_out_minutes
swap a

anl a,#0fh
add a,#30h
mov LCD_DATA,a
lcall DATA_BYTE
mov LCD_DATA,#0cfh
lcall COMMAND_BYTE
mov a,axs_out_minutes
anl a,#0fh
add a,#30h
mov LCD_DATA,a
lcall DATA_BYTE
ret
keyboard:
jb

flag16,g_key

ret
g_key:
jnb

key0,g_nxt0

ljmp nxt0
g_nxt0:
jnb

key0,g_nxt0

lcall delay
jnb

key0,g_nxt0

jnb

flag8,g_key

clr

flag16

jnb

flag17,nxt0_lp0

clr

flag17

setb flag18
setb flag26
mov ie,#00h
mov dptr,#MSG3
lcall LINE_1
mov dptr,#MSG4
lcall LINE_2
mov

axs_flag,#01h
mov c,flag32

mov

axs_flag1,#'P'
jc

mov

axs_nxt0

axs_flag1,#'A'

axs_nxt0:
lcall display1

mov 1bh,#4d
lcall read
mov axs_in_minutes,19h
mov 1bh,#5d
lcall read
mov axs_in_hours,19h
mov 1bh,#6d
lcall read
mov axs_out_minutes,19h
mov 1bh,#7d
lcall read
mov axs_out_hours,19h
lcall display2
ljmp nxt0
nxt0_lp0:
jnb

flag18,nxt0_lp1

clr

flag18

setb flag19
setb flag26
mov ie,#00h

mov

axs_flag,#02h
mov c,flag33

mov

axs_flag1,#'P'
jc

mov

axs_nxt1

axs_flag1,#'A'

axs_nxt1:
lcall display1
mov 1bh,#8d
lcall read
mov axs_in_minutes,19h
mov 1bh,#9d
lcall read
mov axs_in_hours,19h
mov 1bh,#10d
lcall read
mov axs_out_minutes,19h
mov 1bh,#11d
lcall read
mov axs_out_hours,19h
lcall display2

ljmp nxt0
nxt0_lp1:
jnb

flag19,nxt0_lp2

clr

flag19

setb flag20
setb flag26
mov ie,#00h
mov

axs_flag,#03h
mov c,flag34

mov

axs_flag1,#'P'
jc

mov

axs_nxt2

axs_flag1,#'A'

axs_nxt2:
lcall display1
mov 1bh,#12d
lcall read
mov axs_in_minutes,19h
mov 1bh,#13d
lcall read
mov axs_in_hours,19h

mov 1bh,#14d
lcall read
mov axs_out_minutes,19h
mov 1bh,#15d
lcall read
mov axs_out_hours,19h
lcall display2
ljmp nxt0
nxt0_lp2:
jnb

flag20,nxt0_lp3

clr

flag20

setb flag21
setb flag26
mov ie,#00h
mov

axs_flag,#04h
mov c,flag35

mov

axs_flag1,#'P'
jc

mov
axs_nxt3:

axs_flag1,#'A'

axs_nxt3

lcall display1
mov 1bh,#16d
lcall read
mov axs_in_minutes,19h
mov 1bh,#17d
lcall read
mov axs_in_hours,19h
mov 1bh,#18d
lcall read
mov axs_out_minutes,19h
mov 1bh,#19d
lcall read
mov axs_out_hours,19h
lcall display2
ljmp nxt0
nxt0_lp3:
jnb

flag21,nxt0_lp4

clr

flag21

setb flag22
setb flag26

mov ie,#00h
mov

axs_flag,#05h
mov c,flag36

mov

axs_flag1,#'P'
jc

mov

axs_nxt4

axs_flag1,#'A'

axs_nxt4:
lcall display1
mov 1bh,#20d
lcall read
mov axs_in_minutes,19h
mov 1bh,#21d
lcall read
mov axs_in_hours,19h
mov 1bh,#22d
lcall read
mov axs_out_minutes,19h
mov 1bh,#23d
lcall read
mov axs_out_hours,19h

lcall display2
ljmp nxt0
nxt0_lp4:
jnb

flag22,nxt0_lp5

clr

flag22

setb flag23
setb flag26
mov ie,#00h
mov

axs_flag,#06h
mov c,flag37

mov

axs_flag1,#'P'
jc

mov

axs_nxt5

axs_flag1,#'A'

axs_nxt5:
lcall display1
mov 1bh,#24d
lcall read
mov axs_in_minutes,19h
mov 1bh,#25d
lcall read

mov axs_in_hours,19h
mov 1bh,#26d
lcall read
mov axs_out_minutes,19h
mov 1bh,#27d
lcall read
mov axs_out_hours,19h
lcall display2
ljmp nxt0
nxt0_lp5:
jnb

flag23,nxt0_lp6

clr

flag23

setb flag24
setb flag26
mov ie,#00h
mov

axs_flag,#07h
mov c,flag38

mov

axs_flag1,#'P'
jc

mov

axs_flag1,#'A'

axs_nxt6

axs_nxt6:
lcall display1
mov 1bh,#28d
lcall read
mov axs_in_minutes,19h
mov 1bh,#29d
lcall read
mov axs_in_hours,19h
mov 1bh,#30d
lcall read
mov axs_out_minutes,19h
mov 1bh,#31d
lcall read
mov axs_out_hours,19h
lcall display2
ljmp nxt0
nxt0_lp6:
jnb

flag24,nxt0_lp7

clr

flag24

setb flag25

setb flag26
mov ie,#00h
mov

axs_flag,#08h
mov c,flag39

mov

axs_flag1,#'P'
jc

mov

axs_nxt7

axs_flag1,#'A'

axs_nxt7:
lcall display1
mov 1bh,#32d
lcall read
mov axs_in_minutes,19h
mov 1bh,#33d
lcall read
mov axs_in_hours,19h
mov 1bh,#34d
lcall read
mov axs_out_minutes,19h
mov 1bh,#35d
lcall read

mov axs_out_hours,19h
lcall display2
ljmp nxt0
nxt0_lp7:
jnb

flag25,nxt0_lp8

clr

flag25

setb flag27
setb flag26
mov ie,#00h
mov

axs_flag,#09h
mov c,flag40

mov

axs_flag1,#'P'
jc

mov

axs_nxt8

axs_flag1,#'A'

axs_nxt8:
lcall display1
mov 1bh,#36d
lcall read
mov axs_in_minutes,19h
mov 1bh,#37d

lcall read
mov axs_in_hours,19h
mov 1bh,#38d
lcall read
mov axs_out_minutes,19h
mov 1bh,#39d
lcall read
mov axs_out_hours,19h
lcall display2
ljmp nxt0
nxt0_lp8:
jnb

flag27,nxt0_lp9

clr

flag27

setb flag28
setb flag26
mov ie,#00h
mov

axs_flag,#10h
mov c,flag41

mov

axs_flag1,#'P'
jc

axs_nxt9

mov

axs_flag1,#'A'

axs_nxt9:
lcall display1
mov 1bh,#40d
lcall read
mov axs_in_minutes,19h
mov 1bh,#41d
lcall read
mov axs_in_hours,19h
mov 1bh,#42d
lcall read
mov axs_out_minutes,19h
mov 1bh,#43d
lcall read
mov axs_out_hours,19h
lcall display2
ljmp nxt0
nxt0_lp9:
jnb

flag28,nxt0_lp10

clr

flag28

setb flag29
setb flag26
mov ie,#00h
mov

axs_flag,#11h
mov c,flag42

mov

axs_flag1,#'P'
jc

mov

axs_nxt10

axs_flag1,#'A'

axs_nxt10:
lcall display1
mov 1bh,#44d
lcall read
mov axs_in_minutes,19h
mov 1bh,#45d
lcall read
mov axs_in_hours,19h
mov 1bh,#46d
lcall read
mov axs_out_minutes,19h
mov 1bh,#47d

lcall read
mov axs_out_hours,19h
lcall display2
ljmp nxt0
nxt0_lp10:
jnb

flag29,nxt0_lp11

clr

flag29

setb flag30
setb flag26
mov ie,#00h
mov

axs_flag,#12h
mov c,flag43

mov

axs_flag1,#'P'
jc

mov

axs_nxt11

axs_flag1,#'A'

axs_nxt11:
lcall display1
mov 1bh,#48d
lcall read
mov axs_in_minutes,19h

mov 1bh,#49d
lcall read
mov axs_in_hours,19h
mov 1bh,#50d
lcall read
mov axs_out_minutes,19h
mov 1bh,#51d
lcall read
mov axs_out_hours,19h
lcall display2
ljmp nxt0
nxt0_lp11:
jnb

flag30,nxt0_lp13

clr

flag30

setb flag17
clr

flag26

mov ie,#85h
lcall CLR_LCD
ljmp nxt0
nxt0_lp13:

nxt0:
jnb

flag26,nxt0_goto_nxt

ret
nxt0_goto_nxt:
jnb

key1,g_nxt1

ljmp nxt1
g_nxt1:
jnb

key1,g_nxt1

lcall delay
jnb

key1,g_nxt1

clr

flag16

jnb

flag1,nxt1_lp0

clr

flag1

setb flag2
setb flag9
setb flag10
setb flag11
setb flag12
clr

flag13

setb flag14

setb flag15
mov ie,#00h
ljmp nxt1
nxt1_lp0:
jnb

flag2,nxt1_lp1

clr

flag2

setb flag3
setb flag9
setb flag10
setb flag11
clr

flag12

setb flag13
setb flag14
setb flag15
mov ie,#00h
ljmp nxt1
nxt1_lp1:
jnb

flag3,nxt1_lp2

jnb

flag26,goto_nxt1

clr

flag3

setb flag7
ljmp nxt1_lp5
goto_nxt1:
clr

flag3

setb flag4
clr

flag9
setb flag10

setb flag11
setb flag12
setb flag13
setb flag14
setb flag15
mov ie,#00h
ljmp nxt1
nxt1_lp2:
jnb

flag4,nxt1_lp3

clr

flag4

setb flag5
setb flag9
clr

flag10

setb flag11
setb flag12
setb flag13
setb flag14
setb flag15
mov ie,#00h
ljmp nxt1
nxt1_lp3:
jnb

flag5,nxt1_lp4

clr

flag5

setb flag6
setb flag9
setb flag10
clr

flag11

setb flag12
setb flag13
setb flag14
setb flag15
mov ie,#00h
ljmp nxt1

nxt1_lp4:
jnb

flag6,nxt1_lp5

clr

flag6

setb flag7
setb flag9
setb flag10
setb flag11
setb flag12
setb flag13
setb flag14
clr

flag15
mov ie,#00h
sjmp nxt1

nxt1_lp5:
jnb

flag7,nxt1_lp6

clr

flag7

setb flag8
clr

flag9
clr

clr

flag11

flag10

clr

flag12

clr

flag13

clr

flag14

clr

flag15
jnb

flag17,lp1_lp6

mov ie,#85h
MOV RTC_ADD,#02H
MOV RTC_ADD_DATA,seconds
lcall WRITBYTE
MOV RTC_ADD,#03H
MOV RTC_ADD_DATA,minutes
lcall WRITBYTE
MOV RTC_ADD,#04H
MOV RTC_ADD_DATA,hours
lcall WRITBYTE
MOV RTC_ADD,#05H
MOV RTC_ADD_DATA,days
lcall WRITBYTE
MOV RTC_ADD,#06H
MOV RTC_ADD_DATA,weekdays

lcall WRITBYTE
MOV RTC_ADD,#07H
MOV RTC_ADD_DATA,months
lcall WRITBYTE
MOV

RTC_ADD,#08H

MOV RTC_ADD_DATA,years
lcall WRITBYTE
lp1_lp6:

sjmp nxt1

nxt1_lp6:
jnb

flag8,nxt1

clr

flag8

setb flag1
setb flag9
setb flag10
setb flag11
setb flag12
setb flag13
clr

flag14

setb flag15
mov ie,#00h

nxt1:

ljmp

jnb

key2,g_nxt2

jnb

key2,g_nxt2

nxt2

g_nxt2:

lcall delay
jnb

key2,g_nxt2

clr

flag16

jnb

flag1,nxt2_lp0

mov a,seconds
add

a,#01h

da

cjne a,#60h,nxt_lps
mov a,#00h
nxt_lps:

mov seconds,a

nxt2_lp0:
jnb

flag2,nxt2_lp1

mov a,minutes
add
da

a,#01h
a

cjne a,#60h,nxt_lpm
mov a,#00h
nxt_lpm:

mov minutes,a

nxt2_lp1:
jnb

flag3,nxt2_lp2

mov a,hours
add

a,#01h

da

cjne a,#24h,nxt_lph
mov a,#00h
nxt_lph:

mov hours,a

nxt2_lp2:
jnb

flag4,nxt2_lp3

mov a,months
cjne a,#01h,mon1
mov 3bh,#32h
mon1:
cjne a,#02h,mon2
mov 3bh,#30h
mon2:

cjne a,#03h,mon3
mov 3bh,#32h
mon3:
cjne a,#04h,mon4
mov 3bh,#31h
mon4:
cjne a,#05h,mon5
mov 3bh,#32h
mon5:
cjne a,#06h,mon6
mov 3bh,#31h
mon6:
cjne a,#07h,mon7
mov 3bh,#32h
mon7:
cjne a,#08h,mon8
mov 3bh,#32h
mon8:
cjne a,#09h,mon9
mov 3bh,#31h

mon9:
cjne a,#10h,mon10
mov 3bh,#32h
mon10:
cjne a,#11h,mon11
mov 3bh,#31h
mon11:
cjne a,#12h,mon12
mov 3bh,#32h
mon12:
mov a,days
add
da

a,#01h
a

cjne a,3bh,nxt_lpd
mov a,#01h
nxt_lpd:

mov days,a

nxt2_lp3:
jnb

flag5,nxt2_lp4

mov a,months
add

a,#01h

da

cjne a,#13h,nxt_lpt
mov a,#01h
nxt_lpt:

mov months,a

nxt2_lp4:
jnb

flag6,nxt2_lp5

mov a,years
add

a,#01h

da

cjne a,#99h,nxt_lp6
mov a,#99h
nxt_lp6: mov

years,a

nxt2_lp5:
jnb

flag7,nxt2_lp6

mov a,weekdays
add

a,#01h

da

cjne a,#07h,nxt_lp7
mov a,#00h
nxt_lp7: mov

weekdays,a

nxt2_lp6:
nxt2:
jnb

key3,g_nxt3

ljmp nxt3
g_nxt3:
jnb

key3,g_nxt3

lcall delay
jnb

key3,g_nxt3

clr

flag16

jnb

flag1,nxt3_lp0

mov a,seconds
add

a,#99h

da

cjne a,#99h,nx_lps
mov a,#59h
nx_lps:

mov seconds,a

nxt3_lp0:
jnb

flag2,nxt3_lp1

mov a,minutes
add

a,#99h

da

cjne a,#99h,nx_lpm
mov a,#59h
nx_lpm:

mov minutes,a

nxt3_lp1:
jnb

flag3,nxt3_lp2

mov a,hours
add

a,#99h

da

cjne a,#99h,nx_lph
mov a,#23h
nx_lph:

mov hours,a

nxt3_lp2:
jnb

flag4,nxt3_lp3

mov a,months
cjne a,#01h,mo1
mov 3bh,#32h
mo1:
cjne a,#02h,mo2
mov 3bh,#30h

mo2:
cjne a,#03h,mo3
mov 3bh,#32h
mo3:
cjne a,#04h,mo4
mov 3bh,#31h
mo4:
cjne a,#05h,mo5
mov 3bh,#32h
mo5:
cjne a,#06h,mo6
mov 3bh,#31h
mo6:
cjne a,#07h,mo7
mov 3bh,#32h
mo7:
cjne a,#08h,mo8
mov 3bh,#32h
mo8:
cjne a,#09h,mo9

mov 3bh,#31h
mo9:
cjne a,#10h,mo10
mov 3bh,#32h
mo10:
cjne a,#11h,mo11
mov 3bh,#31h
mo11:
cjne a,#12h,mo12
mov 3bh,#32h
mo12:
mov a,days
add

a,#99h

da

cjne a,#00h,nx_lpd
mov a,3bh
add
da
nx_lpd:
nxt3_lp3:

mov days,a

a,#99h
a

jnb

flag5,nxt3_lp4

mov a,months
add

a,#99h

da

cjne a,#00h,nx_lpt
mov a,#12h
nx_lpt:

mov months,a

nxt3_lp4:
jnb

flag6,nxt3_lp5

mov a,years
add

a,#99h

da

cjne a,#99h,nx_lp6
mov a,#99h
nx_lp6: mov

years,a

nxt3_lp5:
jnb

flag7,nxt3_lp6

mov a,weekdays
add
da

a,#99h
a

cjne a,#99h,nx_lp7
mov a,#06h
nx_lp7: mov

weekdays,a

nxt3_lp6:
nxt3:
ret
data_cheke:
mov 1bh,#0d
lcall read
mov a,19h
cjne a,weekdays,data_chanj
ljmp data_load
data_chanj:
mov a,weekdays
mov 1ah,a
mov 1bh,#0d
LCALL write
mov chanj,#52d
loop1:
mov 1ah,#0d

mov 1bh,chanj
LCALL write
djnz chanj,loop1
mov 24h,#0d
mov 25h,#0d
mov 26h,#0d
ret
data_load:
mov 1bh,#1d
lcall read
mov 24h,19h
mov 1bh,#2d
lcall read
mov 25h,19h
mov 1bh,#3d
lcall read
mov 26h,19h
ret
LINE_1:
mov

LCD_DATA,#080h

lcall COMMAND_BYTE
lcall DELAY1
lcall WRITE_MSG
ret
LINE_2:
mov

LCD_DATA,#0c0h

lcall COMMAND_BYTE
lcall DELAY1
lcall WRITE_MSG
ret
INIT_LCD:
mov

LCD_DATA,#038h

lcall COMMAND_BYTE
lcall DELAY1
mov

LCD_DATA,#038h

lcall COMMAND_BYTE
lcall DELAY1
mov

LCD_DATA,#038h

lcall COMMAND_BYTE
lcall DELAY1

mov

LCD_DATA,#038h

lcall COMMAND_BYTE
lcall DELAY1
mov

LCD_DATA,#008h

lcall COMMAND_BYTE
lcall DELAY1
mov

LCD_DATA,#00ch

lcall COMMAND_BYTE
lcall DELAY1
mov

LCD_DATA,#006h

lcall COMMAND_BYTE
lcall DELAY1
ret
CLR_LCD:
mov

LCD_DATA,#001h

lcall COMMAND_BYTE
lcall DELAY1
ret
WRITE_MSG:
mov

a,#00h

movc
cjne

a,@a+dptr
a,#'$',WRITE_CONT

ret
WRITE_CONT:
mov

LCD_DATA,a

lcall DATA_BYTE
inc

dptr

ljmp WRITE_MSG
COMMAND_BYTE:
clr

lcd_rs

lcall DELAY
ljmp

CMD10

DATA_BYTE:
setb

lcd_rs

lcall DELAY
CMD10:
clr

lcd_rw

lcall DELAY
setb

lcd_en

lcall DELAY

clr

lcd_en

lcall DELAY
ret
DELAY:
mov

r0,#10d

DEL:
djnz

r0,DEL

ret
DELAY1:
mov

r0,#0d

mov

r1,#20d

DELAY10:
djnz

r0,DELAY10

djnz

r1,DELAY10

ret
DELAY41:
mov

r0,#0d

mov

r1,#15d

DLP410:
djnz

r0,DLP410

djnz

r1,DLP410

ret
DELAY11:
mov

r0,#0d

mov

r1,#0d

mov

r2,#4d

DLP11:
djnz

r0,DLP11

djnz

r1,DLP11

djnz

r2,DLP11

ret
WRITBYTE:
lCALL

RTC_START

MOV A,#WRITE_C
MOV R7,#08H
LCALL

RTC_SHFTO

LCALL

RTC_ACK

MOV A,RTC_ADD
MOV R7,#08H
LCALL

RTC_SHFTO

LCALL

RTC_ACK

MOV A,RTC_ADD_DATA
MOV R7,#08H
LCALL

RTC_SHFTO

LCALL

RTC_ACK

LCALL

STOP_BIT

LCALL

ACK_POL

RET
READBYTE:

lCALL

RTC_START

MOV A,#WRITE_C
MOV R7,#08H
lCALL

RTC_SHFTO

lCALL

RTC_ACK

MOV A,RTC_ADD
MOV R7,#08H
lCALL

RTC_SHFTO

lCALL

RTC_ACK

lCALL

RTC_START

MOV A,#READ_C
MOV R7,#08H
lCALL

RTC_SHFTO

lCALL

RTC_ACK

MOV R7,#08H
CLOCK8:

SETB p3.4
NOP
NOP
MOV C,p3.5
MOV A,R5
RLC A
MOV R5,A
CLR p3.4
NOP
NOP
NOP
NOP
DJNZ R7,CLOCK8
MOV RTC_ADD_DATA,R5
LCALL

NO_ACK

LCALL

STOP_BIT

RET
ACK_POL:
MOV R3,#40H
ACK_LOOP:
DJNZ R3,DONE_YET
SJMP DN_ACKPOL
DONE_YET:
lCALL

RTC_START

MOV A,#ACK_READ
MOV R7,#08H
lCALL

RTC_SHFTO

lCALL

RTC_ACK

JC

ACK_LOOP

DN_ACKPOL:
lCALL
RET
RTC_SHFTO:

CLR p3.4

NXTSHF:
RLC A

STOP_BIT

MOV p3.5,C
SETB p3.4
NOP
NOP
CLR p3.4
NOP
DJNZ R7,NXTSHF
RET
RTC_START:
SETB p3.4
NOP
NOP
SETB p3.5
NOP
NOP
CLR p3.5
NOP
NOP
CLR p3.4
RET

STOP_BIT:
CLR p3.5
NOP
NOP
SETB p3.4
NOP
NOP
SETB p3.5
RET
RTC_ACK:
NOP
NOP
NOP
NOP
CLR p3.4
NOP
NOP
NOP
NOP
SETB p3.5

NOP
NOP
NOP
NOP
SETB p3.4
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
MOV C,p3.5
CLR p3.4
RET
MSTR_ACK:
CLR p3.4

NOP
NOP
CLR p3.5
NOP
NOP
NOP
NOP
SETB p3.4
NOP
NOP
CLR p3.4
NOP
NOP
SETB p3.5
RET
NO_ACK:
SETB p3.5
NOP
NOP
SETB p3.4

NOP
NOP
CLR p3.4
RET
read:
mov r6, #00h
djnz r6,$
djnz r6,$
PUSH B
MOV B, A
ACALL START
JC XR1
MOV A, #00H
ORL A, #0A0H
ACALL SHOUT
JC XR1
MOV A,1bh
ACALL SHOUT
JC XR1
MOV A, B

lCALL R_CRNT
lJMP XR2
XR1:

lCALL STOP

XR2:

MOV 19h, A
POP B
RET

START:

SETB p3.7
SETB p3.6
JNB p3.7, X40
JNB p3.6, X40
NOP
NOP
CLR p3.7
NOP
NOP
NOP
NOP
CLR p3.6
CLR C
AJMP X41

X40:

SETB C

X41:

RET

STOP:

CLR p3.7
NOP
NOP
NOP
SETB p3.6
NOP
NOP
NOP
NOP
SETB p3.7
RET

SHOUT:

PUSH B
MOV B, #8

X42:

RLC A
MOV p3.7, C
NOP
NOP

SETB p3.6
NOP
NOP
NOP
CLR p3.6
DJNZ B, X42
SETB p3.7
NOP
NOP
NOP
SETB p3.6
NOP
NOP
NOP
NOP
MOV C, p3.7
CLR p3.6
POP B
RET
SHIN:

SETB p3.7

PUSH B
MOV B, #8
X43:

NOP
NOP
NOP
SETB p3.6
NOP
NOP
NOP
MOV C, p3.7
RLC A
CLR p3.6
DJNZ B, X43
POP B
RET

ACK:

CLR p3.7
NOP
NOP
NOP
SETB p3.6

NOP
NOP
NOP
NOP
CLR p3.6
RET
NAK:

SETB p3.7
NOP
NOP
NOP
SETB p3.6
NOP
NOP
NOP
NOP
CLR p3.6
RET

write:
mov r6, #00h
djnz r6,$

djnz r6,$
lCALL START
JC XW2
MOV A, #00H
ORL A, #0A0H
lCALL SHOUT
JC XW1
MOV A,1bh
lCALL SHOUT
JC XW1
MOV A,1ah
lCALL SHOUT
JC XW1
CLR C
XW1:

lCALL STOP

XW2:

RET

R_CRNT:

lCALL START
JC XRC2
MOV A, #00H
ORL A, #0A1H

lCALL SHOUT
JC XRC1
lCALL SHIN
lCALL NAK
CLR C
XRC1:

lCALL STOP

XRC2:

RET

MSG0: db

' SMART CARD $'

MSG1: db

'12 AXS CARD READ$'

MSG2: db

'SUNMONTUEWEDTHUFRISAT$'

MSG3: db

'AXS 00 IN 00:00$'

MSG4: db

' < > OUT 00:00$'

MSG5: db

' ** WELCOME ** $'

MSG6: db

' CARD NOT VALID $'

end

Вам также может понравиться