📄 colock.plm
字号:
start:do;
$include(reg51.dcl)
declare (sclk,io,rst) bit at (0b3h) register;
declare (command,data,n,temp1,num) byte;
declare a(9) byte at (30h);
/* 1.5 inch led bcd code */
/* declare aco(11) byte constant (7bh,41h,0b3h,0e3h,0c9h,0eah,*/
/* 0fah,43h,0fbh,0ebh,00h); */
/* declare aco(11) byte constant (0fch,60h,0dah,0f2h,66h,0b6h,0beh,
0e0h,0feh,0f6h,00h); */
declare aco(11) byte constant (0fdh,60h,0dah,0f2h,66h,0b6h,0beh,
0e0h,0feh,0f6h,00h);
declare week(11) byte constant (01h,02h,04h,08h,10h,20h,40h,
08h,0h,0h,0h);
declare da literally 'p15',clk literally 'p16',ale literally 'p17',
mk literally 'p11',sk literally 'p12',hzd literally 'p13',
hzclk literally 'p14',hzale literally 'p10';
declare temp(32) byte;
declare hz1(224) byte constant (00H,00H,00H,00H,00H,00H,00H,00H,
00H,00H,00H,00H,00H,04H,0ffH,0feH,
00H,00H,00H,00H,00H,00H,00H,00H,
00H,00H,00H,00H,00H,00H,00H,00H,
/*HZ2*/ 00H,00H,00H,00H,00H,10H,3fH,0f8H,
00H,00H,00H,00H,00H,00H,00H,00H,
00H,00H,00H,00H,00H,00H,00H,04H,
0ffH,0feH,00H,00H,00H,00H,00H,00H,
/*hz3*/ 00H,00H,00H,08H,7fH,0fcH,00H,00H,
00H,00H,00H,00h,00H,10H,3fH,0f8H,
00H,00H,00H,00H,00H,00H,00H,00H,
00H,04H,0ffH,0feH,00H,00H,00H,00H,
/*hz4*/ 00H,00H,00H,04H,7fH,0feH,44H,44H,
44h,44h,44h,44h,44h,44h,44h,44h,
44h,44h,44h,44h,48h,3ch,50h,04h,
40h,04h,7fh,0fch,40h,04h,00h,00h,
/*hz5*/ 00H,00H,00H,08H,7FH,0FCH,02H,00H,
02H,00H,02H,00H,02H,10H,3FH,0F8H,
04H,10H,04H,10H,04H,10H,04H,10H,
08H,10H,08H,10H,7FH,0FEH,00H,00H,
/*hz6*/ 00H,00H,04H,00H,02H,00H,03H,00H,
01H,04H,0FFH,0FEH,00H,00H,00H,00H,
04H,40H,0CH,20H,08H,10H,10H,18H,
10H,0CH,20H,0CH,40H,04H,00H,00H,
/*hz7*/ 00H,10H,1FH,0F8h,10H,10H,10H,10H,
10H,10H,10H,10H,10H,10H,1FH,0F0H,
10H,10H,10H,10H,10H,10H,10H,10H,
10H,10H,1FH,0F0H,10H,10H,00H,00H);
clear:procedure;
sclk=0;io=0;rst=0;
end clear;
send1302:procedure(comm);
declare (i,comm) byte;
do i=0 to 7;
comm=scr(comm,1);
io=cy;
call time(1);
sclk=0;
call time(1);
sclk=1;
end;
end send1302;
wbyt1:procedure(com,dat);/*字节写过程*/
declare (com,dat) byte;
call clear;
rst=1;
call send1302(com);
call send1302(dat);
call clear;
end wbyt1;
wbyt8:procedure;/*时钟多字节突发模式写过程*/
declare j byte;
call clear;
a(7)=A(6);a(6)=a(0);
rst=1;
call send1302(command);
do j=1 to 8;
call send1302(a(j));
end;
call clear;
end wbyt8;
RBYT1:PROCEDURE;
DECLARE I BYTE;
CALL CLEAR;
RST=1;
call send1302(0c1h);
IO=1;
DO I=0 TO 7;
SCLK=1;
SCLK=0;
CY=IO;
N=SCR(N,1);
END;
A(8)=N;
CALL CLEAR;
END RBYT1;
rbyt8:procedure;/*时钟多字节突发模式读过程*/
declare (i,j) byte;
call clear;
rst=1;
call send1302(command);
io=1;
do j=1 to 8;
do i=0 to 7;
sclk=1;
call time(1);
sclk=0;
cy=io;
n=scr(n,1);
end;
a(j)=n;
end;
call clear;
a(0)=a(6);a(6)=A(7);
a(0)=a(0) and 0fh;
if a(0)>6 then a(0)=0;
CALL RBYT1;
end rbyt8;
send595:procedure;
declare k byte;
do k=0 to 7;
data=scr(data,1);
da=cy;
clk=1;
clk=0;
end;
end send595;
display:procedure; /*jieya,yima,fasong*/
declare (i,n) byte;
if a(0)>6 then a(0)=0;
n=a(0) and 0fh; /* send week */
data=week(n);
call send595;
do i=1 to 5; /* send second,minute,hour */
n=a(i); /* date,month */
n=n and 0fh;
data=aco(n);
call send595;
n=a(i);
n=shr(n,4);
data=aco(n);
call send595;
end;
ale=0;
ale=1;
end display;
beginset:procedure;
a(0)=06h;a(1)=58h;a(2)=59h;a(3)=23h;
a(4)=30h;a(5)=06h;a(6)=97h;a(7)=00;
a(8)=19h; /* set date/time (1997,7,1,8:00:00,week 3) */
call wbyt1(8eh,0); /* write enable*/
call wbyt1(80h,00h);/* start colock */
call wbyt1(0beh,0abh);/*两个二极管与8K电阻串联充电*/
command=0beh; /* write colock/date */
call wbyt8;
call wbyt1(0c0h,a(8));
call wbyt1(8eh,80h); /* set write protect bit */
end beginset;
hz:procedure(wek);
declare (m,I,J,K,wek) byte;
do m=0 to 31;
temp(m)=hz1(m+32*WEK);
end;
do m=0 to 15;
k=m*2;
do j=k to k+1;
temp1=temp(j);
do i=0 to 7;
temp1=scl(temp1,1);
hzd=cy;
hzclk=1;
hzclk=0;
end;
end;
hzale=1;
hzale=0;
end;
end hz;
hz0:procedure;
declare (m,I,J,K) byte;
do m=0 to 15;
k=m*2;
do j=k to k+1;
do i=0 to 7;
cy=0;
hzd=cy;
hzclk=1;
hzclk=0;
end;
end;
hzale=1;
hzale=0;
end;
end hz0;
key:procedure;
declare (i,time1,k1,tem) byte;
call time(100);
k1=7;time1=30;
if mk=0 then
do;
do while time1>0;
week: if k1=0 then
do;
do i=0 to 5;
call hz(a(0));
end;
do i=0 to 3;
call hz0;
end;
end;
tem=a(k1);
if k1=7 then tem=a(8);
a(k1)=0aah;
if k1=7 then a(8)=0aah;
call display;
call time(254);
call time (254);
a(k1)=tem;
if k1=7 then a(8)=tem;
call display;
call time(254);
call time(254);
call time(254);
time1=time1-1;
if mk=0 then
do;call time(100); /*MOD KEY PROCESS*/
TIME1=30;
IF MK=0 THEN
DO;
k1=k1-1;
DO WHILE K1=0FFH;
K1=7;
END;
END;
end;
IF SK=0 THEN
DO;CALL TIME(100); /*SET KEY PROCESS*/
TIME1=30;
IF SK=0 THEN
DO;
tem=tem+1;
tem=dec(tem);
DO CASE K1;
DO WHILE tem=7;/*week*/
tem=0;
END;
DO WHILE tem=60H;/*scond*/
tem=0;
END;
DO WHILE tem=60H;/*minute*/
tem=0;
END;
DO WHILE tem=24H;/*hour*/
tem=0;
END;
DO WHILE tem=32H;/*date*/
tem=1;
END;
DO WHILE tem=13H;/*month*/
tem=1;
END;
DO while tem=100h; /* YEAR */
tem=00;
END;
DO WHILE TEM>=21H;
TEM=19H;
END;
END;
A(K1)=tem;
if k1=7 then a(8)=tem;
END;
END;
END;
END;
end key;
main$program:
mk=1;sk=1;p32=1;
if sk=0 then call beginset;
clk=0;da=0;ale=1;hzd=1;
hzclk=0;hzale=1;p32=0;
loop:
do while mk=1 ;
if a(0)>6 then a(0)=0;
call hz(a(0));
command=0bfh;
call rbyt8;
call display;
do while mk=0;
call key;
call wbyt1(8eh,0);
command=0beh;
call wbyt8;
CALL wbyt1(0C0H,A(8));
call wbyt1(8eh,80h);
end;
end;
goto loop;
end start;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -