Скачиваний:
20
Добавлен:
10.12.2013
Размер:
20.99 Кб
Скачать

Приложение 1.1

;---SFR----- Описание специальных регистров функций

TCON: EQU 88H;

TMOD: EQU 89H;

P4: EQU C0H;

TCK: REG C0H;

TDO: REG C1H;

TMS: REG C2H;

ENO: REG C3H;

ENI: REG C4H;

WP: REG C5H;

LTEST: REG C6H;

CIN: REG C7H;

P5: EQU 91H;

P6: EQU A1H;

BAUD: EQU 94H;

GMOD: EQU 84H;

DCON0: EQU 92H;

DCON1: EQU 93H;

DARL0: EQU C2H;

DARH0: EQU C3H;

DARL1: EQU D2H;

DARH1: EQU D3H;

SARL0: EQU A2H;

SARH0: EQU A3H;

SARL1: EQU B2H;

SARH1: EQU B3H;

BCRL0: EQU E2H;

BCRH0: EQU E3H;

BCRL1: EQU F2H;

BCRH1: EQU F3H;

RFIFO: EQU F4H;

TFIFO: EQU 85H;

ADR0: EQU 95H;

ADR1: EQU A5H;

ADR2: EQU B5H;

ADR3: EQU C5H;

AMSK0: EQU D5H;

AMSK1: EQU E5H;

GREN: REG E9H;

RDN: REG EBH;

DMA: REG D8H;

TEN: REG D9H;

TFNF: REG DAH;

TDN: REG DBH;

TCDT: REG DCH;

UR: REG DDH;

NOACK: REG DEH;

LNI: REG DFH;

П 1.1

EGSRV: REG C8H;

EGSRE: REG C9H;

EDMA: REG CAH;

EGSTV: REG CBH;

EDMA1: REG CCH;

EGSTE: REG CDH;

RFNE: REG EAH;

;------------------

DATAH: EQU 50H;

DATAL: EQU 51H;

;--------VAR------- Переменные

;R1-NR

;R3-NS

;R5-INSTRUCTION

;R4-LENGTH OF DATA

;------INTERUPT---- Прерывания

ORG 400H;

JMP START;

ORG 403H; Внешнее 0

IEX0:

ORG 40BH; Таймер/счетчик 1

IET0:

ORG 413H; Внешнее 1

IEX1:

ORG 41BH; Таймер/счетчик 1

IET1:

ORG 423H; Последовательный порт

IES:

ORG 42BH; GSC прием

IEGSRV: JMP GSCRV;

ORG 433H; GSC прием с ошибкой

IEGSRE: JMP GSCRE;

ORG 43BH; DMA0

IEDMA0: JMP DMA0;

ORG 443H; GSC передача

IEGSTV: JMP GSCTV;

ORG 44BH; GSC передача с ошибкой

IGSTE:

ORG 453H; DMA1

IEDMA1: JMP DMA1;

;---------START------------- Задание основных режимов работы

П 1.1

ORG 473H;

START: MOV SP,#200;

MOV PSW,#0;

MOV R0,#00000011B;

MOV R4,#0;

MOV R5,#0;

MOV R2,#10;

MOV R1,#0;

MOV R3,#0;

; SETB ENI;

; CLR ENO;

MOV BAUD,#30; ;BAUD=500 KH ( F/(BAUD +1)*8 )

MOV GMOD,#00000011B; ;HDLC, PL=1, 16-CRC, 8-ADDRESS,

;NORMAL,INTERNAL CLK

ORL PCON,#00010000B; ;/GFIEN, GAREN,

MOV DCON0,#10111000B; ;DCON0 TR;D-TFIFO NO;S-IRAM YES

MOV DCON1,#01101000B; ;DCON1 RS;D-ERAM YES;S-RFIFO NO

SETB DMA; ;DMA

MOV ADR0,#1; ;ADR

MOV ADR1,#2;

MOV ADR2,#3;

MOV ADR3,#4;

MOV AMSK0,#0; ;AMSK

MOV AMSK1,#0;

