📄 tvup.plm
字号:
/* filename: tvup.plm */
/* 主机通过RS485巡检40路分机 */
start:do;
$include(reg51.dcl)
declare (data,DAT,ADDRL,n,I,j,k,waittime,sdflag,sdcount) byte;
declare a(40) byte;
declare l(10) byte;
declare la(10) 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 da literally 'p13',clk literally 'p14',ale literally 'p17',
mk literally 'p15',sk literally 'p16',dal literally 'p11',
clkl literally 'p12';
declare sda literally 'p35',sclk literally 'p34';
sta24:procedure;
call time(2);
sda=1;
call time(2);
sclk=1;
call time(2);
sda=0;
call time(2);
sclk=0;
call time(2);
end sta24;
ask: procedure;
call time(2);
sclk=1;
call time(2);
sda=1;
call time(2);
do while sda=1;
end;
call time(2);
sclk=0;
call time(2);
end ask;
stop: procedure;
call time(2);
sda=0;
call time(2);
sclk=1;
call time(2);
sda=1;
call time(2);
sclk=0;
call time(2);
end stop;
shift: procedure(da);
declare (i,da) byte;
do i=0 to 7;
da=scl(da,1);
sda=cy;
call time(2);
sclk=1;
call time(2);
sclk=0;
call time(2);
end;
end shift;
read: procedure;
declare i byte;
do i=0 to 7;
call time(2);
sda=1;
call time(2);
sclk=1;
call time(2);
cy=sda;
call time(2);
dat=scl(dat,1);
call time(2);
sclk=0;
call time(2);
end;
end read;
rd24: procedure;
declare i byte;
call sta24;
call shift(0A0h);
call ask;
call shift(ADDRL);
call ask;
do i=0 to 9;
call sta24;
call shift(0a1h);
call ask;
call read;
L(i)=dat;
end;
call stop;
end rd24;
wr24: procedure;
declare i byte;
call sta24;
call shift(0A0h);
call ask;
call time(1);
call shift(addrl);
call ask;
do i=0 to 9;
call shift(L(i));
call ask;
end;
call stop;
call time(200);
end wr24;
out595: procedure;
declare k byte;
if data=0 then goto out0;
data=not data;
out0: do k=0 to 7;
data=scr(data,1);
dal=cy;
clkl=1;
clkl=0;
end;
end out595;
tvcon:procedure;
declare i byte;
do i=0 to 9;
data=la(i);
call out595;
end;
ale=0;
ale=1;
end tvcon;
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;
declare (i,n) byte;
do i=1 to 9;
n=l(i);
IF N=0AAH THEN N=0AH;
ELSE n=n mod 10;
data=aco(n);
call send595;
n=l(i);
IF N=0AAH THEN N=0AH;
ELSE n=n/10;
data=aco(n);
call send595;
end;
ale=0;
;
ale=1;
end display;
displaysd:procedure;
declare (i,n) byte;
do i=1 to 9;
n=l(i);
IF la(i)=7fH THEN
do;
n=0ah;
do k=1 to 3;
do j=1 to 40;
call time(15);
end;
do j=1 to 15;
p10=0;
call time(24);
p10=1;
call time(24);
end;
end;
end;
ELSE n=n mod 10;
data=aco(n);
call send595;
n=l(i);
if la(i)=7fh then n=0ah;
ELSE n=n/10;
data=aco(n);
call send595;
end;
ale=0;
;
ale=1;
end displaysd;
key:procedure;
declare (i,time1,j,tem) byte;
call time(100);
j=9; time1=30;
if mk=0 then
do;
do while time1>0;
tem=L(j);
L(j)=0aah;
call display;
call time(254);
call time(254);
L(j)=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;
j=j-1;
DO WHILE j=0FFH;
j=9;
END;
END;
end;
IF SK=0 THEN
DO;CALL TIME(100); /*SET KEY PROCESS*/
TIME1=30;
IF SK=0 THEN
DO;
tem=tem+1;
DO WHILE tem=41;
tem=1;
END;
END;
L(j)=tem;
END;
END;
end;
end key;
main$program:
scon=50h;
pcon=00h;
tmod=20h;
tl1=0fdh;
th1=0fdh;
tr1=1;
mk=1;sk=1;
p33=1;
ADDRL=0;
clk=0;da=0;ale=1;
CALL RD24;
do i=0 to 40;
a(i)=0;
end;
sdflag=0ffh;
P32=0;
loop:
do i=1 to 40;
P32=1;
if p33=0 then i=i or 80h;
sbuf=i;
i=i and 7fh;
do while ti=0;
end;
ti=0;
P32=0;
waittime=200;
do while ri=0;
waittime=waittime-1;
if waittime=0 then goto next;
end;
ri=0;
a(i)=sbuf;
P32=1;
sbuf=a(i);
do while ti=0;
end;
ti=0;
P32=0;
next:
end;
DO I=0 TO 9;
LA(I)=A(L(I));
END;
call tvcon;
call displaysd;
do i=0 to 40;
a(i)=0;
end;
DO I=0 TO 9;
LA(I)=0;
END;
do i=0 to 2;
call time(254);
end;
call tvcon;
call display;
do while mk=0;
call key;
ADDRL=0;
CALL WR24;
end;
goto loop;
end start;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -