Anda di halaman 1dari 59

N

i
c
i
o
p
i
o
c
e
s
s
o
i
s

&

N
i
c
i
o
c
o
n
t
i
o
l
l
e
i
s

L
a
b

M
I
N
I

k
C
I
L
C
1

A
U
T
U
M
A
T
I
C

C
U
L
L
E
C
E

B
E
L
L





1hls ro[ecL Lakes over Lhe Lask of
AuLomaLlc 8lnglng of Lhe 8ell ln Colleges
or Schools lL replaces Lhe Manual
SwlLchlng of Lhe bell as a MlcroconLroller
ClrculL conLrols Lhe 8elay sysLem Lo
whlch Lhe LlecLrlc 8ell ls connecLed


Subm|tted by

Muhs|n V
(8090001LC)
Mohammed Sameer
(8090321LC)
Nena Mary Iose
(8090221LC)
N|ran[ana Ambad|
(8090404LC)







HlCR0PR0CFSS0RS At0
HlCR0C0tTR0llFRS lA

MN PROJECT

AUTOMATIC COLLEGE BELL



Submitted by:
Mohammed Sameer (B090321EC)
Muhsin V (B090001EC)
Nena Mary 1ose (B090221EC)
Niranjana Ambadi (B090404EC)












ACKNOWLEDGEMENT


We would llke Lo Lhank Mr Sudheesh Ceorge our faculLy lncharge of Lhe Mlcroprocessors and
MlcroconLrollers Lab for granLlng us Lhls opporLunlLy Lo do a pro[ecL on Lhe sub[ecL whlch has
lndeed helped us Lo acqulre a greaL deal of pracLlcal knowledge abouL Lhe sub[ecL
We graLefully acknowledge Lhe consLanL encouragemenL we recelved from our Leachers
especlally Anand Slr who were ever ready Lo help us ln every sLage of Lhls pro[ecL
LasL buL noL Lhe leasL we would llke Lo Lhank our classmaLes and frlends for Lhelr supporL and
cooperaLlon wlLhouL whlch Lhe compleLlon of Lhls pro[ecL would noL have been posslble



































INTRODUCTION


1hls ro[ecL Lakes over Lhe Lask of 8lnglng of Lhe 8ell ln Colleges lL replaces Lhe Manual
SwlLchlng of Lhe 8ell ln Lhe College lL has an lnbullL 8eal 1lme Clock (uS1307) whlch Lrack over
Lhe 8eal 1lme When Lhls Llme Lquals Lo Lhe 8ell 8lnglng Llme Lhen Lhe 8elay for Lhe 8ell ls
swlLched Cn 1he 8ell 8lnglng Llme can be LdlLed aL any 1lme so LhaL lL can be used aL normal
Class 1lmlngs as well as Lxam 1lmes 1he 8eal 1lme Clock ls dlsplayed on an LCu 1he
MlcroconLroller A189S8232 ls used Lo conLrol all Lhe luncLlons lL geL Lhe Llme Lhrough Lhe
keypad and sLore lL ln lLs Memory And when Lhe 8eal Llme and 8ell Llme geL equal Lhen Lhe 8ell
ls swlLched on for a predeLermlned Llme





















CIRCUIT DIAGRAM:






















AT89S52
RTC
PORT-0
PORT-3
PORT-1
PORT-2
Relay System














COMPONENTS USED AND THEIR ROLE IN THE
WORKING OF THE CIRCUIT:


A 8kILI IN1kCDUC1ICN 1C 80S1 MICkCCCN1kCLLLk

When we have Lo learn abouL a new compuLer we have Lo famlllarlze abouL Lhe machlne
capablllLy we are uslng and we can do lL by sLudylng Lhe lnLernal hardware deslgn (devlces
archlLecLure) and also Lo know abouL Lhe slze number and Lhe slze of Lhe reglsLers

A mlcroconLroller ls a slngle chlp LhaL conLalns Lhe processor (Lhe Cu) nonvolaLlle
memory for Lhe program (8CM or flash) volaLlle memory for lnpuL and ouLpuL (8AM) a clock
and an l/C conLrol unlL Also called a compuLer on a chlp bllllons of mlcroconLroller unlLs
(MCus) are embedded each year ln a myrlad of producLs from Loys Lo appllances Lo
auLomoblles lor example a slngle vehlcle can use 70 or more mlcroconLrollers 1he followlng
plcLure descrlbes a general block dlagram of mlcroconLroller
1he followlng are some of Lhe capablllLles of 8031 mlcroconLroller
lnLernal 8CM and 8AM
l/C porLs wlLh programmable plns
1lmers and counLers
Serlal daLa communlcaLlon
1he 8031 archlLecLure conslsLs of Lhese speclflc feaLures
16 blL C daLa polnLer (u18)
8 blL program sLaLus word (SW)
8 blL sLack polnLer (S)
lnLernal 8CM 4k
lnLernal 8AM of 128 byLes
4 reglsLer banks each conLalnlng 8 reglsLers
80 blLs of general purpose daLa memory
32 lnpuL/ouLpuL plns arranged as four 8 blL porLs 03
1wo 16 blL Llmer/counLers 1011
1wo exLernal and Lhree lnLernal lnLerrupL sources CsclllaLor and clock
clrculLs



AT89S52
1he A189S32 ls a lowpower hlghperformance CMCS 8blL mlcroconLroller wlLh 8k byLes of ln
sysLem programmable llash memory lL ls compaLlble wlLh Lhe lndusLrysLandard 80C31
lnsLrucLlon seL and plnouL 1he onchlp llash allows Lhe program memory Lo be reprogrammed
lnsysLem or by a convenLlonal nonvolaLlle memory programmer

8y comblnlng a versaLlle 8blL Cu wlLh lnsysLem programmable llash on a monollLhlc chlp Lhe
ALmel A189S32 ls a powerful mlcroconLroller whlch provldes a hlghlyflexlble and cosLeffecLlve
soluLlon Lo many embedded conLrol appllcaLlons 1he A189S32 provldes Lhe followlng sLandard
feaLures 8k byLes of llash 236 byLes of 8AM 32 l/C llnes WaLchdog Llmer Lwo daLa polnLers
Lhree 16blL Llmer/counLers a slxvecLor Lwolevel lnLerrupL archlLecLure a full duplex serlal
porL onchlp osclllaLor and clock clrculLry

ln addlLlon Lhe A189S32 ls deslgned wlLh sLaLlc loglc for operaLlon down Lo zero frequency and
supporLs Lwo sofLware selecLable power savlng modes 1he ldle Mode sLops Lhe Cu whlle
allowlng Lhe 8AM Llmer/counLers serlal porL and lnLerrupL sysLem Lo conLlnue funcLlonlng
1he owerdown mode saves Lhe 8AM conLenLs buL freezes Lhe osclllaLor dlsabllng all oLher
chlp funcLlons unLll Lhe nexL lnLerrupL or hardware reseL Some of Lhe pln descrlpLlons of
A189S32 are as follows


Port 0

orL 0 ls an 8blL open draln bldlrecLlonal l/C porL As an ouLpuL porL each pln can slnk elghL
11L lnpuLs When 1s are wrlLLen Lo porL 0 plns Lhe plns can be used as hlgh lmpedance lnpuLs
orL 0 can also be conflgured Lo be Lhe mulLlplexed low order address/daLa bus durlng accesses
Lo exLernal program and daLa memory ln Lhls mode 0 has lnLernal pull ups orL 0 also
recelves Lhe code byLes durlng llash programmlng and ouLpuLs Lhe code byLes durlng program
verlflcaLlon LxLernal pull ups are requlred durlng program verlflcaLlon

Port 1

orL 1 ls an 8blL bldlrecLlonal l/C porL wlLh lnLernal pull ups 1he orL 1 ouLpuL buffers can
slnk/source four 11L lnpuLs When 1s are wrlLLen Lo orL 1 plns Lhey are pulled hlgh by Lhe
lnLernal pull ups and can be used as lnpuLs As lnpuLs orL 1 plns LhaL are exLernally belng
pulled low wlll source currenL (llL) because of Lhe lnLernal pull ups ln addlLlon 10 and 11
can be conflgured Lo be Lhe Llmer/counLer 2 exLernal counL lnpuL (10/12) and Lhe
Llmer/counLer 2 Lrlgger lnpuL (11/12Lx) respecLlvely

Port 2

orL 2 ls an 8blL bldlrecLlonal l/C porL wlLh lnLernal pull ups 1he orL 2 ouLpuL buffers can
slnk/source four 11L lnpuLs When 1s are wrlLLen Lo orL 2 plns Lhey are pulled hlgh by Lhe
lnLernal pull ups and can be used as lnpuLs As lnpuLs orL 2 plns LhaL are exLernally belng
pulled low wlll source currenL (llL) because of Lhe lnLernal pullups orL 2 emlLs Lhe hlghorder
address byLe durlng feLches from exLernal program memory and durlng accesses Lo exLernal
daLa memory LhaL use 16blL addresses

Port l

orL 3 ls an 8blL bldlrecLlonal l/C porL wlLh lnLernal pull ups 1he orL 3 ouLpuL buffers can
slnk/source four 11L lnpuLs When 1s are wrlLLen Lo orL 3 plns Lhey are pulled hlgh by Lhe
lnLernal pull ups and can be used as lnpuLs As lnpuLs orL 3 plns LhaL are exLernally belng
pulled low wlll source currenL (llL) because of Lhe pullups orL 3 also serves Lhe funcLlons of
varlous speclal feaLures of Lhe A189S32

x14L1

lnpuL Lo Lhe lnverLlng osclllaLor ampllfler and lnpuL Lo Lhe lnLernal clock operaLlng clrculL

x14L2

CuLpuL from Lhe lnverLlng osclllaLor ampllfler

1imers

1lmer 0 and 1lmer 1 ln Lhe A189S32 operaLe Lhe same way as 1lmer 0 and 1lmer 1 ln Lhe
A189C31 and A189C321lmer 2 ls a 16blL 1lmer/CounLer LhaL can operaLe as elLher a Llmer or
an evenL counLer 1lmer 2 has Lhree operaLlng modes capLure auLoreload (up or down
counLlng) and baud raLe generaLor 1he modes are selecLed by blLs ln 12CCn

Proqrommob/e c/ock Out

A 30 duLy cycle clock can be programmed Lo come ouL on 10 1hls pln besldes belng a
regular l/C pln has Lwo alLernaLe funcLlons lL can be programmed Lo lnpuL Lhe exLernal clock
for 1lmer/CounLer 2 or Lo ouLpuL a 30 duLy cycle clock ranglng from 61 Pz Lo 4 MPz aL a 16
MPz operaLlng frequency 1o conflgure Lhe 1lmer/CounLer 2 as a clock generaLor blL C/12
(12CCn1) musL be cleared and blL 12CL (12MCu1) musL be seL 8lL 182 (12CCn2) sLarLs and
sLops Lhe Llmer

terrupts

1he A189S32 has a LoLal of slx lnLerrupL vecLors Lwo exLernal lnLerrupLs (ln10 and ln11) Lhree
Llmer lnLerrupLs (1lmers 0 1 and 2) and Lhe serlal porL lnLerrupL Lach of Lhese lnLerrupL
sources can be lndlvldually enabled or dlsabled by seLLlng or clearlng a blL ln Speclal luncLlon
8eglsLer lL lL also conLalns a global dlsable blL LA whlch dlsables all lnLerrupLs aL once



DS1307:
1he uS1307 Serlal 8eal 1lme Clock whlch lncorporaLes a 2wlre serlal lnLerface can be
conLrolled uslng an 8031 compaLlble uS3000 mlcroconLroller 1he uS1307 ls connecLed dlrecLly
Lo Lwo of Lhe l/C porLs on a uS3000 mlcroconLroller





u51l07 uescriptio

1he uS1307 Serlal 8eal 1lme Clock ls a lowpower full 8Cu clock/calendar plus 36 byLes of
nonvolaLlle S8AM Address and daLa are Lransferred serlally vla Lhe 2wlre bldlrecLlonal bus
1he clock/calendar provldes seconds mlnuLes hours day daLe monLh and year lnformaLlon
1he end of Lhe monLh daLe ls auLomaLlcally ad[usLed for monLhs wlLh less Lhan 31 days
lncludlng correcLlons for leap year 1he clock operaLes ln elLher Lhe 24hour or 12hour formaL
wlLh AM/M lndlcaLor 1he uS1307 has a bullLln power sense clrculL whlch deLecLs power
fallures and auLomaLlcally swlLches Lo Lhe baLLery supply

u51l07 Operotio

1he uS1307 operaLes as a slave devlce on Lhe serlal bus Access ls obLalned by lmplemenLlng a
S1A81 condlLlon and provldlng a devlce ldenLlflcaLlon code followed by a reglsLer address
SubsequenL reglsLers can be accessed sequenLlally unLll a S1C condlLlon ls execuLed

5iqo/ uescriptios

vCC Cnu uC power ls provlded Lo Lhe devlce on Lhese plns vCC ls Lhe +3 volL lnpuL When 3
volLs are applled wlLhln normal llmlLs Lhe devlce ls fully accesslble and daLa can be wrlLLen and
read When a 3 volL baLLery ls connecLed Lo Lhe devlce and vCC ls below 123 x v8A1 reads and
wrlLes are lnhlblLed Powever Lhe 1lmekeeplng funcLlon conLlnues unaffecLed by Lhe lower
lnpuL volLage As vCC falls below v8A1 Lhe 8AM and Llmekeeper are swlLched over Lo Lhe
exLernal 3 volL baLLery

v8A1 8aLLery lnpuL for any sLandard 3 volL llLhlum cell or oLher energy source 8aLLery volLage
musL be held beLween 23 and 33 volLs for proper operaLlon 1he nomlnal wrlLe proLecL Lrlp
polnL volLage aL whlch access Lo Lhe real Llme clock and user 8AM ls denled ls seL by Lhe lnLernal
clrculLry as 123 x v8A1 nomlnal A LlLhlum baLLery wlLh 33 mAh or greaLer wlll back up Lhe
uS1307 for more Lhan 10 years ln Lhe absence of power

SCL (Serlal Clock lnpuL) SCL ls used Lo synchronlze daLa movemenL on Lhe serlal lnLerface

SuA (Serlal uaLa lnpuL/CuLpuL) SuA ls Lhe lnpuL/ ouLpuL pln for Lhe 2wlre serlal lnLerface
1he SuA pln ls open draln whlch requlres an exLernal pullup reslsLor

SCW/Cu1 (Square Wave/ CuLpuL urlver) When enabled Lhe SCWL blL seL Lo 1 Lhe SCW/Cu1
pln ouLpuLs one of four square wave frequencles (1 Pz 4 kPz 8 kPz 32 kPz) 1he SCW/Cu1
pln ls open draln whlch requlres an exLernal pullup reslsLor

x1 x2 ConnecLlons for a sLandard 32768 kPz quarLz crysLal 1he lnLernal osclllaLor clrculLry ls
deslgned for operaLlon wlLh a crysLal havlng a speclfled load capaclLance (CL) of 123 pl




AT24C08:

1he A124C08 provldes 8192 blLs of serlal elecLrlcally erasable and programmable readonly
memory (LL8CM) organlzed as 1024 words of 8 blLs each 1he devlce ls opLlmlzed for use ln
many lndusLrlal and commerclal appllcaLlons where lowpower and lowvolLage operaLlon are
essenLlal



uevice Operotio

CLCCk and uA1A 18AnSl1lCnS 1he SuA pln ls normally pulled hlgh wlLh an exLernal devlce
uaLa on Lhe SuA pln may change only durlng SCL low Llme perlods uaLa changes durlng SCL
hlgh perlods wlll lndlcaLe a sLarL or sLop condlLlon as deflned below

S1A81 CCnul1lCn A hlghLolow LranslLlon of SuA wlLh SCL hlgh ls a sLarL condlLlon whlch musL
precede any oLher command

S1C CCnul1lCn A lowLohlgh LranslLlon of SuA wlLh SCL hlgh ls a sLop condlLlon AfLer a read
sequence Lhe sLop command wlll place Lhe LL8CM ln a sLandby power mode

ACknCWLLuCL All addresses and daLa words are serlally LransmlLLed Lo and from Lhe LL8CM
ln 8blL words1he LL8CM sends a zero Lo acknowledge LhaL lL has recelved each word 1hls
happens durlng Lhe nlnLh clock cycle

S1Anu8? MCuL 1he A124C01A/02/04/08A/16A feaLures a lowpower sLandby mode whlch ls
enabled (a) upon powerup and (b) afLer Lhe recelpL of Lhe S1C blL and Lhe compleLlon of any
lnLernal operaLlons

MLMC8? 8LSL1 AfLer an lnLerrupLlon ln proLocol power loss or sysLem reseL any 2wlre parL
can be reseL by followlng Lhese sLeps
1 Clock up Lo 9 cycles
2 Look for SuA hlgh ln each cycle whlle SCL ls hlgh
3 CreaLe a sLarL condlLlon


ULN2003:

1he uLn2003 ls a hlgh volLage hlgh currenL uarllngLon array each conLalnlng seven open
collecLor uarllngLon palrs wlLh common emlLLers Lach channel raLed aL 300mA and can
wlLhsLand peak currenLs of 600mA Suppresslon dlodes are lncluded for lnducLlve load drlvlng
and Lhe lnpuLs are plnned opposlLe Lhe ouLpuLs Lo slmpllfy board layouL Lach lnpuL of Lhls
devlce has a zener dlode and a reslsLor ln serles Lo conLrol Lhe lnpuL currenL Lo a safe llmlL lL
has 7 uarllngLon palrs lnslde lL lL has a 27k serles base reslsLor for each uarllngLon palr






























PROGRAM

INCLUDE REG52.PDF
RB0 EQU 00H ; Select Register Bank 0
RB1 EQU 08H ; Select Register Bank 1 ...poke to PSW to use
RB2 EQU 10H ; Select Register Bank 1 ...poke to PSW to use


;

; PORT DECLERATION
;

ROW1 EQU P3.1
ROW2 EQU P3.2
ROW3 EQU P3.3
ROW4 EQU P3.4
COL1 EQU P3.5
COL2 EQU P3.6
COL3 EQU P3.7
KEYS EQU P3

;RELAYS EQU P1
RL1 EQU P1.3

TIMES EQU 80

SDA1 EQU P2.1 ;SDAPIN5
SCL1 EQU P2.0 ;SCLPIN6
WTCMD EQU 10100000B ;WRITE DATA COMMAND Note 3
RDCMD EQU 10100001B ;READ DATA COMMAND Note 3

SDA EQU P2.1 ;SDAPIN5
SCL EQU P2.0 ;SCLPIN6

DS1307W EQU 0D0H ; SLAVE ADDRESS 1101 000 0 TO WRITE
DS1307R EQU 0D1H ; SLAVE ADDRESS 1101 000 1 TO READ

; ***MACRO'S***
SCLHIGH MACRO
SETB SCL ; SET SCL HIGH
JNB SCL,$ ; LOOP UNTIL STRONG 1 ON SCL
ENDM
;'WTCMD1 EQU 10100010B ;WRITE DATA COMMAND Note 3
;RDCMD1 EQU 10100011B ;READ DATA COMMAND Note 3

; ***LCD CONTROL***
LCDRS EQU P0.0 ;LCD REGISTER SELECT LINE
LCDE EQU P0.1 ;LCD ENABLE LINE
LCDDB4 EQU P0.2 ;PORT 1 IS USED FOR DATA
LCDDB5 EQU P0.3 ;USED FOR DATA
LCDDB6 EQU P0.4 ;FOR DATA
LCDDB7 EQU P0.5 ;FOR DATA

; ***CURSOR CONTROL INSTRUCTIONS***

OFFCUR EQU 0CH
BLINKCUR EQU 0DH

; ***DISPLAY CONTROL INSTRUCTIONS***

CLRDSP EQU 01H
ONDSP EQU 0CH

; ***SYSTEM INSTRUCTIONS***

CONFIG EQU 28H ; 4-BIT DATA,2 LINES,5X7 MATRIX LCD
ENTRYMODE EQU 6 ; INCREMENT CURSOR DON'T SHIFT DISPLAY

KEYBCLOCK EQU P0.7
KEYBDATA EQU P0.6



DSEG ; This is internal data memory
ORG 20H ; Bit addressable memory

FLAGS DS 1
LASTREAD BIT FLAGS.0
SQW BIT FLAGS.4
ACKS BIT FLAGS.5
BUSFLT BIT FLAGS.6
2WBUSY BIT FLAGS.7
COMM BIT FLAGS.2
AM BIT FLAGS.1
AMS BIT FLAGS.3

FLAGSS DS 1
TMP BIT FLAGSS.0
ONTMP BIT FLAGSS.1


SECS DS 1 ; ' SECONDS STORAGE RAM
MINS DS 1 ; ' MINUTES ' '
HRS DS 1 ; ' HOURS ' '
DAY DS 1 ; ' DAY ' '
DATE1 DS 1 ; ' DATE ' '
MONTH DS 1 ; ' MONTH ' '
YEAR DS 1 ; ' YEAR
R30 DS 1
COUNT DS 1
KEY DS 1
KEY1 DS 1


VAL1 DS 1
VAL2 DS 1
VAL3 DS 1
VAL4 DS 1
VAL5 DS 1
DEVICE DS 1

ALMHOUR DS 1
ALMMIN DS 1
ALMAM DS 1
TIM DS 1
TIMEDELAY DS 1
TIMDEL DS 1

STACK DS 25


ALARMTIME DS 75


;

CSEG ; Code begins here

; -------------------------------------
; Main routine. Program execution starts here.
; -------------------------------------
ORG 00H ; Reset
AJMP MAINPROG

ORG 001BH
AJMP RELAYOFF

RELAYOFF
DJNZ TIM,BACK
MOV TIM,#16

MOV A,TIMDEL
ADD A,#01H
DA A
MOV TIMDEL,A
CJNE A,TIMEDELAY,BACK

CLR TR1
CLR EA
CLR RL1
RETI
BACK
MOV TL1,#08H
MOV TH1,#01H
SETB TR1
RETI


MAINPROG
MOV PSW,#RB0 ; Select register bank 0
MOV SP,#STACK
MOV P1,#00H

MOV TMOD,#10H
MOV TIM,#16
MOV TL1,#08H ;count Ior timer1
MOV TH1,#01H
SETB ET1

CALL RESETLCD4
CALL TITLES
CALL CHECKRTC
CALL READALARMS
SETB COL1
CLR ROW4


TOP CALL READCLOCK ;READ CLOCK
CALL RTCLOCK

MOV R0,#02H
Rr3 MOV R1,#0FFH
Rr1 MOV R2,#0FFH
Rr2 JNB COL1,KEYBOARDROUTINE11
DJNZ R2,Rr2
DJNZ R1,Rr1
DJNZ R0,Rr3

;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
; CHECK FOR TIME IS EQUAL
;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
JB AM,SXD1
MOV ALMAM,#00H
AJMP SDX1
SXD1
MOV ALMAM,#0FFH
SDX1

MOV R1,#ALARMTIME
MOV R0,#25

DVB1
MOV A,R1
MOV VAL1,A
INC R1
MOV A,R1
MOV VAL2,A
INC R1
MOV A,R1
MOV VAL3,A
INC R1

MOV ALMHOUR,VAL1
MOV ALMMIN,VAL2



SETB TMP
MOV A,ALMHOUR
CJNE A,#00H,VBN1
MOV A,ALMMIN
CJNE A,#00H,VBN1
CLR TMP
VBN1


JNB TMP,CHKK2
MOV A,ALMAM
CJNE A,VAL3,CHKK2
MOV A,HRS
CJNE A,ALMHOUR,CHKK2
MOV A,MINS
CJNE A,ALMMIN,CHKK2
MOV A,SECS
CJNE A,#00H,CHKK1
MOV TIMDEL,#00H
SETB RL1 ;Time Is Equal
SETB TR1
SETB EA
AJMP CHKK2
CHKK1
CJNE A,#01H,CHKK2
MOV TIMDEL,#00H
SETB RL1 ;Time Is Equal
SETB TR1
SETB EA
CHKK2
DJNZ R0,DVB1


MOV R0,#02H
RS3 MOV R1,#0FFH
RA1 MOV R2,#0FFH
RS2 JNB COL1,KEYBOARDROUTINE11
DJNZ R2,RS2
DJNZ R1,RA1
DJNZ R0,RS3
TOPD AJMP TOP

KEYBOARDROUTINE11
MOV R1,#0FFH
DJNZ R1,$
JB COL1,TOPD
AJMP KEYBOARDROUTINE1
;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((

;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
;************************************************************************
KEYBOARDROUTINE1

CALL DEVNUMM
SETB COMM
KEYBOARDROUTINE
MOV COUNT,#00H
KEYBOARD
CALL DELAY
MOV KEY,#00H
SETB COL1
SETB COL2
SETB COL3
K11 CLR ROW1
CLR ROW2
CLR ROW3
CLR ROW4
MOV A,KEYS
ANL A,#11100000B
CJNE A,#11100000B,K11 ;check till all keys released
K2 ACALL DEALAY ;call 20 msec delay
MOV A,KEYS ;see iI any key is pressed
ANL A,#11100000B ;mask unused bits
CJNE A,#11100000B,OVER ;key pressed, await closure
SJMP K2
OVER ACALL DEALAY
MOV A,KEYS
ANL A,#11100000B
CJNE A,#11100000B,OVER1
SJMP K2
OVER1 MOV A,KEYS
ORL A,#11111110B
MOV KEYS,A
CLR ROW1
MOV A,KEYS
ANL A,#11100000B
CJNE A,#11100000B,ROW1
MOV A,KEYS
ORL A,#11111110B
MOV KEYS,A
CLR ROW2
MOV A,KEYS
ANL A,#11100000B
CJNE A,#11100000B,ROW2
MOV A,KEYS
ORL A,#11111110B
MOV KEYS,A
CLR ROW3
MOV A,KEYS
ANL A,#11100000B
CJNE A,#11100000B,ROW3
MOV A,KEYS
ORL A,#11111110B
MOV KEYS,A
CLR ROW4
MOV A,KEYS
ANL A,#11100000B
CJNE A,#11100000B,ROW4
LJMP K2


ROW1 RLC A
JC MAT1
MOV KEY,#03H
AJMP K1
MAT1 RLC A
JC MAT2
MOV KEY,#02H
AJMP K1
MAT2 RLC A
JC K1
MOV KEY,#01H
AJMP K1

ROW2 RLC A
JC MAT3
MOV KEY,#06H
AJMP K1
MAT3 RLC A
JC MAT4
MOV KEY,#05H
AJMP K1
MAT4 RLC A
JC K1
MOV KEY,#04H
AJMP K1

ROW3 RLC A
JC MAT5
MOV KEY,#09H
AJMP K1
MAT5 RLC A
JC MAT6
MOV KEY,#08H
AJMP K1
MAT6 RLC A
JC K1
MOV KEY,#07H
AJMP K1

ROW4 RLC A
JC MAT7
MOV KEY,#5FH ;#
AJMP K1
MAT7 RLC A
JC MAT8
MOV KEY,#00H ;Ior 0
AJMP K1
MAT8 RLC A
JC K1
MOV KEY,#0AH ;*
MOV R4,#0CH
CALL WRLCDCOM4
CALL MDELAY
CALL READCLOCK ;READ CLOCK
CALL RTCLOCK
CALL DELAYS
AJMP TOP


GETTIMS AJMP GETTIM
K1

JNB COMM,GETTIMS

MOV A,COUNT
CJNE A,#00H,FG1
MOV A,KEY
SWAP A
MOV KEY1,A
CALL DEV1ONTIME1
INC COUNT
KEYB
AJMP KEYBOARD
FG1CJNE A,#01H,KEYB

MOV A,KEY
ORL A,KEY1
MOV KEY,A

CJNE A,#00H,HJ0
CALL ENTERNEWTIME
CALL DELAYS
CALL READCLOCK ;READ CLOCK
CALL RTCLOCK
MOV R4,#0FH
CALL WRLCDCOM4
CALL MDELAY
MOV R4,#81H
CALL WRLCDCOM4
CALL MDELAY
MOV DEVICE,KEY
CLR COMM
AJMP KEYBOARDROUTINE

HJ0CJNE A,#01H,HJ1
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ1CJNE A,#02H,HJ2
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME3
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ2CJNE A,#03H,HJ3
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME6
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ3CJNE A,#04H,HJ4
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME9
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ4CJNE A,#05H,HJ5
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME12
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ5CJNE A,#06H,HJ6
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME15
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ6CJNE A,#07H,HJ7
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME18
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ7CJNE A,#08H,HJ8
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME21
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ8CJNE A,#09H,HJ9
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME24
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ9CJNE A,#10H,HJ10
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME27
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ10CJNE A,#11H,HJ11
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME30
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ11CJNE A,#12H,HJ12
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME33
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ12CJNE A,#13H,HJ13
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME36
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ13CJNE A,#14H,HJ14
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME39
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ14CJNE A,#15H,HJ15
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME42
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ15CJNE A,#16H,HJ16
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME45
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ16CJNE A,#17H,HJ17
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME48
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ17CJNE A,#18H,HJ18
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME51
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ18CJNE A,#19H,HJ19
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME54
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ19CJNE A,#20H,HJ20
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME57
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ20CJNE A,#21H,HJ21
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME60
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ21CJNE A,#22H,HJ22
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME63
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ22CJNE A,#23H,HJ23
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME66
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ23CJNE A,#24H,HJ24
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME69
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ24CJNE A,#25H,HJ25
CALL DEV1ONTIME
CLR COMM
MOV R0,#ALARMTIME72
CALL DISPALMTIME
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ25CJNE A,#26H,HJ26
CALL DEV1ONTIMESGF
CLR COMM
MOV DEVICE,KEY
AJMP KEYBOARDROUTINE
HJ26
AJMP KEYBOARDROUTINE



GETTIM
MOV A,DEVICE
CJNE A,#00H,CVB0
JMP GETTIME
CVB0
MOV A,KEY
CJNE A,#5FH,CVB
CALL STOREALARMS
CALL TIMESTORED
CALL DELAYS
MOV R4,#0CH
CALL WRLCDCOM4
CALL MDELAY
CALL READCLOCK ;READ CLOCK
CALL RTCLOCK
CALL DELAYS
AJMP TOP
CVB
MOV A,COUNT
CJNE A,#00H,CVB1
MOV A,KEY
MOV VAL1,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
INC COUNT
AJMP KEYBOARD
CVB1
CJNE A,#01H,CVB2
MOV A,KEY
MOV VAL2,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
INC COUNT
AJMP KEYBOARD

CVB2
CJNE A,#02H,CVB3
MOV A,KEY
MOV VAL3,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
INC COUNT
AJMP KEYBOARD
CVB3
CJNE A,#03H,CVB4
MOV A,KEY
MOV VAL4,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
INC COUNT
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
AJMP KEYBOARD

CVB4
CJNE A,#04H,CVB5
MOV A,KEY
CJNE A,#01H,CVB7
MOV VAL5,#00H
MOV R4,#'A'
CALL WRLCDDATA
CALL MDELAY
AJMP CVB6
CVB7
MOV VAL5,#0FFH
MOV R4,#'P'
CALL WRLCDDATA
CALL MDELAY
CVB6
MOV COUNT,#00H
MOV R4,#0C4H
CALL WRLCDCOM4
CALL MDELAY
AJMP KEYBOARD
CVB5
AJMP KEYBOARD

;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
DISPALMTIME
MOV A,R0
ANL A,#0F0H
SWAP A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV A,R0
ANL A,#0FH
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV R4,#''
CALL WRLCDDATA
CALL MDELAY
INC R0
MOV A,R0
ANL A,#0F0H
SWAP A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV A,R0
ANL A,#0FH
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY

MOV R4,#' '
CALL WRLCDDATA
CALL MDELAY
INC R0
MOV A,R0
CJNE A,#00H,DCF1
MOV R4,#'A'
CALL WRLCDDATA
CALL MDELAY
MOV R4,#'M'
CALL WRLCDDATA
CALL MDELAY
MOV R4,#0FH
CALL WRLCDCOM4
CALL MDELAY
MOV R4,#0C4H
CALL WRLCDCOM4
CALL MDELAY
RET
DCF1
MOV R4,#'P'
CALL WRLCDDATA
CALL MDELAY
MOV R4,#'M'
CALL WRLCDDATA
CALL MDELAY
MOV R4,#0FH
CALL WRLCDCOM4
CALL MDELAY
MOV R4,#0C4H
CALL WRLCDCOM4
CALL MDELAY
RET
;##########################################################
; DISPLAY ROUTINES
;##########################################################
TITLES
MOV DPTR,#MSAG
CALL LCDMSG
RET
MSAG
DB 1H,82H,'College Bell',0C5H,'Timer',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEV1ONTIME1
MOV DPTR,#MSG1
CALL LCDMSG

MOV A,KEY
ANL A,#0FH
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
RET

MSG1
DB 1H,83H,'ON Time ',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEV1ONTIME

ANL A,#0FH
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY

MOV R4,#0C4H
CALL WRLCDCOM4
CALL MDELAY
RET
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEV1ONTIMESGF

MOV DPTR,#MSTG1
CALL LCDMSG

MOV A,TIMEDELAY
ANL A,#0F0H
SWAP A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY

MOV A,TIMEDELAY
ANL A,#0FH
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY

MOV R4,#0FH
CALL WRLCDCOM4
CALL MDELAY
MOV R4,#8DH
CALL WRLCDCOM4
CALL MDELAY
RET

MSTG1
DB 1H,81H,'Time Delay ',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEVNUMM
MOV DPTR,#MSG3
CALL LCDMSG
RET
MSG3
DB 1H,82H,'Enter Time',0C5H,'Number',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

TIMESTORED
MOV DPTR,#MSG10
CALL LCDMSG
RET
MSG10
DB 1H,80H,'Time Updated...',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;((((((((((((((((((((((((((((((((
DEALAY
MOV R1,#70
REPP2 NOP
DJNZ R1,REPP2
RET
;((((((((((((((((((((((((((((((((
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SDELAY
MOV R1,#04H
RU1 MOV R2,#0FFH
RU NOP
DJNZ R2,RU
DJNZ R1,RU1
RET
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DELAY
MOV R1,#0FFH
RE1 MOV R2,#0FFH
RE NOP
DJNZ R2,RE
DJNZ R1,RE1
RET
;**********************************************************
DELAYSMOV R0,#05H
RY2 MOV R1,#0FFH
RY1 MOV R2,#0FFH
RY NOP
DJNZ R2,RY
DJNZ R1,RY1
DJNZ R0,RY2
RET
;**********************************************************
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&
DELAYSS ;One second delay routine
MOV R0,#18H
RF3 MOV R1,#0FFH
RF1 MOV R2,#0FFH
RF2 NOP
DJNZ R2,RF2
DJNZ R1,RF1
DJNZ R0,RF3
RET
;**********************************************************
; INITIALIZE THE LCD 4-BIT MODE
;**********************************************************
INITLCD4
CLR LCDRS ; LCD REGISTER SELECT LINE
CLR LCDE ; ENABLE LINE
MOV R4, #CONFIG; FUNCTION SET - DATA BITS,
; LINES, FONTS
CALL WRLCDCOM4
MOV R4, #ONDSP ; DISPLAY ON
CALL WRLCDCOM4
MOV R4, #ENTRYMODE ; SET ENTRY MODE
CALL WRLCDCOM4 ; INCREMENT CURSOR RIGHT, NO SHIFT
MOV R4, #CLRDSP; CLEAR DISPLAY, HOME CURSOR
CALL WRLCDCOM4
RET
; **********************************************************
; SOFTWARE VERSION OF THE POWER ON RESET
; **********************************************************
RESETLCD4
CLR LCDRS ; LCD REGISTER SELECT LINE
CLR LCDE ; ENABLE LINE
CLR LCDDB7 ; SET BIT PATTERN FOR...
CLR LCDDB6 ; ... POWER-ON-RESET
SETB LCDDB5
SETB LCDDB4
SETB LCDE ; START ENABLE PULSE
CLR LCDE ; END ENABLE PULSE
MOV A, #4 ; DELAY 4 MILLISECONDS
CALL MDELAY
SETB LCDE ; START ENABLE PULSE
CLR LCDE ; END ENABLE PULSE
MOV A, #1 ; DELAY 1 MILLISECOND
CALL MDELAY
SETB LCDE ; START ENABLE PULSE
CLR LCDE ; END ENABLE PULSE
MOV A, #1 ; DELAY 1 MILLISECOND
CALL MDELAY
CLR LCDDB4 ; SPECIFY 4-BIT OPERATION
SETB LCDE ; START ENABLE PULSE
CLR LCDE ; END ENABLE PULSE
MOV A, #1 ; DELAY 1 MILLISECOND
CALL MDELAY
MOV R4, #CONFIG; FUNCTION SET
CALL WRLCDCOM4
MOV R4, #08H ; DISPLAY OFF
CALL WRLCDCOM4
MOV R4, #1 ; CLEAR DISPLAY, HOME CURSOR
CALL WRLCDCOM4
MOV R4,#ENTRYMODE ; SET ENTRY MODE
ACALL WRLCDCOM4
JMP INITLCD4

; **********************************************************
; SUB RECEIVES A COMMAND WORD TO THE LCD
; COMMAND MUST BE PLACED INSS R4 BY CALLING PROGRAM
; **********************************************************
WRLCDCOM4
CLR LCDE
CLR LCDRS ; SELECT READ COMMAND
PUSH ACC ; SAVE ACCUMULATOR
MOV A, R4 ; PUT DATA BYTE INSS ACC
MOV C, ACC.4 ; LOAD HIGH NIBBLE ON DATA BUS
MOV LCDDB4, C ; ONE BIT AT A TIME USING...
MOV C, ACC.5 ; BIT MOVE OPERATOINS
MOV LCDDB5, C
MOV C, ACC.6
MOV LCDDB6, C
MOV C, ACC.7
MOV LCDDB7, C
SETB LCDE ; PULSE THE ENABLE LINE
CLR LCDE
MOV C, ACC.0 ; SIMILARLY, LOAD LOW NIBBLE
MOV LCDDB4, C
MOV C, ACC.1
MOV LCDDB5, C
MOV C, ACC.2
MOV LCDDB6, C
MOV C, ACC.3
MOV LCDDB7, C
CLR LCDE
SETB LCDE ; PULSE THE ENABLE LINE
CLR LCDE
CALL MADELAY
POP ACC
RET
; **********************************************************
; SUB TO RECEIVE A DATA WORD TO THE LCD
; DATA MUST BE PLACED INSS R4 BY CALLING PROGRAM
; **********************************************************
WRLCDDATA
CLR LCDE
SETB LCDRS ; SELECT READ DATA
PUSH ACC ; SAVE ACCUMULATOR
MOV A, R4 ; PUT DATA BYTE INSS ACC
MOV C, ACC.4 ; LOAD HIGH NIBBLE ON DATA BUS
MOV LCDDB4, C ; ONE BIT AT A TIME USING...
MOV C, ACC.5 ; BIT MOVE OPERATOINS
MOV LCDDB5, C
MOV C, ACC.6
MOV LCDDB6, C
MOV C, ACC.7
MOV LCDDB7, C
SETB LCDE ; PULSE THE ENABLE LINE
CLR LCDE
MOV C, ACC.0 ; SIMILARLY, LOAD LOW NIBBLE
MOV LCDDB4, C
MOV C, ACC.1
MOV LCDDB5, C
MOV C, ACC.2
MOV LCDDB6, C
MOV C, ACC.3
MOV LCDDB7, C
CLR LCDE
SETB LCDE ; PULSE THE ENABLE LINE
CLR LCDE
NOP
NOP
POP ACC
RET

; **********************************************************
; SUB TAKES THE STRING IMMEDIATELY FOLLOWING THE CALL AND
; DISPLAYS ON THE LCD. STRING MUST BE TERMINATED WITH A
; NULL (0).
; **********************************************************
LCDMSG
CLR A ; Clear Index
MOVC A,ADPTR ; Get byte pointed by Dptr
INC DPTR ; Point to the next byte
JZ LCDMsg9 ; Return iI Iound the zero (end oI stringz)
CJNE A,#01H,LcdMsg1 ; Check iI is a Clear Command
MOV R4,A
CALL WRLCDCOM4 ;II yes, RECEIVE it as command to LCD
JMP LCDMSG ;Go get next byte Irom stringz

LcdMsg1 CJNE A,#0FFH,FLL ;Check Ior displaying Iull character
MOV R4,A
CALL WRLCDDATA
JMP LCDMSG
FLL CJNE A,#080h,$3 ; Data or Address? II ~ 80h then is address.
JC LcdMsgData ; Carry will be set iI A 80h (Data)
MOV R4,A
CALL WRLCDCOM4 ; Carry not set iI A~80, it is address
JMP LcdMsg ; Go get next byte Irom stringz

LcdMsgData ;
MOV R4,A
CALL WRLCDDATA ; It was data, RECEIVE it to Lcd
JMP LcdMsg ; Go get next byte Irom stringz
LcdMsg9

RET ; Return to Caller

; **********************************************************
; 1 MILLISECOND DELAY ROUTINE
; **********************************************************

MDELAY
PUSH ACC
MOV A,#0A6H
MDOLP
INC A
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
JNZ MDOLP
NOP
POP ACC
RET
MADELAY
PUSH ACC
MOV A,#036H
MADOLP
INC A
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
JNZ MADOLP
NOP
POP ACC
RET

;

; READ DATA FROM EEPROM
;

READEEPROM
MOV A,#WTCMD ;LOAD WRITE COMMAND TO SEND ADDRESS
CALL OUTS ;SEND IT
MOV A,R4 ;GET LOW BYTE ADDRESS
CALL OUT ;SEND IT
MOV A,#RDCMD ;LOAD READ COMMAND
CALL OUTS ;SEND IT
BRDLP CALL IN ;READ DATA
MOV R1,a ;STORE DATA
INC R1 ;INCREMENT DATA POINTER
DJNZ R6,AKLP ;DECREMENT LOOP COUNTER
CALL STOP ;IF DONE, ISSUE STOP CONDITION
RET ;DONE, EXIT ROUTINE
AKLP CLR SDA1 ;NOT DONE, ISSUE ACK
SETB SCL1
NOP ;NOTE 1
NOP
NOP
NOP ;NOTE 2
NOP
CLR SCL1
JMP BRDLP ;CONTINUE WITH READS
;

; STORE DATA IN EEPROM
;

STOREEEPROM
MOV A,#WTCMD ;LOAD WRITE COMMAND
CALL OUTS ;SEND IT
MOV A,R4 ;GET LOW BYTE ADDRESS
CALL OUT ;SEND IT
BTLP MOV A,R1 ;GET DATA
CALL OUT ;SEND IT
INC R1 ;INCREMENT DATA POINTER
DJNZ R6,BTLP ;LOOP TILL DONE
CALL STOP ;SEND STOP CONDITION
RET
;

;***********************************************************************
; THIS ROUTINE SENDS OUT CONTENTS OF THE ACCUMULATOR
; to the EEPROM and includes START condition. ReIer to the data sheets
; Ior discussion oI START and STOP conditions.
;***********************************************************************

OUTS MOV R2,#8 ;LOOP COUNT -- EQUAL TO BIT COUNT
SETB SDA1 ;INSURE DATA IS HI
SETB SCL1 ;INSURE CLOCK IS HI
NOP ;NOTE 1
NOP
NOP
CLR SDA1 ;START CONDITION -- DATA 0
NOP ;NOTE 1
NOP
NOP
CLR SCL1 ;CLOCK 0
OTSLP RLC A ;SHIFT BIT
JNC BITLS
SETB SDA1 ;DATA 1
JMP OTSL1 ;CONTINUE
BITLS CLR SDA1 ;DATA 0
OTSL1 SETB SCL1 ;CLOCK HI
NOP ;NOTE 1
NOP
NOP

CLR SCL1 ;CLOCK LOW
DJNZ R2,OTSLP ;DECREMENT COUNTER
SETB SDA1 ;TURN PIN INTO INPUT
NOP ;NOTE 1

SETB SCL1 ;CLOCK ACK
NOP ;NOTE 1
NOP
NOP

CLR SCL1
RET

;**********************************************************************
; THIS ROUTINE SENDS OUT CONTENTS OF ACCUMLATOR TO EEPROM
; without sending a START condition.
;**********************************************************************

OUT MOV R2,#8 ;LOOP COUNT -- EQUAL TO BIT COUNT
OTLP RLC A ;SHIFT BIT
JNC BITL
SETB SDA1 ;DATA 1
JMP OTL1 ;CONTINUE
BITL CLR SDA1 ;DATA 0
OTL1 SETB SCL1 ;CLOCK HI
NOP ;NOTE 1
NOP
NOP

CLR SCL1 ;CLOCK LOW
DJNZ R2,OTLP ;DECREMENT COUNTER
SETB SDA1 ;TURN PIN INTO INPUT
NOP ;NOTE 1

SETB SCL1 ;CLOCK ACK
NOP ;NOTE 1
NOP
NOP

CLR SCL1
RET


STOP CLR SDA1 ;STOP CONDITION SET DATA LOW
NOP ;NOTE 1
NOP
NOP

SETB SCL1 ;SET CLOCK HI
NOP ;NOTE 1
NOP
NOP

SETB SDA1 ;SET DATA HIGH
RET
;*******************************************************************
; THIS ROUTINE READS A BYTE OF DATA FROM EEPROM
; From EEPROM current address pointer.
; Returns the data byte in R1
;*******************************************************************
CREAD MOV A,#RDCMD ;LOAD READ COMMAND
CALL OUTS ;SEND IT
CALL IN ;READ DATA
MOV R1,A ;STORE DATA
CALL STOP ;SEND STOP CONDITION
RET

;**********************************************************************
; THIS ROUTINE READS IN A BYTE FROM THE EEPROM
; and stores it in the accumulator
;**********************************************************************

IN MOV R2,#8 ;LOOP COUNT
SETB SDA1 ;SET DATA BIT HIGH FOR INPUT
INLP CLR SCL1 ;CLOCK LOW
NOP ;NOTE 1
NOP
NOP
NOP

SETB SCL1 ;CLOCK HIGH
CLR C ;CLEAR CARRY
JNB SDA1,INL1 ;JUMP IF DATA 0
CPL C ;SET CARRY IF DATA 1
INL1 RLC A ;ROTATE DATA INTO ACCUMULATOR
DJNZ R2,INLP ;DECREMENT COUNTER
CLR SCL1 ;CLOCK LOW
RET


;**********************************************************
; INITILIZE RTC
;**********************************************************
CHECKRTC
SETB SDA ; ENSURE SDA HIGH
SCLHIGH ; ENSURE SCL HIGH
CLR ACKS ; CLEAR STATUS FLAGS
CLR BUSFLT
CLR 2WBUSY
CLR SQW
CALL OSCCONTROL ;Initilize the RTC
CALL SQWCONTROL1HZ
LCALL SENDSTART ; SEND 2WIRE START CONDITION
MOV A,#DS1307W ; SEND DS1307 WRITE COMMAND
LCALL SENDBYTE
MOV A,#08H ; SET POINTER TO REG 08H ON DS1307
LCALL SENDBYTE
LCALL SENDSTOP ; SEND STOP CONDITION
LCALL SENDSTART ; SEND START CONDITION
MOV A,#DS1307R ; SEND DS1307 READ COMMAND
LCALL SENDBYTE
LCALL READBYTE ; READ A BYTE OF DATA
MOV R1,A
LCALL SENDSTOP ; SEND 2WIRE STOP CONDITION
CJNE A,#0AAH,STORETIM
RET
STORETIM
MOV MINS,#00H
MOV HRS,#10H
MOV DAY,#06H
MOV DATE1,#01H
MOV MONTH,#01H
MOV YEAR,#10H
CLR AM
CALL STORERTC
RET
; **********************************************************
; CHECK FOR ENTER THE TIME
; **********************************************************

SETRTC
ret
; **********************************************************
; SUB SETS THE DS1307 OSCILLATOR
; **********************************************************
OSCCONTROL
CALL SENDSTART ; GENERATE START CONDITION
MOV A,#DS1307W ; 1101 0000 ADDRESS WRITE-BIT
CALL SENDBYTE ; SEND BYTE TO 1307
MOV A,#00H ; ADDRESS BYTE TO REGISTER 00H
CALL SENDBYTE ; SECONDS REGISTER, ALWAYS LEAVE
SETB LASTREAD ; REG 00H-BIT #7 0 (LOW)
CALL SENDSTOP ; IF REG 00H-BIT #7 1 CLOCK
CALL SENDSTART ; OSCILLATOR IS OFF.
MOV A,#DS1307R ; 1101 0001 ADDRESS READ-BIT
CALL SENDBYTE ;
CALL READBYTE ; READ A BYTE FROM THE 1307
CLR ACC.7 ; CLEAR REG 00H-BIT #7 TO ENABLE
OSCSET ; OSCILLATOR.
PUSH ACC ; SAVE ON STACK
CALL SENDSTOP ;
CALL SENDSTART ;
MOV A,#DS1307W ; SETUP TO WRITE
CALL SENDBYTE ;
MOV A,#00H ; REGISTER 00H ADDRESS
CALL SENDBYTE ;
POP ACC ; GET DATA TO START OSCILLATOR
CALL SENDBYTE ; SEND IT
CALL SENDSTOP
RET
; **********************************************************
; THIS SUB CONTROLS THE SQW OUTPUT 1HZ
; **********************************************************
SQWCONTROL1HZ
LCALL SENDSTART ; SEND START CONDITION
MOV A,#DS1307W ; SET POINTER TO REG 07H ON
; DS1307
LCALL SENDBYTE
MOV A,#07H
LCALL SENDBYTE
MOV A,#90H ; SQW/OUTSS ON AT 1HZ
JNB SQW,SQWSET ; JUMP IF SQW BIT IS ACTIVE
MOV A,#80H ; TURN SQW/OUTSS OFF OFF HIGH
SQWSET
LCALL SENDBYTE
LCALL SENDSTOP
RET
; **********************************************************
; THIS SUB READS ONE BYTE OF DATA FROM THE DS1307
; **********************************************************

READBYTE
MOV R6,#08H; SET COUNTER FOR 8-BITS DATA
MOV A,#00H
SETB SDA ; SET SDA HIGH TO ENSURE LINE
; FREE
READBITS
SCLHIGH ; TRANSITION SCL LOW-TO-HIGH
MOV C,SDA ; MOVE DATA BIT INTO CARRY
RLC A ; ROTATE CARRY-BIT INTO ACC.0
CLR SCL ; TRANSITION SCL HIGH-TO-LOW
DJNZ R6,READBITS
; LOOP FOR 8-BITS
JB LASTREAD,ACKN
; CHECK TO SEE IF THIS IS
; THE LAST READ
CLR SDA ; IF NOT LAST READ SEND ACK-BIT

ACKN
SCLHIGH ; PULSE SCL TO TRANSMIT ACKNOWLEDGE
CLR SCL ; OR NOT ACKNOWLEDGE BIT
RET

; **********************************************************
; SUB SENDS START CONDITION
; **********************************************************

SENDSTART
SETB 2WBUSY ; INDICATE THAT 2-WIRE
CLR ACKS ; OPERATION IS INSS PROGRESS
CLR BUSFLT ; CLEAR STATUS FLAGS
JNB SCL,FAULT
JNB SDA,FAULT
SETB SDA ; BEGIN START CODITION
SCLHIGH
CLR SDA
CALL DEELAY
CLR SCL
RET
FAULT
SETB BUSFLT
RET

; **********************************************************
; SUB SENDS STOP CONDITION
; **********************************************************
SENDSTOP
CLR SDA
SCLHIGH
SETB SDA
CLR 2WBUSY
RET
; **********************************************************
; SUB DELAYS THE BUS
; **********************************************************
DEELAY
NOP ; DELAY FOR BUS TIMING
RET
; **********************************************************
; THIS SUB SENDS 1 BYTE OF DATA TO THE DS1307
; CALL THIS FOR EACH REGISTER SECONDS TO YEAR
; ACC MUST CONTAIN DATA TO BE SENT TO CLOCK
; **********************************************************
SENDBYTE
MOV R6,#08H; SET COUNTER FOR 8-BITS
SBLOOP
JNB ACC.7,NOTONE; CHECK TO SEE IF BIT-7 OF
SETB SDA ; ACC IS A 1, AND SET SDA HIGH
JMP ONE
NOTONE
CLR SDA ; CLR SDA LOW
ONE
SCLHIGH ; TRANSITION SCL LOW-TO-HIGH
RL A ; ROTATE ACC LEFT 1-BIT
CLR SCL ; TRANSITION SCL LOW-TO-HIGH
DJNZ R6,SBLOOP; LOOP FOR 8-BITS
SETB SDA ; SET SDA HIGH TO LOOK FOR
SCLHIGH ; ACKNOWLEDGE PULSE
CLR ACKS
JNB SDA,SBEX ; CHECK FOR ACK OR NOT ACK
SETB ACKS ; SET ACKNOWLEDGE FLAG FOR
; NOT ACK
SBEX
CALL DEELAY ; DELAY FOR AN OPERATION
CLR SCL ; TRANSITION SCL HIGH-TO-LOW
CALL DEELAY ; DELAY FOR AN OPERATION
RET
; **********************************************************
; SUB READS THE CLOCK AND WRITES IT TO THE SCRATCHPAD MEMORY
; ON RETURN FROM HERE DATE & TIME DATA WILL BE STORED INSS THE
; DATE & TIME REGISTERS FROM 24H (SECS) TO 2AH (YEAR)
; ALARM SETTINGS INSS REGISTERS 2CH(HRS) AND 2DH(MINUTES).
; **********************************************************
READCLOCK
MOV R1,#SECS ; SECONDS STORAGE LOCATION
MOV R30,#00H
CLR LASTREAD
CALL SENDSTART
MOV A,#DS1307W
CALL SENDBYTE
MOV A,#00H
CALL SENDBYTE
CALL SENDSTOP
CALL SENDSTART
MOV A,#DS1307R
CALL SENDBYTE

READLOOP
MOV A,R30
CJNE A,#09H,NOTLAST
SETB LASTREAD

NOTLAST
CALL READBYTE
MOV R1,A
MOV A,R30
CJNE A,#00H,NOTFIRST
MOV A,R1
CLR ACC.7 ; ENSURE OSC BIT0 (ENABLED)
MOV R1,A
NOTFIRST
INC R1
INC R30
MOV A,R30
CJNE A,#07H,READLOOP
CALL SENDSTOP
RET
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&
; DISPLAY CLOCK ON LCD
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&
RTCLOCK
MOV R4,#01H
CALL WRLCDCOM4
CALL MDELAY
MOV R4,#81H
CALL WRLCDCOM4
CALL MDELAY

MOV R3,DATE1
CALL SPLITDATA
MOV R4,#'-'
CALL WRLCDDATA
CALL MDELAY
MOV R3,MONTH
CALL SPLITDATA
MOV R4,#'-'
CALL WRLCDDATA
CALL MDELAY
MOV R4,#'2'
CALL WRLCDDATA
CALL MDELAY
MOV R4,#'0'
CALL WRLCDDATA
CALL MDELAY
MOV R3,YEAR
CALL SPLITDATA

MOV A,DAY
CJNE A,#01H,TGY1
CALL SUN
JMP TGY
TGY1 CJNE A,#02H,TGY2
CALL MON
JMP TGY
TGY2 CJNE A,#03H,TGY3
CALL TUE
JMP TGY
TGY3 CJNE A,#04H,TGY4
CALL WED
JMP TGY
TGY4 CJNE A,#05H,TGY5
CALL THU
JMP TGY
TGY5 CJNE A,#06H,TGY6
CALL FRI
JMP TGY
TGY6 CJNE A,#07H,TGY
CALL SAT
JMP TGY
TGY

MOV R4,#0C3H
CALL WRLCDCOM4
CALL MDELAY
MOV A,HRS
JNB ACC.5,DCF3
SETB AM ;PM
JMP DCF2
DCF3 CLR AM
DCF2 ANL A,#00011111B
MOV HRS,A
MOV R3,A
CALL SPLITDATA
MOV R4,#''
CALL WRLCDDATA
CALL MDELAY
MOV R3,MINS
CALL SPLITDATA
MOV R4,#''
CALL WRLCDDATA
CALL MDELAY
MOV R3,SECS
CALL SPLITDATA
MOV R4,#' '
CALL WRLCDDATA
CALL MDELAY

JB AM,DCF0
MOV R4,#'A'
CALL WRLCDDATA
CALL MDELAY
JMP DCF4

DCF0 MOV R4,#'P'
CALL WRLCDDATA
CALL MDELAY

DCF4 MOV R4,#'M'
CALL WRLCDDATA
CALL MDELAY
RET
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&
SPLITDATA
MOV A,R3
ANL A,#0F0H
SWAP A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV A,R3
ANL A,#0FH
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
RET
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SUN
MOV DPTR,#MAG1
CALL LCDMSG
RET
MAG1
DB ' SUN',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MON
MOV DPTR,#MAG2
CALL LCDMSG
RET
MAG2
DB ' MON',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TUE
MOV DPTR,#MAG3
CALL LCDMSG
RET
MAG3
DB ' TUE',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WED
MOV DPTR,#MAG4
CALL LCDMSG
RET
MAG4
DB ' WED',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THU
MOV DPTR,#MAG5
CALL LCDMSG
RET
MAG5
DB ' THU',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FRI
MOV DPTR,#MAG6
CALL LCDMSG
RET
MAG6
DB ' FRI',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SAT
MOV DPTR,#MAG7
CALL LCDMSG
RET
MAG7
DB ' SAT',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
; STORE THE TIME TO RTC CHIP
;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
STORERTC
LCALL SENDSTART ; SEND 2WIRE START CONDITION
MOV A,#DS1307W ; LOAD DS1307 WRITE COMMAND
LCALL SENDBYTE ; SEND WRITE COMMAND
MOV A,#08H ; SET DS1307 DATA POINTER TO BEGINNING
LCALL SENDBYTE ; OF USER RAM 08H
MOV A,#0AAH ; WRITE BYTE TO ENTIRE RAM SPACE
LCALL SENDBYTE
LCALL SENDSTOP ; SEND 2WIRE STOP CONTION

LCALL SENDSTART ; SEND 2WIRE START CONDITION
MOV A,#DS1307W ; LOAD DS1307 WRITE COMMAND
LCALL SENDBYTE ; SEND WRITE COMMAND
MOV A,#01H ; SET DS1307 DATA POINTER TO BEGINNING
LCALL SENDBYTE ; OF 00H
MOV A,MINS ; Send min
LCALL SENDBYTE

JNB AMS,H6K7
ORL HRS,#00100000B
AJMP H6K8
H6K7 ANL HRS,#11011111B
H6K8
MOV A,HRS ;send hr
SETB ACC.6 ;12 HR MODE
CLR ACC.5
JNB AM,SXK
SETB ACC.5
SXK
LCALL SENDBYTE
MOV A,DAY ; Send Day
LCALL SENDBYTE
MOV A,DATE1 ; Send date
LCALL SENDBYTE
MOV A,MONTH ; Send month
LCALL SENDBYTE
MOV A,YEAR ; Send yr
LCALL SENDBYTE
LCALL SENDSTOP ; SEND 2WIRE STOP CONTION
RET
;##########################################################
GETRTC

RET

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ENTERNEWTIME
MOV DPTR,#MSAG1
CALL LCDMSG
RET
MSAG1
DB 1H,80H,'Plz Enter the',0C0H,'Date & Time',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CLOCKUPDATED
MOV DPTR,#MSG11
CALL LCDMSG
RET
MSG11
DB 1H,0C2H,'Clock Updated...',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BLANK
MOV DPTR,#MSG12
CALL LCDMSG
RET
MSG12
DB 1H,80H,'Press keys',0C0h, 00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
READALARMS

MOV R1,#ALARMTIME ;GET DATA IN BYTES(RAM)
MOV R4,#10H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME6 ;GET DATA IN BYTES(RAM)
MOV R4,#20H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME12 ;GET DATA IN BYTES(RAM)
MOV R4,#30H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME18 ;GET DATA IN BYTES(RAM)
MOV R4,#40H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME24 ;GET DATA IN BYTES(RAM)
MOV R4,#50H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME30 ;GET DATA IN BYTES(RAM)
MOV R4,#60H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME36 ;GET DATA IN BYTES(RAM)
MOV R4,#70H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME42 ;GET DATA IN BYTES(RAM)
MOV R4,#80H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME48 ;GET DATA IN BYTES(RAM)
MOV R4,#90H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME54 ;GET DATA IN BYTES(RAM)
MOV R4,#0A0H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME60 ;GET DATA IN BYTES(RAM)
MOV R4,#0B0H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME66 ;GET DATA IN BYTES(RAM)
MOV R4,#0C0H ;DATA ADDRESS IN EEPROM
MOV R6,#6 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#ALARMTIME72 ;GET DATA IN BYTES(RAM)
MOV R4,#0D0H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL READEEPROM

MOV R1,#TIMEDELAY ;GET DATA IN BYTES(RAM)
MOV R4,#0E0H ;DATA ADDRESS IN EEPROM
MOV R6,#1 ;NUMBER OF BYTES
CALL READEEPROM
RET

STOREALARMS
MOV A,VAL1
SWAP A
ORL A,VAL2
MOV VAL1,A

MOV A,VAL3
SWAP A
ORL A,VAL4
MOV VAL2,A

MOV A,DEVICE
CJNE A,#01H,JKL1
MOV R1,#ALARMTIME ;GET DATA IN BYTES(RAM)
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME ;GET DATA IN BYTES(RAM)
MOV R4,#10H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
RET

JKL1 CJNE A,#02H,JKL2
MOV R1,#ALARMTIME3
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME3 ;GET DATA IN BYTES(RAM)
MOV R4,#13H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
RET
JKL2 CJNE A,#03H,JKL3
MOV R1,#ALARMTIME6
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME6 ;GET DATA IN BYTES(RAM)
MOV R4,#20H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
RET
JKL3 CJNE A,#04H,JKL4
MOV R1,#ALARMTIME9
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME9 ;GET DATA IN BYTES(RAM)
MOV R4,#23H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
RET
JKL4 CJNE A,#05H,JKL5
MOV R1,#ALARMTIME12
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME12 ;GET DATA IN
BYTES(RAM)
MOV R4,#30H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
RET
JKL5 CJNE A,#06H,JKL6
MOV R1,#ALARMTIME15
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME15 ;GET DATA IN
BYTES(RAM)
MOV R4,#33H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
RET
JKL6 CJNE A,#07H,JKL7
MOV R1,#ALARMTIME18
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME18 ;GET DATA IN
BYTES(RAM)
MOV R4,#40H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
RET
JKL7 CJNE A,#08H,JKL8
MOV R1,#ALARMTIME21
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME21 ;GET DATA IN
BYTES(RAM)
MOV R4,#43H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL8 CJNE A,#09H,JKL9
MOV R1,#ALARMTIME24
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME24 ;GET DATA IN
BYTES(RAM)
MOV R4,#50H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL9 CJNE A,#10H,JKL10
MOV R1,#ALARMTIME27
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME27 ;GET DATA IN
BYTES(RAM)
MOV R4,#53H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL10CJNE A,#11H,JKL11
MOV R1,#ALARMTIME30
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME30 ;GET DATA IN
BYTES(RAM)
MOV R4,#60H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL11CJNE A,#12H,JKL12
MOV R1,#ALARMTIME33
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME33 ;GET DATA IN
BYTES(RAM)
MOV R4,#63H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL12CJNE A,#13H,JKL13
MOV R1,#ALARMTIME36
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME36 ;GET DATA IN BYTES(RAM)
MOV R4,#70H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL13CJNE A,#14H,JKL14
MOV R1,#ALARMTIME39
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME39 ;GET DATA IN
BYTES(RAM)
MOV R4,#73H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL14CJNE A,#15H,JKL15
MOV R1,#ALARMTIME42
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME42 ;GET DATA IN BYTES(RAM)
MOV R4,#80H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL15CJNE A,#16H,JKL16
MOV R1,#ALARMTIME45
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME45 ;GET DATA IN BYTES(RAM)
MOV R4,#83H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL16CJNE A,#17H,JKL17
MOV R1,#ALARMTIME48
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME48 ;GET DATA IN BYTES(RAM)
MOV R4,#90H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL17CJNE A,#18H,JKL18
MOV R1,#ALARMTIME51
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME51 ;GET DATA IN BYTES(RAM)
MOV R4,#93H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL18CJNE A,#19H,JKL19
MOV R1,#ALARMTIME54
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME54 ;GET DATA IN BYTES(RAM)
MOV R4,#0A0H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL19CJNE A,#20H,JKL20
MOV R1,#ALARMTIME57
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME57 ;GET DATA IN BYTES(RAM)
MOV R4,#0A3H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL20CJNE A,#21H,JKL21
MOV R1,#ALARMTIME60
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME60 ;GET DATA IN BYTES(RAM)
MOV R4,#0B0H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL21CJNE A,#22H,JKL22
MOV R1,#ALARMTIME63
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME63 ;GET DATA IN BYTES(RAM)
MOV R4,#0B3H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL22CJNE A,#23H,JKL23
MOV R1,#ALARMTIME66
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME66 ;GET DATA IN BYTES(RAM)
MOV R4,#0C0H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL23CJNE A,#24H,JKL24
MOV R1,#ALARMTIME69
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME69 ;GET DATA IN BYTES(RAM)
MOV R4,#0C3H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL24CJNE A,#25H,JKL25
MOV R1,#ALARMTIME72
MOV R1,VAL1
INC R1
MOV R1,VAL2
INC R1
MOV R1,VAL5
MOV R1,#ALARMTIME72 ;GET DATA IN BYTES(RAM)
MOV R4,#0D0H ;DATA ADDRESS IN EEPROM
MOV R6,#3 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL25CJNE A,#26H,JKL26
MOV TIMEDELAY,VAL1
MOV R1,#TIMEDELAY ;GET DATA IN BYTES(RAM)
MOV R4,#0E0H ;DATA ADDRESS IN EEPROM
MOV R6,#1 ;NUMBER OF BYTES
CALL STOREEEPROM
JKL26RET



;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$4
GETTIME
MOV A,KEY
CJNE A,#5FH,CEB
CALL STORERTC
CALL TIMESTORED
CALL DELAYS
MOV R4,#0CH
CALL WRLCDCOM4
CALL MDELAY
CALL READCLOCK ;READ CLOCK
CALL RTCLOCK
CALL DELAYS
JMP TOP
CEB
MOV A,COUNT
CJNE A,#00H,COB1
MOV A,KEY
MOV VAL1,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
INC COUNT
JMP KEYBOARD
COB1
CJNE A,#01H,COB2
MOV A,KEY
MOV VAL2,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
INC COUNT
MOV A,VAL1
SWAP A
ORL A,VAL2
MOV DATE1,A
JMP KEYBOARD
COB2
CJNE A,#02H,COB3
MOV A,KEY
MOV VAL1,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
INC COUNT
JMP KEYBOARD
COB3
CJNE A,#03H,COB4
MOV A,KEY
MOV VAL2,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
INC COUNT
MOV A,VAL1
SWAP A
ORL A,VAL2
MOV MONTH,A
JMP KEYBOARD
COB4
CJNE A,#04H,COB5
MOV A,KEY
MOV VAL1,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
INC COUNT
JMP KEYBOARD
COB5
CJNE A,#05H,COB6
MOV A,KEY
MOV VAL2,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
INC COUNT
MOV A,VAL1
SWAP A
ORL A,VAL2
MOV YEAR,A
JMP KEYBOARD
COB6
CJNE A,#06H,COB7
MOV A,KEY
MOV R4,#10H
CALL WRLCDCOM4
CALL MDELAY
CJNE A,#01H,TTY1
CALL SUN
JMP TTY
TTY1 CJNE A,#02H,TTY2
CALL MON
JMP TTY
TTY2 CJNE A,#03H,TTY3
CALL TUE
JMP TTY
TTY3 CJNE A,#04H,TTY4
CALL WED
JMP TTY
TTY4 CJNE A,#05H,TTY5
CALL THU
JMP TTY
TTY5 CJNE A,#06H,TTY6
CALL FRI
JMP TTY
TTY6 CJNE A,#07H,TTY
CALL SAT
JMP TTY
TTY MOV DAY,KEY
MOV R4,#0C3H
CALL WRLCDCOM4
CALL MDELAY
INC COUNT
JMP KEYBOARD

COB7
CJNE A,#07H,COB8
MOV A,KEY
MOV VAL1,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
INC COUNT
JMP KEYBOARD
COB8
CJNE A,#08H,COB9
MOV A,KEY
MOV VAL2,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
INC COUNT
MOV A,VAL1
SWAP A
ORL A,VAL2
MOV HRS,A
JMP KEYBOARD
COB9
CJNE A,#09H,COB10
MOV A,KEY
MOV VAL1,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
INC COUNT
JMP KEYBOARD
COB10
CJNE A,#0AH,COB11
MOV A,KEY
MOV VAL2,A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
MOV R4,#14H
CALL WRLCDCOM4
CALL MDELAY
INC COUNT
MOV A,VAL1
SWAP A
ORL A,VAL2
MOV MINS,A
JMP KEYBOARD
COB11
CJNE A,#0BH,COB12
MOV A,KEY
CJNE A,#01H,CAB0
CLR AM
MOV R4,#'A'
CALL WRLCDDATA
CALL MDELAY
JMP KEYBOARD
CAB0
SETB AM
MOV R4,#'P'
CALL WRLCDDATA
CALL MDELAY
JMP KEYBOARD
COB12
JMP KEYBOARD
END
HEX FILE

02000000013DC0
10001B00011DD53614753610E5382401D4F538B5E5
10002B003707C28EC2AFC29332758B08758D01D262
10003B008E3275D0007581397590007589107536C3
10004B0010758B08758D01D2AB120648120535124F
10005B0007FE120B47D2B5C2B412091A1209517816
10006B000279FF7AFF30B576DAFBD9F7D8F32001A6
10007B000575350001847535FF79527819E7F52D33
10008B0009E7F52E09E7F52F09852D33852E34D297
10009B0008E533B40007E534B40002C20830082B7E
1000AB00E535B52F26E524B53321E523B5341CE51D
1000BB0022B4000B753800D293D28ED2AF01D6B4D6
1000CB000109753800D293D28ED2AFD8B0780279AD
1000DB00FF7AFF30B508DAFBD9F7D8F3016479FF63
1000EB00D9FE20B5F701F21205C5D202752A00120E
1000FB000609752B00D2B5D2B6D2B7C2B1C2B2C205
10010B00B3C2B4E5B054E0B4E0F1B1F9E5B054E0FA
10011B00B4E00280F5B1F9E5B054E0B4E00280EA56
10012B00E5B044FEF5B0C2B1E5B054E0B4E030E563
10013B00B044FEF5B0C2B2E5B054E0B4E039E5B07E
10014B0044FEF5B0C2B3E5B054E0B4E042E5B044D0
10015B00FEF5B0C2B4E5B054E0B4E04B0201153388
10016B004005752B0321DD334005752B0221DD3353
10017B004060752B0121DD334005752B0621DD33E6
10018B004005752B0521DD334048752B0421DD33EC
10019B004005752B0921DD334005752B0821DD3317
1001AB004030752B0721DD334005752B5F21DD3387
1001BB004005752B0021DD334018752B0A7C0C1282
1001CB00068F12072112091A120951120613016424
1001DB0061F13002FBE52AB4000CE52BC4F52C12BF
1001EB000551052A01FAB401FBE52B452CF52BB47F
1001FB000023120AF512061312091A1209517C0F69
10020B0012068F1207217C8112068F120721852B74
10021B0032C20201F7B4010F120570C202785212FA
10022B0004AB852B3201F7B4020F120570C20278B2
10023B00551204AB852B3201F7B4030F120570C2B4
10024B000278581204AB852B3201F7B4040F120558
10025B0070C202785B1204AB852B3201F7B4050F29
10026B00120570C202785E1204AB852B3201F7B413
10027B00060F120570C20278611204AB852B320196
10028B00F7B4070F120570C20278641204AB852B0A
10029B003201F7B4080F120570C20278671204AB73
1002AB00852B3201F7B4090F120570C202786A125E
1002BB0004AB852B3201F7B4100F120570C2027814
1002CB006D1204AB852B3201F7B4110F120570C2FE
1002DB000278701204AB852B3201F7B4120F1205A2
1002EB0070C20278731204AB852B3201F7B4130F73
1002FB00120570C20278761204AB852B3201F7B46B
10030B00140F120570C20278791204AB852B3201DF
10031B00F7B4150F120570C202787C1204AB852B53
10032B003201F7B4160F120570C202787F1204ABBC
10033B00852B3201F7B4170F120570C202788212A7
10034B0004AB852B3201F7B4180F120570C202787B
10035B00851204AB852B3201F7B4190F120570C24D
10036B000278881204AB852B3201F7B4200F1205EB
10037B0070C202788B1204AB852B3201F7B4210FBC
10038B00120570C202788E1204AB852B3201F7B4C2
10039B00220F120570C20278911204AB852B320129
1003AB00F7B4230F120570C20278941204AB852B9D
1003BB003201F7B4240F120570C20278971204AB06
1003CB00852B3201F7B4250F120570C202789A12F1
1003DB0004AB852B3201F7B4260A120584C20285C1
1003EB002B3201F701F7E532B40003020E13E52BB4
1003FB00B45F1C120BC61205E01206137C0C12061E
0F040B008F12072112091A1209511206130164E8
10041A00E52AB40011E52BF52D2430FC1206C6128C
10042A000721052A01FAB40119E52BF52E2430FC1F
10043A001206C61207217C1412068F120721052AFA
10044A0001FAB40211E52BF52F2430FC1206C6126C
10045A000721052A01FAB40319E52BF5302430FCEB
10046A001206C6120721052A7C1412068F120721CA
10047A0001FAB4042AE52BB4010D7531007C41124E
10048A0006C6120721819C7531FF7C501206C612DE
10049A000721752A007CC412068F12072101FA016E
1004AA00FAE654F0C42430FC1206C6120721E654B8
1004BA000F2430FC1206C61207217C3A1206C61215
1004CA00072108E654F0C42430FC1206C61207219C
1004DA00E6540F2430FC1206C61207217C201206AD
1004EA00C612072108E6B400217C411206C612078B
1004FA00217C4D1206C61207217C0F12068F1207A5
10050A00217CC412068F120721227C501206C612C1
10051A0007217C4D1206C61207217C0F12068F1284
10052A0007217CC412068F1207212290053C12066D
10053A00FC220182436F6C6C6567652042656C6CB6
10054A00C554696D6572009005651206FCE52B5469
10055A000F2430FC1206C61207212201834F4E20B7
10056A0054696D652000540F2430FC1206C6120728
10057A00217CC412068F120721229005B61206FCAE
10058A00E53754F0C42430FC1206C6120721E537B9
10059A00540F2430FC1206C61207217C0F12068F54
1005AA001207217C8D12068F1207212201815469BC
1005BA006D652044656C61793A20009005CC12067D
1005CA00FC220182456E7465722054696D65C54EC0
1005DA00756D626572009005E71206FC220180546F
1005EA00696D6520557064617465642E2E2E0079DC
1005FA004600D9FD2279047AFF00DAFDD9F9227979
10060A00FF7AFF00DAFDD9F922780579FF7AFF002F
10061A00DAFDD9F9D8F522781879FF7AFF00DAFDE0
10062A00D9F9D8F522C280C2817C2812068F7C0CA7
10063A0012068F7C0612068F7C0112068F22C28058
10064A00C281C285C284D283D282D281C281740419
10065A00120721D281C2817401120721D281C2817B
10066A007401120721C282D281C281740112072148
10067A007C2812068F7C0812068F7C0112068F7C5A
10068A0006D18F80A0C281C280C0E0ECA2E492822F
10069A00A2E59283A2E69284A2E79285D281C281E0
1006AA00A2E09282A2E19283A2E29284A2E39285DC
1006BA00C281D281C281120734D0E022C281D280A3
1006CA00C0E0ECA2E49282A2E59283A2E69284A21E
1006DA00E79285D281C281A2E09282A2E19283A2AC
1006EA00E29284A2E39285C281D281C2810000D0C3
1006FA00E022E493A3601FB40105FCD18F80F3B418
10070A00FF05FCD1C680EBB480004005FCD18F8088
10071A00E1FCD1C680DC22C0E074A604000000001F
10072A000000000070F500D0E022C0E0743604003A
10073A000000000000000070F500D0E02274A01252
10074A000781EC1207AF74A11207811207E7F709B4
10075A00DE041207CF22C2A1D2A00000000000C20C
10076A00A080E874A0120781EC1207AFE71207AF66
10077A0009DEF91207CF227A08D2A1D2A00000001E
10078A00C2A1000000C2A0335005D2A102079BC239
10079A00A1D2A0000000C2A0DAEDD2A100D2A0002E
1007AA000000C2A0227A08335005D2A10207BBC2B8
1007BA00A1D2A0000000C2A0DAEDD2A100D2A0000E
1007CA000000C2A022C2A1000000D2A0000000D2F4
1007DA00A12274A1F1811207E7F9F1CF227A08D296
1007EA00A1C2A000000000D2A0C330A101B333DA35
1007FA00F0C2A022D2A1D2A030A0FDC205C206C278
0E080A0007C20412084F1208891208C374D0E6
100818001208EF74081208EF1208E11208C374D125
100828001208EF1208A4F91208E1B4AA01227523EC
100838000075241075250675260175270175281081
10084800C201120A9C22221208C374D01208EF7443
10085800001208EFD2001208E11208C374D112087E
10086800EF1208A4C2E7C0E01208E11208C374D06E
100878001208EF74001208EFD0E01208EF1208E136
10088800221208C374D01208EF74071208EF74908C
1008980030040274801208EF1208E1227E08740006
1008A800D2A1D2A030A0FDA2A133C2A0DEF42000C4
1008B80002C2A1D2A030A0FDC2A022D207C205C2A6
1008C8000630A01230A10FD2A1D2A030A0FDC2A143
1008D8001208EDC2A022D20622C2A1D2A030A0FDE9
1008E800D2A1C2072200227E0830E705D2A1020861
1008F800FBC2A1D2A030A0FD23C2A0DEECD2A1D2BF
10090800A030A0FDC20530A102D20511EDC2A01190
10091800ED227922752900C20011C374D011EF7439
100928000011EF11E111C374D111EFE529B40902E7
10093800D20011A4F7E529B40004E7C2E7F70905D6
1009480029E529B407E511E1227C0112068F120777
10095800217C8112068F120721AB26120A2E7C2DCC
100968001206C6120721AB27120A2E7C2D1206C6C4
100978001207217C321206C61207217C301206C6E5
10098800120721AB28120A2EE525B40106120A48DF
100998000209D1B40206120A540209D1B40306129C
1009A8000A600209D1B40406120A6C0209D1B4051E
1009B80006120A780209D1B40606120A840209D17D
1009C800B40706120A900209D17CC312068F1207D7
1009D80021E52430E505D2010209E5C201541FF5DD
1009E80024FB120A2E7C3A1206C6120721AB2312E8
1009F8000A2E7C3A1206C6120721AB22120A2E7C56
100A0800201206C612072120010B7C411206C612CD
100A18000721020A257C501206C61207217C4D12B6
100A280006C612072122EB54F0C42430FC1206C675
100A3800120721EB540F2430FC1206C6120721229C
100A4800900A4F1206FC222053554E00900A5B1262
100A580006FC22204D4F4E00900A671206FC222009
100A680054554500900A731206FC2220574544004D
100A7800900A7F1206FC222054485500900A8B12D7
100A880006FC222046524900900A971206FC2220B2
100A9800534154001208C374D01208EF74081208A6
100AA800EF74AA1208EF1208E11208C374D01208F2
100AB800EF74011208EFE5231208EF300305432411
100AC8002041CE5324DFE524D2E6C2E5300102D22C
100AD800E51208EFE5251208EFE5261208EFE527ED
100AE8001208EFE5281208EF1208E12222900AFC0A
100AF8001206FC220180506C7A20456E74657220C3
100B0800746865C04461746520262054696D650069
100B1800900B1F1206FC2201C2436C6F636B2055B9
100B28007064617465642E2E2E00900B391206FCD9
100B38002201805072657373206B657973C00079E8
100B4800527C107E0612074779587C207E061207D1
100B580047795E7C307E0612074779647C407E06C2
100B6800120747796A7C507E0612074779707C60C5
100B78007E0612074779767C707E06120747797CD5
100B88007C807E0612074779827C907E0612074792
100B980079887CA07E06120747798E7CB07E061283
100BA800074779947CC07E06120747799A7CD07EE5
100BB8000312074779377CE07E0112074722E52DAB
100BC800C4452EF52DE52FC44530F52EE532B40188
100BD800147952A72D09A72E09A73179527C107EC6
100BE8000312076D22B402147955A72D09A72E09FF
100BF800A73179557C137E0312076D22B40314794B
0F0C080058A72D09A72E09A73179587C207E0304
100C170012076D22B40414795BA72D09A72E09A723
100C270031795B7C237E0312076D22B40514795E4C
100C3700A72D09A72E09A731795E7C307E031207FD
100C47006D22B406147961A72D09A72E09A731795A
100C5700617C337E0312076D22B407147964A72DD4
100C670009A72E09A73179647C407E0312076D22FC
100C7700B408137967A72D09A72E09A73179677CCF
100C8700437E0312076DB40913796AA72D09A72EAE
100C970009A731796A7C507E0312076DB410137966
100CA7006DA72D09A72E09A731796D7C537E0312F5
100CB700076DB411137970A72D09A72E09A73179EC
100CC700707C607E0312076DB412137973A72D0928
100CD700A72E09A73179737C637E0312076DB413BE
100CE700137976A72D09A72E09A73179767C707E0F
100CF7000312076DB414137979A72D09A72E09A735
100D07003179797C737E0312076DB41513797CA74B
100D17002D09A72E09A731797C7C807E0312076DE8
100D2700B41613797FA72D09A72E09A731797F7CE0
100D3700837E0312076DB417137982A72D09A72E97
100D470009A73179827C907E0312076DB418137955
100D570085A72D09A72E09A73179857C937E0312D4
100D6700076DB419137988A72D09A72E09A731791B
100D7700887CA07E0312076DB42013798BA72D09F9
100D8700A72E09A731798B7CA37E0312076DB421A7
100D970013798EA72D09A72E09A731798E7CB07EEE
100DA7000312076DB422137991A72D09A72E09A75E
100DB7003179917CB37E0312076DB423137994A71D
100DC7002D09A72E09A73179947CC07E0312076DE0
100DD700B424137997A72D09A72E09A73179977CF2
100DE700C37E0312076DB42513799AA72D09A72E81
100DF70009A731799A7CD07E0312076DB4260C853A
100E07002D3779377CE07E0112076D22E52BB45F21
100E17001A519C1205E01206137C0C12068F12075A
100E270021311A3151120613020064E52AB4001267
100E3700E52BF52D2430FC1206C6120721052A02E0
100E470000FAB40121E52BF52E2430FC1206C61258
100E570007217C1412068F120721052AE52DC445A8
100E67002EF5260200FAB40212E52BF52D2430FCEC
100E77001206C6120721052A0200FAB40331E52B30
100E8700F52E2430FC1206C61207217C1412068F99
100E97001207217C1412068F1207217C1412068F69
100EA700120721052AE52DC4452EF5270200FAB4BD
100EB7000412E52BF52D2430FC1206C61207210576
100EC7002A0200FAB40521E52BF52E2430FC120680
100ED700C61207217C1412068F120721052AE52D59
100EE700C4452EF5280200FAB40652E52B7C1012F1
100EF700068F120721B401055148020F34B40205C9
100F07005154020F34B403055160020F34B4040581
100F1700516C020F34B405055178020F34B406053D
100F27005184020F34B407055190020F34852B25E5
100F37007CC312068F120721052A0200FAB4071292
100F4700E52BF52D2430FC1206C6120721052A02CF
100F570000FAB40821E52BF52E2430FC1206C61240
100F670007217C1412068F120721052AE52DC44597
100F77002EF5240200FAB40912E52BF52D2430FCD6
100F87001206C6120721052A0200FAB40A39E52B10
100F9700F52E2430FC1206C61207217C1412068F88
100FA7001207217C1412068F1207217C1412068F58
100FB7001207217C1412068F120721052AE52DC47A
100FC700452EF5230200FAB40B1FE52BB4010DC221
100FD700017C411206C61207210200FAD2017C5099
0C0FE7001206C61207210200FA0200FAEE
00000001FF



























WORKING


1he lC uS1307 ls a real Llme clock whlch ls provldlng Lhe real Llme clock and daLe lL can
also work even when Lhe power of Lhe clrculL ls off wlLh Lhe help of Lhe baLLery 1hls Llme and
daLe ls dlsplayed on Lhe 16*2 LCu 1he user can conLrol Lhe LoLal worklng of Lhe sysLem uslng
Lhe 4*3 keypad (*#0123436789) 1he lC A189S32 ls Lhe braln of Lhe sysLem lL keeps
checklng Lhe Llme wlLh Lhe seL alarm Llmes and when Lhe Lwo are become equal Lhe
mlcroconLroller provldes a Plgh aL Lhe speclflc porL Pen due Lo Lhe speclflc acLlon of Lhe
uLn2003 lc Lhe ouLer clrculL wlll be closed and so LLu glows and Lhe buzzer beeps (1hey are
provlded only as worklng examples lnsLead of Lhe relay sysLem wlLh Lhe bell whlch works ln Ac
supply) uLn2003 ls an lc conLalns serles of double uarllngLon palr ampllflers whlch ampllfles
Lhe currenL LhaL goes Lo Lhe relay sysLem as a hlgh currenL ls requlred for Lhe worklng of a relay
When a hlgh lnpuL comes aL Lhe l/p end lL provldes a ground poLenLlal aL Lhe ouLpuL end whlch
closes Lhe clrculL conLalns Lhe relay sysLem and Lhe bell or any devlce aLLached Lo Lhe relay wlll
be swlLched Cn lf Lhe lncomlng volLage ls Low aL Lhe l/p end of uLn2003 lL wlll provlde a hlgh
lmpedance sLaLe aL Lhe ouLpuL end whlch opens Lhe ouLer clrculL loop whlch ln Lurn swlLches
Cll Lhe relay sysLem 1he varlable reslsLor connecLed Lo Lhe LCu ls used Lo ad[usL Lhe
brlghLness and conLrasL of Lhe LCu dlsplay resenLly up Lo 23 alarms can be seL uslng Lhls
clrculL lL can be modlfled Lo any number accordlng Lo Lhe avallablllLy of memory space ln Lhe
mlcroconLroller

OPERATING PROCEDURE:


SeLLlng 8eal 1lML uA1L

ulal *0 Lo Change 8eal 1lme Lhen dlal # afLer seLLlng Llme

SeLLlng Alarms

ulal *01 Lo change flrsL 8ell 1lmlngs Lhen dlal # afLer seLLlng Llme
ulal *02 Lo change second 8ell 1lmlngs Lhen dlal # afLer seLLlng Llme




ulal *23 Lo change 23Lh 8ell 1lmlngs Lhen dlal # afLer seLLlng Llme

SeLLlng Alarm uelay (ln Seconds)

ulal *26 Lo change Lhe 1lme delay ln seconds Lhen dlal # afLer enLerlng values


TIMELINE




DA1L LVLN1
12 SL1 2011 'AuLomaLlc College 8ell' ls selecLed as our mlnl pro[ecL
13 SL1 2011 CuLllne of Lhe pro[ecL prepared
13 SL1 2011 AbsLracL submlLLed
20 SL1 2011 ueslgned Lhe LoLal pro[ecL clrculLs
23 SL1 2011 rogram for mlcroconLroller ls coded
26 SL1 2011
ro[ecL ls Lrled Lo slmulaLe ln roLeus"
lallure (many parLs of Lhe coded programs needed Lo
be correcLed and modlfled)
rogram modlflcaLlon correcLlon sLarLed
27 SL1 2011
keyboard and LCu programs are changed Successfully
slmulaLed ln roLeus"
28 SL1 2011 8oughL clrculL componenLs
3 CC1 2011 Assembled Lhe componenLs on Lhe 8readboard
6 CC1 2011 Pex flle ls burned Lo Lhe mlcroconLroller chlp
8 CC1 2011
SLarLed LesLlng Lhe clrculL on 8readboard
lallure
19 CC1 2011
Successfully compleLed LesLlng of Lhe pro[ecL on Lhe
bread board
23 CC1 2011 8readboard submlLLed
31 CC1 2011 SLarLed C8 Works
2 nCv 2011 Successfully compleLed LesLlng of Lhe pro[ecL on Lhe C8
3 nCv 2011 lnlLlal submlsslon of flnal deslgn
nCv 2011 llnal Submlsslon of Lhe ro[ecL







FURTHER POSSIBILITIES &
MODIFICATIONS

resenLly up Lo 23 alarms can be seL uslng Lhls clrculL lL can be modlfled Lo any number
accordlng Lo Lhe avallablllLy of memory space ln Lhe mlcroconLroller 8aLher Lhan uslng as a
slmple college bell Lhls producL can be modlfled Lo vasL posslblllLles Lhrough some small
changes ln Lhe coded program as well as ln Lhe clrculLs As a very good example we can modlfy
Lhls sysLem Lo a LoLal real Llme home or offlce conLrol sysLem whlch can be used Lo conLrol
home/offlce elecLrlc devlces (up Lo 8 devlces can be connecLed)wlLh Llme llned conLrol AnoLher
example ls WeaLher 8ecordlng devlce lf relay sysLem ls replaced by weaLher measuremenL
sensors (up Lo 8 sensors can be connecLed) and some sllghL modlflcaLlons ln Lhe program code
we can record weaLher condlLlons for a LoLal week monLh or a year






REFERENCES


1 en.50/,.org
2 MMC 1exL books Lyla 8 uas
3 Mazldl
4 www8031pro[ecLslnfo
3 www.atmel.com
6 www.keil.com
7 www.labcenter.com
8 www.cadence.com
9 www.engineersgarage.com