3 ?
T |?
!y?
3 ?
T C?y# 
?
"d 7?
?
?
?
?
L
H
Hò?
%4?¨
%4¥?
+?
%4
^
Sr ?
??8
3K?w¥
Hò?
?¨$.04/
??ü
Hò?
3¥???
??èyM1è
^"??
=?]
H
D
" - *#.
"59
訥
Hò?
.$#%45?Y
? V°¤9Db?¨%4?
!9¥
Hòè
^?
3 ???è
^i μ
z¥±¤ gb%4?
μ±ì{a??¤ ge?aúúayT×? V L
?a? V<W¨?ò?31?úú¥
L
H
Hò?
?b
?1?
?/

=cB??èyè f ??
E
M[
?é
>
b

9
easa
Ha?a?
ùa °aa
Miμ í
M?ê?
b

=é?
#$%
V
U
HWa ° ??
9b

l
Hl
H?l
H
Hò

T{μ18.
".·?μ1
7
H?
b
.05030-"*/"5"&-9L
H?ê4b

μ?3".?íD èq{Y  ??T13
?
Hò e?7i 3?1Y¨3".
μ"3".
?í
? μ?è 1?
b

VI?Zo?|
{b

??|
{ *32
9LY ??
9?a?
ù??a
Hò÷??
ù2
? VsY? èq
à
79 VsYé??
kb
%4¥e ?#5?
a
ü
%4
=?e ? ?m
U???è
^as

^a?
ù?Zoê4è
^a3?
Hò e??ía
3?¨d^
>3".a
Eé?=é?9F a9L
¤ gè
^aè÷ 71 1?í
=??èy??s
F?bmA
U
%45?
mb/
sY
a
ü
5??

(/%7
$$
°
@è÷ 7èab?7èa?èS?
=
H
V ?7
$$
??7$ì?9
H?
ˉ
?? ?7
$$
/??7[/
H3".9
H $ MD?
=?
?èyb
.05

Tê4
.055?¤?7
$$
Hê4.05030-"
H
??¤?('/%
Hê4*/5&-
H?b
428 Zo?|]
4285?
V
L
H
Hò
=?)s
¥?h?ê4B?T1
{?| 
{
q VY
V7i "I??Mb
"%j"%
_1?
ˉ¨L
9L¤ g VD
.05030-"±"
*/5&-±"
¤ gb
"4 1?êY
{ ?
¨?
LC?|s ?"%"-&¥/
?ü1?
í ?%4b
%4
êY
{ ?
%43% Z?μ
??T

T
| %?.055?¥è
ü?
P¨.05030-"
H?
H%4
^B
?

C
9L?
ù¥a
?1
êY ?
ù%4·
U
%4 z?
_9¥
H Y?
ù%4¥a
P
%4
íi
bê4*/5&-
H?
H%4?T 3%

3%D??i? ¥
??| 0&
¥?lM]b
38 
{ ?
385?9μ
??T

Tbê
.05030-"
H?
H38
^Bè
ü?|·
U? -?
ù
^
?
ù%401úè
ü
H38úè
ü·
U?
ù
38?è
ü·
U?
ù ê*/5&-
H?38?|
^B?

ü?|?183bN

T/385?DY¨3".¥

??| 8&
¥clM]b
$4

{ ?
`ù%4¥9L?
ù
=

?|A? ?1?b
*32 ?
# h
{ ?
?è
üμr VT±) ?¥?

{ ?b
àμ?Hq
@
H*32)?úE
b*32L
^
P 7
^
{ ?1 p?¤
¤èEb
3&4&5 ˉê
{
??? ??è
ü
HWv?
NT £%4μrˉêb
%4¥
=??
1?s
¥m
%4¥1/s
¥m ?m
U?3?¥¨
3".3?¥ib
L
H
Hò
HWb ° ??
93".
#¨? e?
¥3?+
y7i F?+
μ¥?3? V°¤b
HWa ° ??
9?í
HW ° ??YVM?¥
=i3? ? |
HWa
° ??
9YVM?¥
=i3?
!?
S 3?
=
? V[
^
Eé?#$%?
Tb
HW Vê4l
H?l
H
??ê4l
H?
Hl
H3?Tê1
,”}V1.b
H
Wa ° ??
93?
^

¥9
^ V`ù¥b
eò?
?3?<
H
e_°BQ?
9Hq ?÷?
H
H
W ° ? V
? pb ??3?¥?
93?μ
?
P¨Z
Eb?B???
9
HW ?M?
Hasa
e?
9?í
?
?
9ê?ú¥Hq/?
9?
?
H ?BQb?
=? ???
93??? ?B???1?
b
?1?
^ ?iV$?''¥é?
b?l
H3?¥?1?
ê?ê
H?
91l
H?
3BQ??MLl
Hsò?
93???1?ê
H
sò?
9BQ ? ??3???
?1?ê
H
e?BQb
d^
>3".
%4?3?Y¨d^
>3".?¨? ?
+
y?

ì V$) ? ??¨Td^
>
=ib
÷??
ù9 V`ùb
?
35$
L
H
HòF3"._) ? 4 ??? ?¥a1
?¥?÷b?
9?¥?
3
q VI?V
eBQ
?
?BQ?
ù??¥?
3
q VVNT?
μTê4b÷?2
?¨?_??·
UB?÷?
?
ù??b? e?
ê7i #$?'ó
¥ 
?s|W%
í
???
3Hqb
?? e?ê
%4ì
H 
=???$1?[]??è
y?

?"d -$h{b7i "¥#*5j#*5
1
Hu 7??s
yˉê#*5j#*5¥ 
F?
^
P??1>b
Zo
{ê4
?me ?m
U)s?"?¥? V¨
?êê4 ê4s
h¥
"¥
^4285
?á
3B?Zo?| 
q?7i "¥ 34j
34ê
!?b428
qê4D?
ù??
3 
?
êê4 B?
qê4zYV¨?? e?Z
o
{
?ê482& ? e?4285?
{¥ 71b
?
ù?ê4
?
ù? V*32?á
3NTBQ?
 μTBQ¥
??
q]"?7i" ??
¥ e?ê17i
#?¥1*&êb
÷??
ù
%4
e3?BQ÷??
ù1?
B?
93
?DM?¥
HW3? ?T
¥k ??3??
^?1
?
5á
3BQ?
9?b
%4
e?7i 
%4μ? e?7i 
ì ?
HW? V`
ù'
P÷??
ù9? è?b
7i "
BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0
UIP DV2 DV1 DV0 RS3 RS2 RS1 RS0
6*1÷??
ù?é?êb?6*11÷?D|
y?
3?6*11÷?Dà
 μT
=?
?
3b
%7%7%7¨? 71??ˉês
yb?
tꥷBF|u 7??i
?35$9
Hb
V

ˉ?
ù?
qZo
qb
34343434
qê4êV)
q 
?h?êB?ì?s

{ ?ê4z¥h
¨?á
3Zo 4285?
{?
ù?¨ V[

¨1*&ê
??

¨428&ê
?42"8
{

=?]
H
?i¨M]¥
q

??
?
7i #
BIT7 BIT6 BIT5 BIT4 BIOT
3
BIT2 BIT2 BIT1
SET PIE ALE
0
VIE SQW
E
DM 24/1
2
DSE
4&54&51
HW÷??èé?
e9
<
H
BQ?4&5ê ?
HW÷?$ì??? V
S
HW ° ?3?b
1*&?
ù??
jê1*&15
?[ê?
¥
q ??*325?á?@
1*&15
ì??b
"*&?
9?
?ê1*&1
???5
ì??b
428&Zo
?ê?ê?
qZoV428?
{
 1
H428?1?b
%.


Tê%.1 ]?1
Eé?
7
V
ü
^#$%
¥
b
l
Hì
TêV
ül
H?7V
ü
l
H?b
%4&11
7
H
?ê?%4&?
H
?
?+
y
¥÷?
1z¥?B
H
ù °a
HWV
".
H?M1".?%4&ê1??+
y
????
3b
7i $
BIT7 BIY6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0
IRQF PF AF VF 0 0 0 0
*32'?
# hS?êb?/
Vr
T?B??1
?
H?b
1'1*& "'"*&
6'6*&
'*32'1' ·1*& "'·"*& 6'·6*&
o1*32'1*325?
{? ??7i $[a
3&4&55?1?a
μS?ê b
,b
"'?
9?S?êo"'1V
üC
HWD?
9
HW
¥b
7'÷??
ù2
S?êb7'1V
ü÷??
ù2
b
#*"5j#*5?¨
ê91?
 ?b
7i %
BIT7 BIT6 BIT5 BIT4 BIOT3 BIT2 BIT1 BIT0
VRT 0 0 0 0 0 0 0
735
=??èy
ê
ü
H?9 ?C
V
ü
=??èy{ Db
#*5j#*5?¨
ê91?
 ?b
?q¤ gè
^
%4
Hò?
$?±¥¤ gè
^ ?m
Ub

Tê4?.05 ?1ê4?/5&-
H?ê4
%4
Hò?
¥1?9L# "4
g$?
±¥1#"-&
°¤M ó 7%4a38 e?LD
?
¥3%a8"3 e?LM ? %4¥úê1??
$? °
¥1
g ?
ê5%4¥ú
ê1??1')7 ?-1?5??
=?ò?í
¥1? ? %? )j')
 %4¥?
{
*32$¥??*/5
M óó?
4??
| %4¥428
g VI?á
3Zo
{?|b
¤ g èq
/
1%4
Hò?
$?
¥¤ g è
qL??¨
?l
H?¥d1
7
H
HW

T1#$%

S
HW1
M °
Hs
eLZo
{b
Hò?
B
e?_?

# h?
BQBZ
??
??BQ
HòA
U
6BZ
9ó?
±"d4
HWb

%4
Hò?
¥
S ???
.07%153'") 7i "1?
.07 ")%7j%7s
ˉê
.079 !%153""
*/$ %153?7i #1?
.07 "")T?÷?
?÷??ê#$%
l
H?
.079 !%135"
.07 21-)
e?í1?
$-3 "
e
.079 !%153"
.07%1-) s?í1?
$-3 "s
.079!%153"
.07%1-)
H?í1?
.07 ") 
H
.079 !%153"
.07 %1-) °?í1?
.07 "!) °
.079 %%153"
*/$ %153??í1?
.07 ") 
.079 !%153"
*$ %153?
M?í1?
.07 ") 
M
.079 !%153"
*/$ %153 ?7i "1?
.07 ") %7j%7 34j34
.079 !%153"ê?
ù?
q1 μT
?Zo
{
qL)[
*/$ %153?7i #
.07 "")
e÷?BQ
?Zo
{
l
H?
.079 !%153"
Hò 7
S?

 |%4
Hò ° ?
??
%4¥ ° ?
HòYèμ?°?
?ZE
b?

H
n51


^?÷?2
oμ
÷?2
H
?μrb
??¨°?E |

°?7i "¥6*1ê?6*1
H
÷?2
 V[b[/
^?¨°?ZEV
eà
M?
í¥
ai ?$
=?3".¥j)?í
???s?? ?/
.07 %153'") 7i "1?
.079 "!%153
8"*5+# "$$8"*56*15??÷??
8
.07 %1-!)
e1?
.07 3) |
"S
n1?
.079 "!%153 |
e

.07 !3"
?$¥
=?3".
u
*$ %153M·?
*$ 3
 [/
{
??¨?E |

?%4?? h
U?
± V[Y??
7 | ° ?
b?÷?2
??
H÷?
2

μr V[°¤ | ° ?
 ?
9
ò??
ù?93°?7i "¥6*1ê?
6*1
H
÷?2
 ° ?
Hò 8·
7? ú?
b
 i nclude <absacc.h>
/*

7è
?l */
#define CMD_START_DS12C887 0x20 /* 7 
Hò?
*/
#define CMD_START_OSCILLATOR 0x70 /* 7 ?? 
)?]?
*/
#define CMD_CLOSE_DS12C887 0x30 /*1?
Hò?
*/
/*
μ¥?ê
P¨?T b"
P¨D?T */
#define MASK_SETB_SET 0x80 /* ì?
? */
#define MASK_CLR_SET 0x7f /*
P
? */
#define MASK_SETB_DM 0x04 /*
P¨ HEXì
T
*/
#define MASK_CLR_DM 0xfb /*
P
¨ BCD

T */
#define MASK_SETB_2412 0x02 /*
P
¨ 24l
H

T */
#define MASK_CLR_2412 0xfd /*
P¨ 12l
H

T */
#define MASK_SETB_DSE 0x01 /*
P¨1
7
H */
#define MASK_CLR_DSE 0xfe /* ?
P¨1
7
H */
/* 7i 1?Y??l */
xdata char chSecondsChannel _at_ 0xdf00;
xdata char chMinutesChannel _at_ 0xdf02;
xdata char chHoursChannel _at_ 0xdf04;
xdata char chDofWChannel _at_ 0xdf06;
xdata char chDateChannel _at_ 0xdf07;
xdata char chMonthChannel _at_ 0xdf08;
xdata char chYearChannel _at_ 0xdf09;
xdata char chCenturyChannel _at_ 0xdf32;
xdata char chRegA _at_ 0xdf0a;
xdata char chRegB _at_ 0xdf0b;
xdata char chRegC _at_ 0xdf0c;
xdata char chRegD _at_ 0xdf0d;
/*f
2
ü?s */
void StartDs12c887(void);
void CloseDs12c887(void);
void InitDs12c887(void);
unsigned char GetSeconds(void);
unsigned char GetMinutes(void);
unsigned char GetHours(void);
unsigned char GetDate(void);
unsigned char GetMonth(void);
unsigned char GetYear(void);
unsigned char GetCentury(void);
void SetTime(unsigned char chSeconds,unsigned char
chMinutes,unsigned char
chHours);
void SetDate(unsigned char chDate,unsigned char chMonth,unsigned
char chYear);
/*************************************************************
f
?
?f
¨ ? ?
Hò?
yT
?¨S??
Hò?
nQ
P¨
H¨?BQ
? g?

 g?

*************************************************************/
void StartDs12c887(void)
{
chRegA = CMD_START_DS12C887;
}
/*************************************************************
f
?
?f
¨ ?1>
Hò?
?¨S?B?¨??
? g?

 g?

*************************************************************/
void CloseDs12c887(void)
{
chRegA = CMD_CLOSE_DS12C887;
}
void InitDs12c887()
{
StartDs12c887();
chRegB = chRegB | MASK_SETB_SET; /* ì?
? */
chRegB = chRegB & MASK_CLR_DM | MASK_SETB_2412 \
& MASK_CLR_DSE;
/*
P¨ BCD

Ta 24l
H

Ta?
P¨1
7
H */
chCenturyChannel = 0x21; /*
!?1 21
W@ */
chRegB = chRegB & MASK_CLR_SET; /*
P
? */
}
/*************************************************************
f
?
?f
¨ ?V
Hò?
 |
e3?
?¨S?
? g?

 g?

*************************************************************/
unsigned char GetSeconds(void)
{
return(chSecondsChannel);
}
/*************************************************************
f
?
?f
¨ ?V
Hò?
 |s3?
?¨S?
? g?

 g?

*************************************************************/
unsigned char GetMinutes(void)
{
return(chMinutesChannel);
}
/*************************************************************
f
?
?f
¨ ?V
Hò?
 |l
H3?
?¨S?
? g?

 g?

*************************************************************/
unsigned char GetHours(void)
{
return(chHoursChannel);
}
/*************************************************************
f
?
?f
¨ ?V
Hò?
 | °3?
?¨S?
? g?

 g?

*************************************************************/
unsigned char GetDate(void)
{
return(chDateChannel);
}
/*************************************************************
f
?
?f
¨ ?V
Hò?
 |3?
?¨S?
? g?

 g?

*************************************************************/
unsigned char GetMonth(void)
{
return(chMonthChannel);
}
/*************************************************************
f
?
?f
¨ ?V
Hò?
 |
M3?
?¨S?
? g?

 g?

*************************************************************/
unsigned char GetYear(void)
{
return(chYearChannel);
}
/*************************************************************
f
?
?f
¨ ?V
Hò?
 |
W@3?
?¨S?
? g?

 g?

*************************************************************/
unsigned char GetCentury(void)
{
return(chCenturyChannel);
}
/*************************************************************
f
?
?f
¨ ?
!?
Hò?
¥
HW
?¨S?
? g?
 chSecondsachMinutesachHours
^
!?
HW¥a
ê BCD
 g?

*************************************************************/
void SetTime(unsigned char chSeconds,unsigned char
chMinutes,unsigned char
chHours)
{
chRegB = chRegB | MASK_SETB_SET; /* ì?
? */
chSecondsChannel = chSeconds;
chMinutesChannel = chMinutes;
chHoursChannel = chHours;
chRegB = chRegB & MASK_CLR_SET; /*
P
?
*/
}
/*************************************************************
f
?
?f
¨ ?
!?
Hò?
¥ °
ù
?¨S?
? g?
 chDateachMonthachYear
^
!? °
ù¥a
ê BCD
 g?

*************************************************************/
void SetDate(unsigned char chDate,unsigned char
chMonth,unsigned char chYear)
{
chRegB = chRegB | MASK_SETB_SET; /* ì?
? */
chDateChannel = chDate;
chMonthChannel = chMonth;
chYearChannel = chYear;
chRegB = chRegB & MASK_CLR_SET; /*
P
? */
}
'7
qèaDe ?
?


q
H
" -?¨
3è
^ ?μ
t?531

q¥MD

E?|
{M
??"L V1? e?"d
L?¨
 aD
q}9?
?èV7
P
L
!!eb
SS
E??8
3w¥

qèaD ?
1
212o3¤

¥?? íq'
V?

E
T
V V¨??
è

LC 
ú?
T?b
12?
o

121"?
T
qèa D ?
? 
c
1? a è,aú9m
bv 
|
q
?|D1°
@èa?|b12
D12'M] uY
^  12
=
?μBo×a5¨?4úè÷¥×??b
?1+?
12é?
q9
Ho3
P¨B?7(?

[11? I?¥
9
q
{ ? V°¤V
{ ?5?
¤ ? 
bv 1? ?¨?? ?5
{ Kv
R&¥
{è
@ V z? 715a?;=5?
=
c¥
9
P¨ è,/
??oμ
q9?

1? ¥ìaèa1R; ?¨??+? V[]
???? ?
{èaD
{ ?
q ? ? 1L? ?
?′1
 μ 1è
^ ?
s ú ? ; H
H′??1? I?
{ ??|¥
 
,
q
{ ?
H12¥
{èa V? ? ?è
^1? ?
? ?
{ ?
qr??V
Bó ?′
H V|
{ 
¨? z??è a·
U§?μb
¥
=?2#ò???
V? Imbò???
?/
°?
+?
.31
bv 1? ¥
{ ?

°?¤ è,¥?
Hè ?
(
°?¤ è,¥
{èEsè ?
7(
°?
.3?
:+1
bv ¥
{ ?


°?1
{?85¥?

:
°?1
{?85¥"èB?¤è÷
:(
°?1?è÷

;((
°?1¤1

,3)
°??¨b
yTe ?
? è,üV
{ ? )
{ ? ?¥
qD?1°
@èa
H3
?¤ ?
Hè ? (a
{èE7[#sè ?
roè ?
(? ?B )
{ ¥
?
3?M
H
?? f ? V
?
3

{ ?
μ
a ¥V
,èaμs
{ ?èa
H?
Hè
? èa μ1 ;H H¥
èa′-W$L?1 èb
è 
{ ?
q?|¥??
ù??
Hè ?
¥èM

1(
; HH , ?è ??¥
ü (è
@
@è ??¥
ü (

@1
?69"NH
&;,"K.3 ( ;((
{  è
^ü ? Bè
@ ?1
?μèE
{èE
7?7èE¥
6B
¤1 ? "
r oa ¥ è
@
$
roè ?sa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