ev1527·¢É䣬pic½ÓÊÕµÄÔ´³ÌÐò;===============================================;Author:RATO(RT1527)RECEIVINGPROGRAM;ModifyDate:03-28-2001Version:final_v1.0;Default:PIC16C57CMainclock=4MHZ;===============================================;P=16C57C;PIC16C57isthetargetprocessor#includep16c5x.inc;Includeheaderfile;;DefinePageBase-AddressforProgram-MemoryusedPAGE_0equ0x00PAGE_1equH'0200'PAGE_2equH'0400'PAGE_3equH'0600';DefineResetVectorsPIC54equH'01FF'PIC55equH'01FF'PIC56equH'03FF'PIC57equH'07FF'ResetVectorequPIC57;DefineSpecialRegisterINDFequ0x00RTCCequ0x01PCLequ0x02STATUSequ0x03;F3RegisSTATUSReg.FSRequ0x04PORT_Aequ0x05;I/OPort-AAssignmentPORT_Bequ0x06;I/OPort-BAssignmentPORT_Cequ0x07;I/OPort-CAssignment;DefineSTATUSRegisterBitsCequ0x00;CarryBitisBit.0ofF3DCequ0x01Zequ0x02;ZeroBitisBit.2ofF3PDequ0x03TOequ0x04PA0equ0x05;16C5XStatusbitsPA1equ0x06;16C5XStatusbits;DefineOPTIONregisterbitsPS0equ0x00PS1equ0X01PS2equ0x02PSAequ0x03TOSEequ0x04TOCEequ0x05;======Define========Wequ0x00Fequ0x01nullequ0x00;#DEFINECSPORTA,0#DEFINECLKPORTA,1#DEFINEDIOPORTA,2#DEFINERFINPORTA,3;#DEFINELRNLEDPORTB,5#DEFINELRNKEYPORTB,0#DEFINEK0PORTB,1#DEFINEK1PORTB,2#DEFINEK2PORTB,3#DEFINEK3PORTB,4#DEFINESPPORTB,6;#DEFINESTRPORTC,0#DEFINED_FFPORTC,1#DEFINECKPORTC,2;;++++++++++++++++++++++++++++++++++++++++;DefineBANK_0RegisterforProgramused.;++++++++++++++++++++++++++++++++++++++++JUMP_Fequ0x08FLAGequ0x09#DEFINEKEYRPFLAG,7#DEFINERECERRFLAG,5#DEFINELRN_FFLAG,6#DEFINERE_LRNFLAG,4#DEFINETMPFLAG,2;------------------------TCNT0equ0x0ATCNT10equ0x0BTCNT11equ0x0CBIT_CNTequ0x0DDELAY_DATAequ0x0ERTCNTLequ0x0FRTCNTHequ0x10H_LEVELequ0x11;highpulsedurationL_LEVELequ0x12;lowpulsedurationRECB33B40equ0x13RECB25B32equ0x14RECB17B24equ0x15RECB09B16equ0x16RECB01B08equ0x17H_TIMEequ0x18L_TIMEequ0X19TEMPequ0X1AR1equ0X1CR2equ0X1DTMP7equ0x1EOUTBYTequ0x1FKEYFLAGEQU0X1BDECR3340EQUH_TIMEDECR2532EQUL_TIMEDP_IndexequDELAY_DATARD1EQUBIT_CNTRD2EQUR1LD1EQUR2LD2EQUDELAY_DATAR7EQUBIT_CNTd0EQUH_TIMEd1EQUL_TIMEpd33d40EQUR1pd25d32EQUR2pd17d24EQUOUTBYTpd09d16EQUH_TIMEpd01d08EQUL_TIMEcatch_timeEQUJUMP_FADDR3340EQU0X30ADDR2532EQU0X31ADDR1724EQU0X32ADDR0916EQU0X33ADDR0108EQU0X34DEC3340EQU0X35DEC2532EQU0X36;;-----EEPROMREGISTERDEFINE-------TMP1EQUH_LEVELTMP2EQUL_LEVELEEPADDREQUDELAY_DATA#DEFINER1_FLAGJUMP_F,4#DEFINER2_FLAGJUMP_F,5#DEFINER3_FLAGJUMP_F,6#DEFINER4_FLAGJUMP_F,7;TRISBWREQUB'11111000'TRISBRDEQUB'11111100'IDCODEEQUB'01001001';===============================================;PAGE-0BASE-EEPADDRFORPROGRAMMEMORY;===============================================ORG0X00GOTORESET0;===============================================TST_TIME0BSFSTATUS,PA0CALLTST_TIME1BCFSTATUS,PA0RETLW00H;===============================================INIT_PROINIT_PORTMOVLWB'00000110';Fop/128tortccOPTIONMOVLWB'00000000'TRISPORTCCLRFPORTAMOVLWB'00000011'TRISPORTBMOVLWB'00111100'MOVWFPORTBMOVLWB'1000';clralloutputTRISPORTAMOVLWTRISBRDTRISPORTAMOVLW0XFFMOVWFTMP7MOVLW0X02MOVWFcatch_timeRETLW00H;===============================================RESET0CALLINIT_PRO;afterresetRESET_ALLCLRFTCNT0CLRFKEYFLAGBCFTMPCLRFTEMPCLRFJUMP_F;===============================================CLRFRTCCKEYSCANKEYSCAN_COCLRFTCNT0BTFSSLRNKEYGOTO$+3BSFSTATUS,PA0GOTOTEST_LRNMOVLW0X02MOVWFcatch_timeBSFSTATUS,PA0GOTORECEIVE0SCENDGOTOKEYSCAN_CO;************************************************ORG200H;================================================TST_TIME1TST_RTCCP1CLRWDTBTFSSRTCC,7RETLW00HBCFRTCC,7INCFTCNT0,FINCFSZTCNT10,FGOTOINC_RTIME2INCFTCNT11,FINC_RTIME2INCFSZRTCNTL,FRETLW00HINCFRTCNTH,FRETLW00H;-----------------------------------------------SENDCCLRWDTMOVLWB'11111000'ANDWFPORTA,FMOVLWTRISBWRS1TRISPORTAGOTO$+1BSFCSBSFSTATUS,CMOVLW.9MOVWFBIT_CNTSENDC2SKPCBCFDIOSKPNCBSFDIOGOTO$+1RLFOUTBYT,FBSFCLKGOTO$+1GOTO$+1BCFCLKDECFSZBIT_CNT,FGOTOSENDC2BCFDIOBTFSCR1_FLAGGOTOSENDC_R1BTFSCR2_FLAGGOTOSENDC_R2BTFSCR3_FLAGGOTOSENDC_R3GOTOSENDC_R4;------------------------------------------------EECLEARCLRFTMP1CLRFTMP2EEWRITEMOVLW30H;EEPROMWRITEENABLEMOVWFOUTBYTCLRFJUMP_FBSFR1_FLAGGOTOSENDCSENDC_R1BCFCSWRITE1MOVFWEEPADDRMOVWFOUTBYTBSFOUTBYT,6CLRFJUMP_FBSFR2_FLAGGOTOSENDCSENDC_R2MOVLW.16MOVWFBIT_CNTWRITE2BTFSSTMP1,7BCFDIOBTFSCTMP1,7BSFDIOGOTO$+1RLFTMP2,FBSFCLKGOTO$+1RLFTMP1,FBCFCLKDECFSZBIT_CNT,FGOTOWRITE2BCFCSMOVLWTRISBRDTRISPORTABSFCSWRITE5BTFSSDIOGOTOWRITE5WRITE6BCFCSCLRFJUMP_FBSFR3_FLAGGOTOSENDCSENDC_R3BCFCSINCFEEPADDR,FRETLW0H;------------------------------------------------EEREADMOVFWEEPADDRMOVWFOUTBYTBSFOUTBYT,7CLRFJUMP_FBSFR4_FLAGMOVLWTRISBRDGOTOSENDCSENDC_R4MOVLWTRISBRDTRISPORTAMOVLW.16MOVWFBIT_CNTREAD0BSFCLKRLFTMP2,FBCFTMP2,0BTFSCDIOBSFTMP2,0BCFCLKRLFTMP1,FDECFSZBIT_CNT,FGOTOREAD0BCFCSRETLW0H;===============================================DELAY_150USMOVLW.43DELAY_TPGOTOSHORT_DELAYDELAY_50USMOVLW.10NOPSHORT_DELAYMOVWFDELAY_DATADELAY_LPDECFSZDELAY_DATA,FGOTODELAY_LPRETLW00HCHK_HIBCFRECERRBCFSTATUS,CMOVLW.239ADDWFH_LEVEL,WBTFSSSTATUS,CGOTOCHK_LOWMOVLW.224ADDWFH_LEVEL,WBTFSCSTATUS,CGOTOREC_ERRSET_HICLRFH_LEVELCLRFL_LEVELBSFSTATUS,CTRANS_DATARRFRECB33B40,FRRFRECB25B32