AT89C52的一款电子钟参考一下C语言版r
r
i
cludereg52hr
i
cludestdiohr
voiddelayi
tar
i
toutfu
ctio
i
ta端口输出设置函数r
voidrecou
t时间计算函数r
i
talmr
sfrp00x80r
sfrp20xA0r
sfrp10x90r
sbitp130x93r
sbitp370xb7r
i
tijr
i
ttimecou
t0用于秒计时器的计数定时器每250机器周期中断一次计数4000次就达到1秒r
i
ttimecou
t20用于计时器误差的校正r
i
ttemp9l0k1mkeyo
key
umber用于时间校正的临时变量r
i
tyearmo
thdatehourmi
uteseco
dr
i
talm_houralm_mi
utealm_typealm_ru
1闹钟r
bitstopbr
bitflagbr
定义时间初始值r
year2007r
mo
th11r
date30r
hour12r
mi
ute0r
seco
d0r
alm_hour12r
alm_mi
ute0r
alm_type0默认闹钟关r
i
tcout1110X3F0X060X5B0X4F0X660X6D0X7D0X070X7F0X6F0X40r
i
tcout280XFE0XFD0XFB0XF70XEF0XDF0XBF0X7Fr
mai
r
mai
r
r
TMOD0x22r
TH00X06r
TL00X06r
PT01定时器0设定为高优先级r
PX00外部中断0设置为低优先级r
PX10r
ET01r
EX01r
EX11r
EA1r
TF00r
TR01定时器0准备开始r
p371r
while1r
r
p2cout20r
p0outfu
ctio
hour10r
delay5r
p00x00r
p2cout21r
p0outfu
ctio
hour10r
delay5r
p00x00r
p2cout22r
p0cout110r
delay7r
p00x00r
p2cout23r
p0outfu
ctio
mi
ute10r
delay5r
p00x00r
p2cout24r
p0outfu
ctio
mi
ute10r
delay5r
p00x00r
p2cout25r
p0cout110r
delay7r
p00x00r
p2cout26r
p0outfu
ctio
seco
d10r
delay5r
p00x00r
p2cout27r
p0outfu
ctio
seco
d10r
delay5r
p00x00r
ifalm_type1alm_mi
utemi
utealm_hourhouralm_ru
1判断闹钟r
alm_ru
almr
ifalm_ru
0alm_mi
utemi
utealm_ru
1r
recou
t换算时分秒r
r
r
计时中断r
voidTimer0_Overflowi
terrupt1usi
g0r
r
r
iftimecou
t24700r
r
timecou
tr
timecou
t20r
r
iftimecou
t4000r
r
timecou
tr
timecou
t2r
r
elser
r
timecou
t0r
seco
dr
r
r
显示日期r
voidi
t0i
terrupt0usi
g0中断显示日期r
r
j1000r
whilejr
r
p2cout20r
p0outfu
ctio
year1000r
delay5r
p00x00r
p2cout21r
p0outfu
ctio
year1000100r
delay5r
p00x00r
p2cout22r
p0outfu
ctio
year10010r
delay5r
p00x00r
p2cout23r
p0outfu
ctio
year10r
delay5r
p00x00r
p2cout24r
p0outfu
ctio
mo
th10r
delay5r
p00x00r
p2cout25r
p0r