Ñòóäåíòàì > Êóðñîâûå > Ðåãèñòðàòîð äèñêðåòíûõ ñèãíàëîâ
Ðåãèñòðàòîð äèñêðåòíûõ ñèãíàëîâÑòðàíèöà: 4/5
Ïðè ÷òåíèè èç CÎÌ ïîðòà
ïðèíÿòà ñëåäóþùàÿ ðàñøèôðîâêà ïðèíèìàåìûõ áàéòîâ. Îäèí áëîê ñîñòàâëÿåò 5
áàéòîâ: ïåðâûé óïðàâëÿþùèé äàëåå èäóò 4 áàéòà ñ äàííûìè, â ñëåäóþùåé
ïîñëåäîâàòåëüíîñòè: ×àñû âêëþ÷åíèÿ êàíàëà – ìèíóòû âêëþ÷åíèÿ êàíàëà – ÷àñû
âûêëþ÷åíèÿ êàíàëà – ìèíóòû âûêëþ÷åíèÿ êàíàëà. Ïåðåäà÷à äàííûõ âåäåòñÿ â
äâîè÷íîé ôîðìå. Óïðàâëÿþùèé áàéò èñïîëüçóåò 4 ìëàäøèõ áèòà, ïåðâûå òðè íåñóò
íîìåð êàíàëà â äâîè÷íîì êîäå, ÷åòâåðòûé ïîêàçûâàåò ïîñëåäíèé êàíàë èäåò èëè
íåò (1 – ïîñëåäíèé, 0 – íå ïîñëåäíèé). Åñëè êàíàë ïîñëåäíèé, òî ïîñëå ïðèåìà 4
ñëåäóþùèõ áàéòîâ äàííûõ ñâÿçü ñ ïîðòîì ïðåêðàòèòñÿ, åñëè íåò, òî ïðîäîëæèòñÿ ñ
ïðèåìà ñëåäóþùåãî óïðàâëÿþùåãî áàéòà.
Àëãîðèòì îáðàáîòêè ïðåðûâàíèÿ áóäåò âûãëÿäåòü ñëåäóþùèì
îáðàçîì.
TF0 := 0;
R1 := R1+1;
If (R1<20) Then goto exit ;
R1 := 0;
R2 := R2+1;
If (R2<60) Then goto exit ;
R2 := 0;
R3 := R3+1;
For (i=0 to 7) do {
R0 := 20h + i*4 ;
If ( @R0+1 =R3) then if (@R0 = R4) then
P[i] :=0;
If (@R0+3 = R3) Then if (@R0+2=R4) then
P[i] :=1;};
If (R3<60) Then goto exit ;
R3 := 0;
R4 := R4+1;
If (R4<24) Then goto exit ;
R4 := 0;
Gosub Pause50; [Ïîäïðîãðàììà çàïóñêà òàéìåðà, áóäåò ïîèñàíà
äàëåå]
Return
3.2 Ïðîãðàììà íà ÿçûêå
àññåìáëåðà.
Íà ÿçûêå àññåìáëåðà ïðîãðàììà ðàçäåëåíà íà íåñêîëüêî
ïðîöåäóð çàòåì â ãëàâíîì ìîäóëå âñå ïðîöåäóðû ñâÿçûâàþòñÿ äðóã ñ äðóãîì òàê êàê
ýòî íåîáõîäèìî. Äàëåå ïðèâîäèòñÿ ïîäðîáíîå îïèñàíèå ýòèõ ïîäïðîãðàìì.
OMCS-51 MACRO ASSEMBLER VSKURS1
PAGE 1
loc obj line source
0100 1 ORG
100h
0100 75B80C 2 MOV IP,
#00001100b
0103 75A80C 3 MOV IE,
#00001100b
0106 758991 4 MOV TMOD,
#10010001b
0109 758844 5 MOV TCON,
#01000100b
010C 758000 6 MOV P0,
#0h
010F 75A000 7 MOV P2,
#0h
0112 7E05 8 MOV R6, #5h
0114 7930 9 MOV R1,
#30h
0116 8E90 10 CON: MOV P1, R6
0118 3094FD 11 JNB P1.4,
$
011B E580 12 MOV A, P0
011D F8 13 MOV R0, A
011E 75F0A0 14 MOV B,
#0A0h
0121 A4 15 MUL AB
0122 9450 16 SUBB A,
#50h
0124 A7E0 17 MOV @R1, 0E0h
0126 09 18 INC R1
0127 DEED 19 DJNZ R6,
CON
0129 E8 20 MOV A,
R0
012A 20E708 21 JB ACC.7,GRR
012D B4340C 22 CJNE A,
#34h, NORM
0130 4008 23 JC ERROR
0132 30E707 24 JNB ACC.7,NORM
0135 B4A304 25 GRR: CJNE A,
#0A3h, NORM
0138 4002 26 JC NORM
013A D2A7 27 ERROR: SETB P2.7
013C E590 28 NORM: MOV A,
P1
013E 55F0 29 ANL A,
0F0h
0140 F535 30 MOV 35h, A
0142 C299 31 INTT1: CLR TI
0144 7588FF 32 MOV TCON,
#0FFh
0147 7598DC 33 MOV SCON,
#11011100B
014A 758920 34 MOV TMOD,
#20h
014D D299 35 SETB TI
014F 3099FD 36 JNB TI,
$
0152 E599 37 MOV A,
SBUF
0154 C299 38 CLR TI
0156 B4060F 39 CJNE A,
#6h, DD
0159 F9 40 MOV R1, A
015A E7 41 MOV A,
@R1
015B C9 42 XCH A,
R1
015C 7430 43 MOV A,
#30h
015E 29 44 ADD A,
R1
015F C9 45 XCH A,
R1
0160 E7 46 MOV A,
@R1
0161 F599 47 MOV SBUF, A
0163 3099FD 48 JNB TI,
$
0166 2176 49 AJMP ENDD
0168 7936 50 DD: MOV R1, #36h
OMCS-51 MACRO ASSEMBLER VSKURS1
PAGE 2
016A 7E03 51 MOV R6, #3h
016C 8999 52 CC: MOV SBUF, R1
016E 3099FD 53 JNB TI,
$
0171 C299 54 CLR TI
0173 09 55 INC R1
0174 DEF6 56 DJNZ R6,
CC
0176 75B000 57 ENDD: MOV P3,
#0h
0179 2106 58 AJMP BEGIN
017B 00 59 NOP
0013 60 ORG 0013h
0013 120030 61 CALL INTERRUPT
0016 32 62 RETI
0017 00 63 NOP
001B 64 ORG 001Bh
001B 120053 65 CALL TIMERFULL
001E 32 66 RETI
0030 67 ORG 030h
0030 00 68 INTERRUPT: NOP
0031 858B36 69 MOV 36h,
TL1
0034 858D37 70 MOV 37h,
TH1
0037 FC8D 71 MOV R4, TH1
0039 BC7D09 72 CJNE R4,
#7Dh, OK
003C 4012 73 JC ERD
003E AC8B 74 MOV R4,
TH1
0040 BC5002 75 CJNE R4,
#50h, OK
0043 500B 76 JNC ERD
0045 C2A6 77 OK: CLR P2.6
0047 758D00 78 MOV TH1,
#0h
004A 758B00 79 MOV TL1,
#0h
004D 020052 80 JNP EX
0050 D2A6 81 ERD: SETB P2.6
0052 22 82 EX: RET
0053 00 83 TIMERFULL: NOP
0054 858B36 84 MOV 36h,
TH1
0057 858D37 85 MOV 37h,
TH1
005A D2A6 86 SETB P2.6
005C 758D00 87 MOV TH1,
#0h
005F 758B00 88 MOV TL1,
#0h
0062 22 89 RET
90 END
OMCS-51 MACRO ASSEMBLER VSKURS1
PAGE 3
SYMBOL TABLE LISTING
----------------------
name type value
ACC D ADDR 00E0H A
B D ADDR 00E0H A
BEGIN C ADDR 0106H
A
CC C ADDR 016CH A
CON C ADDR 0116H A
DD C ADDR 0168H A
ENDD C ADDR 0176H
A
ERD C ADDR 0050H A
ERROR C ADDR 013AH
A
EX C ADDR 0052H A
IE C ADDR 00A8H
A
INTERRUPT C ADDR 0030H
A
INTT1 C ADDR 0142H
A
IP C ADDR 00B8H
A
NORM C ADDR 013CH
A
OK C ADDR 0045H A
PO C ADDR 0080H A
P1 C ADDR 0090H
A
P2 C ADDR 00A0H
A
P3 C ADDR 00B0H
A
QRR C ADDR 0135H A
SBUF D ADDR 0099H A
SCON D ADDR 0098H A
TCON D ADDR 0088H A
TH1 D ADDR 008DH A
TI B ADDR 0098H.1 A
TIMERFULL C ADDR 0053H A
TL1 D ADDR 008BH A
TMOD D ADDR 0089H A
|