MOV DARH1,#80H;

MOV DARL1,#00H; ;DAR1=34H

MOV 30H,#10;

MOV 31H,#12;

MOV 32H,#13;

MOV 33H,#14;

; SETB F0;

CLR F0;

SETB EGSRV;

; SETB EGSRE;

; SETB EDMA0;

; SETB EGSTV;

; SETB EDMA1;

CALL RAMT;

SETB EA;

MOV P5,#0;

FF: CALL TR;

MOV R1,#18H;

П 1.1

FF3: MOV R2,#FFH;

FF2: MOV R3,#FFH;

FF1: JB F0,BEGIN;

DJNZ R3,FF1;

DJNZ R2,FF2;

DJNZ R1,FF3;

JMP FF;

;*************MAIN********************

BEGIN: ;CLR ENI;

;SETB ENI;

CALL NET;

JMP BEGIN;

;**********NET************************

NET: JNB F0,NETW;

; CALL IND;

MOV P5,#0;

CLR F0;

CALL ANFR;

CALL TR;

NETW: RET;

;___________________________________

TR: CLR EGSRV;

MOV DARH0,#0;

MOV DARL0,#TFIFO; ;DAR0=TFIFO

MOV SARH1,#0;

MOV SARL1,#RFIFO;

MOV SARH0,#0;

MOV SARL0,#30H; ;SAR0=30H

MOV DARH1,#80H;

MOV DARL1,#00H; ;DAR1=8000H

; MOV BCRH0,#0;

; MOV BCRL0,#12; ;BCR0

MOV BCRH1,#0;

MOV BCRL1,#FFH; ;BCR1

;*****COMMANDS**********

;-------MASTER---------

;-------SNRM-----------

CMD0: CJNE R5,#0,CMD1; SNRM

MOV 30H,#10;

MOV 31H,#10010011B; SNRM

MOV BCRH0,#0;

MOV BCRL0,#2;

JMP CEXIT;

П 1.1

;-------RRF------------

CMD1: CJNE R5,#1,CMD3; RRF

MOV 30H,#10;

MOV 31H,R1;

ORL 31H,#00010001B; RRF

MOV BCRH0,#0;

MOV BCRL0,#2;

JMP CEXIT;

;-------FRMR------------

CMD3: CJNE R5,#3,CMD4; FRMR

MOV 30H,#10;

MOV 31H,#10010111B; FRMR

MOV BCRH0,#0;

MOV BCRL0,#2;

MOV R5,B;

JMP CEXIT;

;-------DISC------------

CMD4: CJNE R5,#4,CMD8; DISC

MOV 30H,#10;

MOV 31H,#01010011B; DISC

MOV BCRH0,#0;

MOV BCRL0,#2;

JMP CEXIT;

;-------RRNF------------

CMD8: CJNE R5,#8,CEXIT; RRNF

MOV 30H,#10;

MOV 31H,R1;

ORL 31H,#1;

MOV BCRH0,#0;

MOV BCRL0,#2;

JMP CEXIT;

CEXIT:

CALL RFIFOC;

SETB TEN; ;TEN

SETB GREN; ;GREN

SETB EGSRV;

ORL DCON0,#1;

ORL DCON1,#1;

TRE: RET;

;---------------------------

RFIFOC: MOV A,RFIFO;

JB RFNE,RFIFOC;RFNE

RET;

;----------------------------

RFIFOD: MOV DPH,DARH1;

MOV DPL,DARL1;

RFIF1: JNB RFNE,ENDD;

CLR C;

MOV A,BCRL1;

П 1.1

SUBB A,#1;

MOV BCRL1,A;

MOV A,BCRH1;

SUBB A,#0;

MOV BCRH1,A;

MOV A,RFIFO;

MOVX @DPTR,A;

INC DPTR;

JMP RFIF1;

ENDD: CLR C;

MOV A,#FFH;

SUBB A,BCRL1;

CLR C;

SUBB A,#2;

MOV R4,A;

RET;

;**************INTERUPT****************

GSCRV:

CPL P1.7;

CALL RFIFOD;

MOV R0,#FFH;

CALL IND;

MOV P5,#0;

CLR EGSRV;

SETB F0;

RETI;

;----------------------------

GSCTV: CLR EGSTV;

CPL P1.7;

MOV R0,#FFH;

CALL IND;

MOV P5,#0;

CLR EGSTV;

; SETB F0;

RETI;

;----------------------------------------

GSCRE:

CPL P1.7;

CALL IND;

MOV P5,#0;

SETB F0;

RETI;

;------------------------------

DMA0:

CPL P1.7;

CALL IND;

П 1.1

MOV P5,#0;

SETB GREN; ;GREN

SETB F0;

RETI;

;------------------------------

DMA1:

CPL P1.7;

CALL IND;

MOV P5,#0;

SETB F0;

RETI;

;**************************

;--------IND---------------

IND:

;MOV P5,#FFH;

MOV P5,R0;

MOV R6,#FFH;

I1: MOV R7,#FFH;

I2: NOP;

NOP;

NOP;

NOP;

NOP;

DJNZ R7,I2;

DJNZ R6,I1;

MOV P5,#80H;

MOV R6,#FFH;

I3: MOV R7,#FFH;

I4: NOP;

NOP;

NOP;

NOP;

NOP;

DJNZ R7,I4;

DJNZ R6,I3;

RET;

;-----------------------

RAMT: MOV DPTR,#8000H;

MOV P5,#0;

MOV R0,#FFH;

RAMTW: MOV A,R0;

MOVX @DPTR,A;

INC DPTR;

DJNZ R0,RAMTW;

MOV DPTR,#8000H;

MOV R0,#FFH;

RAMTR: MOVX A,@DPTR;

CJNE A,0,RAMTE;

INC DPTR;

DJNZ R0,RAMTR;

; CALL IND;

П 1.1

RET;

RAMTE:

; CALL IND;

RET;

;******ANALIZ FRAME*********

ANFR:

;-------MASTER------------

MAST:

; MOV R0,#11101010B;

; CALL IND;

; MOV P5,#0;

MOV DPTR,#8001H;

MOVX A,@DPTR;

;-------SNRM--------------

MRV0: CJNE R5,#0,MRV4; SNRM

CJNE A,#01110011B,MRV0_1; UA

MOV R1,#0;

MOV R5,#1; RRF

JMP RVEX;

MRV0_1: MOV R5,#0;

JMP RVEX;

;-------DISC--------------

MRV4: CJNE R5,#4,MRV1; DISC

CJNE A,#01110011B,MRV4_1; UA

MOV R5,#0; SNRM

JMP RVEX;

MRV4_1: CJNE A,#00011111B,MRV4_2; DM

MOV R5,#0; SNRM

JMP RVEX;

MRV4_2: MOV R5,#4; DISC

JMP RVEX;

;-------RRF----------------

MRV1: CJNE R5,#1,MRV8; RRF

CJNE A,#10010111B,MRV1_1; FRMR

MOV R5,#1; RRF

JMP RVEX;

MRV1_1: JNB A.0,MRV1_2; NOT I

MOV B,R5;

MOV R5,#3; FRMR

JMP RVEX;

MRV1_2: JB A.4,MRV1_4; INF

MOV R5,#1; RRF

JMP MRV1_5;

MRV1_4: MOV R5,#8; RRNF

MRV1_5: ANL A,#00001110B;

SWAP A;

CJNE A,1,MRV1_6; NS<>NR

MOV A,R1;

ADD A,#00100000B;

MOV R1,A; NR=NR+1;

MOV R0,#11101010B;

CALL IND;

П 1.1

MOV P5,#0;

JMP RVEX;

MRV1_6: MOV B,#1;

MOV R5,#3; FRMR;

JMP RVEX;

;-------RRNF-----------

MRV8: CJNE R5,#8,RVEX; RRNF

MOV R5,#4; DISC

JMP RVEX;

RVEX:

RET;

;-------END OF ANALIZ---------

Соседние файлы в папке Колин