PIC單片機(jī)應(yīng)用開發(fā)典型模塊-第八章程序_第1頁
PIC單片機(jī)應(yīng)用開發(fā)典型模塊-第八章程序_第2頁
PIC單片機(jī)應(yīng)用開發(fā)典型模塊-第八章程序_第3頁
PIC單片機(jī)應(yīng)用開發(fā)典型模塊-第八章程序_第4頁
PIC單片機(jī)應(yīng)用開發(fā)典型模塊-第八章程序_第5頁
已閱讀5頁,還剩31頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

(1)16×16位定點(diǎn)數(shù)加、減法程序LISTp=16f877INCLUDEp16f877.incACCALOEQU20;寄存加數(shù)或減數(shù)低8位ACCAHIEQU21;寄存加數(shù)或減數(shù)高8位ACCBLOEQU23;寄存被加數(shù)或被減數(shù)低8位ACCBHIEQU24;寄存被加數(shù)或被減數(shù)高8位ORG0X0000STARTGOTOMAIN*雙字節(jié)省辦法程序,入口地點(diǎn)ACCB-ACCA,出口地點(diǎn)ACCB*D_subCALLNEG_A;求ACCA的補(bǔ)碼雙字節(jié)加辦法程序,入口地點(diǎn)ACCB+ACCA,出口地點(diǎn)ACCBD_add

MOVF

ACCALO,0

;ACCB

和ACCA低半字節(jié)相加ADDWFBTFSCINCFMOVF

ACCBLOSTATUS,CACCBHIACCAHI,0

;

有進(jìn)位否?;有,ACCB高字節(jié)加1,再加;ACCA、ACCB高半字節(jié)相加

ACCAHIADDWF

ACCBHIRETURN

;子程序返回;ACCA取補(bǔ)子程序NEG_A

INCF

COMF

ACCALOACCALO

;ACCALO取反加

1BTFSCDECFCOMF

STATUS,ZACCAHIACCAHI

;低8位有進(jìn)位嗎?;有,ACCAHI減1,再取反;否則ACCAHI直接取反RETURN

;

子程序返回(2)16×16位定點(diǎn)數(shù)乘法程序LISTp=16f877INCLUDEp16f877.incACCALOEQU20;寄存乘數(shù)低8位ACCAHIEQU21;寄存乘數(shù)高8位ACCBLOEQU23;寄存被乘數(shù)低8位和乘積第16~23位ACCBHIEQU24;寄存被乘數(shù)高8位和乘積第24~31位ACCCLOEQU26;寄存乘積低8位ACCCHIEQU27;寄存乘積高8位ACCDLOEQU28;臨時寄存器ACCDHIEQU29;臨時寄存器TEMPEQU2A;臨時寄存器SIGNEQU2B;寄存乘積的符號ORG0X0000STARTGOTOMAINORG0X0100D_mpyCALLS_SIGN;求取乘積的符號,并對負(fù)數(shù)取補(bǔ)CALLSETUP;調(diào)用子程序,將ACCB的值送ACCDINCFTEMPCLRFACCCHI;清ACCCCLRFACCCLOMLOOPBCFSTATUS,C;清進(jìn)位位RRFACCDHI;ACCD右移RRFACCDLOBTFSCSTATUS,C;判斷是否需要相加CALLD_add;加乘數(shù)至ACCB,見加法程序BCFSTATUS,C;清進(jìn)位位RRFACCBHI;右移部分乘積RRFACCBLORRFACCCHIRRFACCCLODECFSZTEMP;乘法達(dá)成否?GOTOMLOOP;否,持續(xù)求乘積BTFSSSIGN,7;是,確定乘積的符號GOTOOVER;為正,乘法結(jié)束COMFACCCLO;為負(fù),乘積取補(bǔ)INCFACCCLOBTFSCSTATUS,ZDECFACCCHICOMFACCCHIBTFSCSTATUS,ZNEG_BDECFACCBLOCOMFACCBLOBTFSCSTATUS,ZDECFACCBHICOMFACCBHIOVERRETURN;子程序返回SETUPMOVLW15;初始化TEMP寄存器MOVWFTEMPMOVFACCBHI,0;ACCB送ACCDMOVWFACCDHIMOVFACCBLO,0MOVWFACCDLOCLRFACCBHI;清ACCBCLRFACCBLORETURN;子程序返回S_SIGNMOVFACCAHI,0;ACCAHI異或ACCBHI,結(jié)果送SIGN單元XORWFACCBHI,0MOVWFSIGNBTFSSACCBHI,7;ACCB為負(fù)嗎?GOTOCHEK_A;否,檢查ACCACALLNEG_B;是,求取ACCB絕對值CHEK_ABTFSCACCAHI,7;ACCA為負(fù)嗎?CALLNEG_A;ACCA為負(fù),求取ACCA絕對值,RETURN;ACCA和ACCB均為正,返回(3)16×16位定點(diǎn)數(shù)除法程序LISTp=16f877INCLUDEp16f877.incACCALOEQU20;寄存除數(shù)低8位ACCAHIEQU21;寄存除數(shù)高8位ACCBLOEQU22;寄存被除數(shù)和商的低8位ACCBHIEQU23;寄存被除數(shù)和商的高8位ACCCLOEQU24;寄存余數(shù)低8位ACCCHIEQU25;寄存余數(shù)高8位ACCDLOEQU26;臨時寄存器ACCDHIEQU27;臨時寄存器TEMPEQU28;臨時寄存器SIGNEQU29;寄存商的符號ORG0X0000STARTGOTOMAINORG0X0100D_divCALLS_SIGN;確定商的符號,并將負(fù)數(shù)取補(bǔ)CALLSETUP;初始化TEMP,將被除數(shù)移至ACCDINCFTEMPCLRFACCCHI;清余數(shù)寄存器CLRFACCCLODLOOPBCFSTATUS,C;清進(jìn)位位RLFACCDLO;被除數(shù)、余數(shù)左移1位RLFACCDHIRLFACCCLORLFACCCHIMOVFACCAHI,0;ACCCHI-ACCAHISUBWFACCCHI,0BTFSSSTATUS,Z;ACCCHI=ACCAHI?GOTONOCHKMOVFACCALO,0;是,ACCCLO-ACCALOSUBWFACCCLO,0NOCHKBTFSSSTATUS,C;ACCC>ACCA?GOTONOGOMOVFACCALO,0;是,余數(shù)減除數(shù)SUBWFACCCLOBTFSSSTATUS,CDECFACCCHIMOVFACCAHI,0SUBWFACCCHIBSFSTATUS,C;置進(jìn)位位NOGORLFACCBLO;商左移1位RLFACCBHIDECFSZTEMP;循環(huán)完成?GOTODLOOPBTFSSSIGN,7;是,確定商的符號GOTODIVOVER;為正,除法結(jié)束,跳轉(zhuǎn)到結(jié)束行COMFACCCLO;為負(fù),商和余數(shù)分別取補(bǔ)INCFACCCLOBTFSCSTATUS,ZDECFACCCHICOMFACCCHICALLNEG_B;見乘法程序中間NEG_BDIVOVERRETURN;子程序返回S_SIGNMOVFACCAHI,0;ACCAHI異或ACCBHI,結(jié)果送SIGN單元XORWFACCBHI,0MOVWFSIGNBTFSSACCBHI,7;ACCB為負(fù)?GOTOCHEK_A;否,檢查ACCACOMFACCBLO;是,ACCB取補(bǔ)INCFACCBLOBTFSCSTATUS,ZDECFACCBHICOMFACCBHICHEK_ABTFSCACCAHI,7;ACCA為負(fù)?CALLNEG_A;ACCA為負(fù),取補(bǔ)(NEG_A子程序請參見;16×16位定點(diǎn)數(shù)乘辦法程序NEG_A)RETURN;ACCA和ACCB均為負(fù),返回(4)浮點(diǎn)數(shù)加減法程序LISTp=16f877INCLUDEp16f877.incACCALOEQU20;寄存加數(shù)或減數(shù)的尾數(shù)ACCAHIEQU21EXPAEQU22;寄存加數(shù)或減數(shù)階碼ACCBLOEQU23;寄存被加數(shù)或被減數(shù)尾數(shù)以及和或差A(yù)CCBHIEQU24EXPBEQU25;寄存被加數(shù)或被減數(shù)階碼ACCCLOEQU26;臨時寄存器ACCCHIEQU27;臨時寄存器ACCDLOEQU28;臨時寄存器ACCDHIEQU29;臨時寄存器TEMPEQU2A;臨時寄存器TEMP1EQU30;臨時寄存器TIMESEQU31;臨時寄存器ORG0X000STARTGOTOMAINORG0X0100F_subCALLNEG_A;求ACCA的補(bǔ)碼,將減法變換為補(bǔ)碼加法F_addCALLSUBADJ;調(diào)子程序判斷EXPB和EXPA的大小BTFSCSTATUS,Z;參與運(yùn)算的兩個數(shù)階碼相等?GOTOPADD;是,求尾數(shù)的和BTFSCSTATUS,C;EXPB>EXPA?CALLF_swap;是,ACCB與ACCA互換MOVFEXPA,0;否,求取兩者的差值SUBWFEXPBSCLOOPCALLSHFTSR;ACCB右移規(guī)格化INCFSZEXPB;EXPB=EXPA?GOTOSCLOOP;否,持續(xù)右移MOVFEXPA,0;是,存和(差)的階碼MOVWFEXPBPADDMOVFACCAHI,0;ACCAHI或ACCBHIIORWFACCBHI,0MOVWFSIGN;存于SIGN寄存器MOVFACCBHI,0;暫存ACCBHIMOVWFEXPACALLD_add;尾數(shù)相加BTFSSSIGN,7;ACCA和ACCB有負(fù)數(shù)?BTFSCACCBHI,7;否,把和的最高位和次高位同時進(jìn)位?GOTOADD2;否,轉(zhuǎn)ADD2BTFSSACCAHI,7;ACCA為負(fù)嗎?GOTOADD3;ACCA和ACCB不同時為負(fù),轉(zhuǎn)ADD3BTFSSEXPA,7;是,ACCB為負(fù)嗎?GOTOADD3BSFSTATUS,C;ACCA和ACCB同為負(fù),帶負(fù)號右移RRFACCBHIRRFACCBLOINCFEXPBADD3CLRFACCCHI;和(差)規(guī)格化CLRFACCCLOCALLF_normRETURN;子程序返回ADD2BCFSTATUS,C;最高位次高位不同時進(jìn)位,ACCB右移INCFEXPBGOTOSHFTRSHFTSRBCFSTATUS,C;ACCB帶符號右移子程序BTFSCACCBHI,7BSFSTATUS,CSHFTRRRFACCBHIRRFACCBLORETURN;子程序返回F_swapMOVFACCAHI,0;ACCAHI、ACCBHI交換MOVWFTEMPMOVFACCBHI,0MOVWFACCAHIMOVFTEMP,0MOVWFACCBHIMOVFACCALO,0;ACCALO、ACCBLO交換MOVWFTEMPMOVFACCBLO,0MOVWFACCALOMOVFTEMP,0MOVWFACCBLOMOVFEXPA,0;EXPA、EXPB交換MOVWFTEMPMOVFEXPB,0MOVWFEXPAMOVFTEMP,0MOVWFEXPBRETURNSUBADJMOVFEXPA,0;EXPA異或EXPB,結(jié)果送C_DIVXORWFEXPB,0MOVWF

C_DIVMOVFSUBWFBTFSSRETURN

EXPA,0EXPB,0C_DIV,7

;EXPB-EXPA;EXPA和

EXPB同號?;是,進(jìn)位位的值真確反應(yīng)兩者的大小,返回BTFSS

STATUS,C

;否,進(jìn)位位的值取反GOTO

CHANGECBCF

STATUS,CRETURNCHANGECBSF

STATUS,CRETURNF_norm

MOVF

ACCBHI

;ACCB=0?BTFSS

STATUS,ZGOTO

C_normMOVF

ACCBLOBTFSC

STATUS,ZRETURN

;是,不需規(guī)格化,返回C_norm

BTFSC

ACCBHI,7;否。ACCB為負(fù)?GOTO

C_norm2C_norm1

BTFSC

ACCBHI,6;為正。規(guī)格化完成?RETURN

;ACCBHI.6=1,規(guī)格化結(jié)束CALLDECFGOTO

SHFTSLEXPBC_norm1

;否。ACCB左移;EXPB減1;從頭判斷規(guī)格化完成否?C_norm2

BTFSS

ACCBHI,6

;ACCB為負(fù)。規(guī)格化完畢否?RETURN;ACCBHI.6=0,規(guī)格化結(jié)束BCF

STATUS,CCALL

SHFTSL

;否,ACCB左移BSFDECF

EXPB

ACCBHI,7

;加符號;EXPB減1GOTO

C_norm2

;從頭判斷規(guī)格化完成否?SHFTSL

BCF

STATUS

,C

;ACCB左移子程序RLFRLFRLFRLF

ACCCLOACCCHIACCBLOACCBHIRETURN(5)浮點(diǎn)數(shù)乘法程序LISTp=16f877INCLUDEp16f877.incACCALOEQU20;寄存乘數(shù)尾數(shù)ACCAHIEQU21EXPAEQU22;寄存乘數(shù)階碼ACCBLOEQU23;寄存被乘數(shù)尾數(shù)和乘積高16位ACCBHIEQU24EXPBEQU25;寄存被乘數(shù)階碼ACCCLOEQU26;寄存乘積低16位ACCCHIEQU27ACCDLOEQU28;臨時寄存器ACCDHIEQU29;臨時寄存器TEMPEQU2A;臨時寄存器TEMP1EQU30;臨時寄存器TIMESEQU31;臨時寄存器SIGNEQU2B;存放乘積符號COUNTEQU2F;臨時寄存器ACCEHIEQU30;臨時寄存器ACCELOEQU31;臨時寄存器ORG0X0000STARTGOTOMAINORG0X0100F_mpyCALLS_SIGN;求取乘積的符號,并對負(fù)數(shù)取補(bǔ)CALLSETUP;調(diào)用子程序?qū)CCB的值送ACCDCLRFACCCHI;清ACCCCLRFACCCLOMLOOPBCFSTATUS,C;清進(jìn)位位RRFACCDHI;ACCD右移RRFACCDLOBTFSCSTATUS,C;判斷是否需要相加CALLD_add;加乘數(shù)至ACCBBCFSTATUS,C;清進(jìn)位位RRFACCBHI;右移部分乘積RRFACCBLORRFACCCHIRRFACCCLODECFSZTEMP;乘法達(dá)成否?GOTOMLOOP;否,持續(xù)循環(huán)MOVFEXPA,0;是,乘數(shù)與被乘數(shù)階碼相加,得積的階碼ADDWFEXPBMOVFACCBHI;ACCBHI=0?BTFSSSTATUS,ZGOTOFINUP;否,轉(zhuǎn)FINUPMOVFACCBLO;ACCB=0?BTFSSSTATUS,ZGOTOSHFT08;否,只有ACCBHI=0,轉(zhuǎn)SHFT08MOVFACCCHI,0;ACCB=0,將乘積左移15位MOVWFACCBHIMOVFACCCLO,0MOVWFACCBLOBCFSTATUS,CRRFACCBHIRRFACCBLOMOVLW.15;乘積階碼減15(十進(jìn)制數(shù))SUBWFEXPBGOTOFINUPSHFT08MOVFACCBLO,0;只有ACCBHI=0,乘積左移7位MOVWFACCBHIMOVFACCCHI,0MOVWFACCBLOBCFSTATUS,CRRFACCBHIRRFACCBLOMOVLW.7;乘積階碼減7SUBWFEXPBFINUPCALLF_norm;對乘積進(jìn)行規(guī)格化BTFSSSIGN,7;確定乘積的符號GOTOOVER;為正,乘法結(jié)束COMFACCCLO;為負(fù),乘積取補(bǔ)INCFACCCLOBTFSCSTATUS,ZDECFACCCHICOMFACCCHIBTFSCSTATUS,ZNEG_BDECFACCBLOCOMFACCBLOBTFSCSTATUS,ZDECFACCBHICOMFACCBHIOVERRETURN;乘法結(jié)束,子程序返回S_SIGNMOVFACCAHI,0;ACCAHI異或ACCBHI,結(jié)果送SIGNXORWFACCBHI,0MOVWFSIGNBTFSSACCBHI,7;ACCB為負(fù)?GOTOCHEK_A;否,檢查ACCACOMFACCBLO;是,ACCB取補(bǔ)INCFACCBLOBTFSCSTATUS,ZDECFACCBHICOMFACCBHICHEK_ABTFSCACCAHI,7;ACCA為負(fù)?CALLNEG_A;ACCA取補(bǔ)RETURN;返回F_normMOVFACCBHI;ACCB=0?BTFSSSTATUS,ZGOTOC_normMOVFACCBLOBTFSCSTATUS,ZRETURN;是,不需規(guī)格化,返回C_normBTFSCACCBHI,7;否。ACCB為負(fù)?GOTOC_norm2C_norm1BTFSCACCBHI,6;為正。規(guī)格化完畢?RETURN;ACCBHI.6=1,規(guī)格化結(jié)束CALL

SHFTSL

;否。ACCB左移DECFGOTO

EXPBC_norm1

;EXPB

減1;從頭判斷規(guī)格化完成否?C_norm2

BTFSS

ACCBHI,6

;ACCB

為負(fù)。規(guī)格化完成否?RETURN;ACCBHI.6=0,規(guī)格化結(jié)束BCF

STATUS,CCALL

SHFTSL

;否,ACCB左移BSF

ACCBHI,7

;加符號DECFGOTO

EXPBC_norm2

;EXPB減1;從頭判斷規(guī)格化完成否?SHFTSL

BCF

STATUS

,C

;ACCB左移子程序RLF

ACCCLORLF

ACCCHIRLF

ACCBLORLF

ACCBHIRETURN(6)浮點(diǎn)數(shù)除法程序LISTp=16f877INCLUDEp16f877.incACCALOEQU20;寄存除數(shù)的尾數(shù)ACCAHIEQU21EXPAEQU22;寄存除數(shù)的階碼ACCBLOEQU23;寄存被除數(shù)的尾數(shù)和商的尾數(shù)ACCBHIEQU24EXPBEQU25;寄存被除數(shù)和商的階碼ACCCLOEQU26;寄存余數(shù)ACCCHIEQU27ACCDLOEQU28;臨時寄存器ACCDHIEQU29;臨時寄存器TEMPEQU2A;臨時寄存器TEMP1EQU30;臨時寄存器TIMESEQU31;臨時寄存器SIGNEQU2B;寄存商的符號COUNTEQU2F;臨時寄存器ACCEHIEQU30;臨時寄存器ACCELOEQU31;臨時寄存器ORG0X0000STARTGOTOMAINORG0X0100F_divCALLS_SIGN;確定商的符號,并將負(fù)數(shù)取補(bǔ)CLRFACCCHI;初始化ACCC寄存器CLRFACCCLOCALLF_norm;規(guī)格化ACCBCLRFACCCLOCLRFACCCHICLRFTIMESMOVFACCAHI;除數(shù)為零?BTFSSSTATUS,ZGOTOFD0;否,求商MOVFACCALOBTFSCSTATUS,ZRETLW01;是,返回FD0CALLNEG_A;除數(shù)取補(bǔ)FD1MOVFACCBHI,0;ACCBHI送ACCDLOMOVWFACCDLOCALLD_add1;被除數(shù)尾數(shù)大于除數(shù)尾數(shù)?BTFSSSTATUS,CGOTOFD2RRF1BCFSTATUS,C;是,被除數(shù)右移規(guī)格化,直到小于除數(shù)為止RRFACCBHIRRFACCBLOINCFTIMESRRFACCCHIBCFSTATUS,CGOTOFD1FD2CALLDDIV;否,調(diào)用雙字節(jié)除辦法程序,求商的尾數(shù)MOVFTIMES,0;根據(jù)右移規(guī)格化次數(shù)調(diào)整ACCB階碼ADDWFEXPBMOVFEXPA,0;求商的階碼SUBWFEXPBCALLF_norm;商規(guī)格化BTFSCSIGN,7;商為負(fù)?CALLNEG_B;是,取補(bǔ)CALLNEG_A;除數(shù)復(fù)原RETURN;浮點(diǎn)數(shù)除法完成,返回DDIVMOVLW0X0F;初始化ACCDHIMOVWFACCDHIDV1BCFSTATUS,CRLFACCCLO;左移商RLFACCCHIRLFACCBLO;左移余數(shù)RLFACCBHIMOVFSTATUS,0;暫存STATUS寄存器MOVWFACCDLOMOVFACCBHI,0;ACCBHI送TEMP1MOVWFTEMP1MOVFACCALO,0;ACCB-ACCAADDWFACCBLO,0MOVWFTEMPBTFSCSTATUS,CINCFTEMP1MOVFACCAHI,0ADDWFTEMP1,0BTFSCACCDLO,0;左移余數(shù)時移出來的數(shù)為1?GOTODV2TESTCBTFSSSTATUS,C;是,再判斷ACCB尾數(shù)是否大于ACCAGOTODV3DV2MOVWFACCBHI;是,余數(shù)送ACCBMOVFTEMP,0MOVWFACCBLOINCFACCCLO;商加1DV3DECFSZACCDHI;商求取完成?GOTODV1MOVFACCCHI,0;是,將商送ACCBMOVWFACCBHIMOVFACCCLO,0MOVWFACCBLORETLW00D_add1MOVFACCALO,0;加數(shù)、被加數(shù)低半字節(jié)相加ADDWFACCBLO,0BTFSCSTATUS,C;有進(jìn)位?INCFACCDLO;ACCD低半字節(jié)加1MOVFACCAHI,0;ACCAHI+ACCDLOADDWFACCDLORETLW0;子程序返回SETUPMOVLW.15MOVWFTEMPMOVFACCBHI,0MOVWFACCDHIMOVFACCBLO,0MOVWFACCDLOCLRFACCBHICLRFACCBLORETLW0NEG_ACOMFACCALO;ACCALO取反加1INCFACCALOBTFSCSTATUS,Z;低8位有進(jìn)位嗎?DECFACCAHI;有,ACCAHI減1,再取反COMFACCAHI;否,ACCAHI直接取反RETLW0NEG_BDECFACCBLO;ACCBLO取反加1COMFACCBLOBTFSCSTATUS,Z;低8位有進(jìn)位嗎?DECFACCBHI;有,ACCBHI減1,再取反COMFACCBHI;否,ACCBHI直接取反RETLW0S_SIGNMOVFACCAHI,0;ACCAHI異或ACCBHI,結(jié)果送SIGN單元XORWFACCBHI,0MOVWFSIGNBTFSSACCBHI,7;ACCB為負(fù)?GOTOCHEK_A;否,檢查ACCACOMFACCBLO;是,ACCB取補(bǔ)INCFACCBLOBTFSCSTATUS,ZDECFACCBHICOMFACCBHICHEK_ABTFSCACCAHI,7;ACCA為負(fù)?CALLNEG_A;ACCA為負(fù),取補(bǔ)RETLW0;ACCA和ACCB均為負(fù),返回F_normMOVFACCBHI;ACCB=0?BTFSSSTATUS,ZGOTOC_normMOVFACCBLOBTFSCSTATUS,ZRETLW0;是,不需規(guī)格化,返回C_normBTFSCACCBHI,7;否。ACCB為負(fù)?GOTOC_norm2C_norm1BTFSCACCBHI,6;為正。規(guī)格化完成?RETLW

0

;ACCBHI.6=1,規(guī)格化結(jié)束CALLDECF

SHFTSLEXPB

;EXPB

;否。ACCB左移減1GOTO

C_norm1

;從頭判斷規(guī)格化完成否?C_norm2

BTFSS

ACCBHI,6

;ACCB為負(fù)。規(guī)格化完成否?RETLW

0;ACCBHI.6=0,規(guī)格化結(jié)束BCF

STATUS,CCALLBSFDECF

SHFTSLEXPB

ACCBHI,7

;否,ACCB左移;加符號;EXPB減1GOTO

C_norm2

;

從頭判斷規(guī)格化完成否?SHFTSL

BCF

STATUS

,C

;ACCB

左移子程序RLFRLFRLFRLF

ACCCLOACCCHIACCBLOACCBHIRETLW

0(7)定點(diǎn)數(shù)轉(zhuǎn)變?yōu)楦↑c(diǎn)數(shù)程序LISTp=16f877INCLUDEp16f877.incACCBLOEQU23;寄存定點(diǎn)整數(shù)和變換后浮點(diǎn)數(shù)的尾數(shù)ACCBHIEQU24EXPBEQU25;寄存變換后浮點(diǎn)數(shù)的階碼ACCCLOEQU26;臨時寄存器ACCCHIEQU27;臨時寄存器ACCDLOEQU28;臨時寄存器ACCDHIEQU29;臨時寄存器SIGNEQU2B;寄存被變換數(shù)的符號ORG0X0000STARTGOTOMAINORG0X0100DtoFCLRFSIGN;根據(jù)被變換數(shù)確定結(jié)果的符號,對負(fù)數(shù)取補(bǔ)BTFSSACCBHI,7GOTOINTF1BSFSIGN,7CALLNEG_BINTF1MOVLW.15;初始化EXPBMOVWFEXPBCLRFACCCHICLRFACCCLOCALLF_norm;對ACCB進(jìn)行規(guī)格化BTFSSSIGN,7;結(jié)果為負(fù)?GOTODtoF1CALLNEG_B;是,求補(bǔ)DtoF1RETURNF_normMOVFACCBHI;ACCB=0?BTFSSSTATUS,ZGOTOC_normMOVFACCBLOBTFSCSTATUS,ZRETLW0;是,不需規(guī)格化,返回C_normBTFSCACCBHI,7;否。ACCB為負(fù)?GOTOC_norm2C_norm1BTFSCACCBHI,6;為正。規(guī)格化完成?RETLW0;ACCBHI.6=1,規(guī)格化結(jié)束CALLSHFTSL;否。ACCB左移DECFEXPB;EXPB減1GOTOC_norm1;從頭判斷規(guī)格化完成否?C_norm2BTFSSACCBHI,6;ACCB為負(fù)。規(guī)格化完畢否?RETLW0;ACCBHI.6=0,規(guī)格化結(jié)束BCFSTATUS,CCALLSHFTSL;否,ACCB左移BSFACCBHI,7;加符號DECFEXPB;EXPB減1GOTOC_norm2;從頭判斷規(guī)格化完成否?SHFTSL

BCF

STATUS

,C

;ACCB左移子程序RLF

ACCCLORLFRLFRLF

ACCCHIACCBLOACCBHIRETLW

0(8)3字節(jié)浮點(diǎn)數(shù)變換為定點(diǎn)整數(shù)程序FtoDCLRFSIGN;清結(jié)果符號寄存器MOVFACCBHI,0BTFSSACCBHI,7;被變換數(shù)是否為負(fù)?GOTOD1BSFSIGN,7;是,SIGN.7置1CALLNEG_B;被變換數(shù)取補(bǔ)D1BTFSSEXPB,7;被變換數(shù)為正,再判階碼為負(fù)否?GOTOD2CLRFACCBHI;為負(fù),被變換數(shù)小于1,無法用定點(diǎn)數(shù)表示CLRFACCBLORETLW0D2MOVLW.16;被變換數(shù)階碼減16(十進(jìn)制數(shù))SUBWFEXPB,0BTFSSSTATUS,C;階碼小于16?GOTOD3MOVLW0XFF;階碼大于等于16,置ACCB為最大,返回MOVWFACCBHIMOVWFACCBLORETLW01D3CALLFTOW3;調(diào)用子程序?qū)⒏↑c(diǎn)數(shù)變換為定點(diǎn)數(shù)BTFSCSIGN,7;定點(diǎn)數(shù)為負(fù)?CALLNEG_B;是,取補(bǔ)RETLW0;否,返回FTOW3MOVLW.15;EXPB=15(十進(jìn)制數(shù))?SUBWFEXPB,0BTFSCSTATUS,ZRETLW0;是,返回BCFSTATUS,C;否,ACCB持續(xù)右移,EXPB加1RRFACCBHIRRFACCBLOINCFEXPBGOTOFTOW3;從頭判斷EXPB=15?(9)雙字節(jié)定點(diǎn)數(shù)至5位BCD碼變換程序LISTp=16f877INCLUDEp16f877.incACCBLOEQU23;寄存被變換的雙字節(jié)整數(shù)低8位ACCBHIEQU24;寄存被變換的雙字節(jié)整數(shù)高8位ACCCLOEQU26;寄存5位BCD碼ACCCHIEQU27ACCDLOEQU28ACCDHIEQU29TEMP

EQU

2A

;

臨時寄存器SIGN

EQU

2B

;被變換數(shù)符號寄存器ORG

0X0000START

GOTO

MAINORG

0X0100BtoBCD

CLRF

SIGN

;初始化符號寄存器BTFSS

ACCBHI,7

;被變換數(shù)為負(fù)?GOTO

LOOP1

;否,轉(zhuǎn)

BtoBCDBSF

SIGN,7

;是,存符號CALL

NEG_B

;ACCB取補(bǔ)LOOP1

BCFMOVLW

STATUS,C.16

;清進(jìn)位位

;移位計數(shù)器賦初值MOVWFCLRFCLRFCLRF

COUNTACCCHIACCCLOACCDHI

;初始化出口寄存器LOOP16

RLF

ACCBLO

;ACCB左移一位至出口寄存器RLFRLFRLFRLFDECFSZ

ACCBHIACCDHIACCCLOACCCHICOUNT

;移位計數(shù)器=0?ADJDEC

GOTORETLWMOVLWMOVWFCALL

ADJDEC0ACCDHI;指針指向FSRADJBCD

ACCDHI

;否,轉(zhuǎn)ADJDEC;是,返回;調(diào)用BCD碼校正子程序MOVLW

ACCCLO

;指針指向

ACCCLOMOVWFFSRCALLADJBCD;調(diào)用BCD碼校正子程序MOVLWACCCHI;指針指向ACCCHIMOVWFFSRCALLADJBCD;調(diào)用BCD碼校正子程序GOTOLOOP16;ACCB從頭左移ADJBCDMOVLW00X03;LSD+3>7?ADDWFINDF,0MOVWFTEMPBTFSCTEMP,3MOVWFINDF;是,LSD=LSD+3MOVLW0X30;否,MSD+3>7?ADDWFINDF,0MOVWFTEMPBTFSCTEMP,7MOVWFINDF;是,MSD=MSD+3RETLW0;返回(10)浮點(diǎn)數(shù)至5位壓縮BCD碼變換程序LISTp=16f877INCLUDEp16f877.incACCALOEQU20;臨時寄存器ACCAHIEQU21EXPAEQU22;臨時寄存器ACCBLOEQU23;寄存被變換浮點(diǎn)數(shù)尾數(shù)ACCBHIEQU24EXPBEQU25;寄存被變換浮點(diǎn)數(shù)階碼ACCCLOEQU26;臨時寄存器ACCCHIEQU27;臨時寄存器ACCDLOEQU28;臨時寄存器ACCDHIEQU29;臨時寄存器TEMPEQU2A;臨時寄存器TEMP1EQU30;臨時寄存器TIMESEQU31;臨時寄存器SIGNEQU2B;臨時寄存器COUNTEQU2F;臨時寄存器C_MULEQU2C;寄存小數(shù)點(diǎn)地點(diǎn)C_DIVEQU2D;寄存小數(shù)點(diǎn)地點(diǎn)FPOLEQU2E;寄存被變換數(shù)的符號ORG0X0000STARTGOTOMAINORG0X0100FtoBCDCLRFC_MUL;清小數(shù)點(diǎn)地點(diǎn)數(shù)寄存器CLRFC_DIVCLRFACCAHI;求取結(jié)果符號,存于FPOL.7CALLS_SIGNMOVFSIGN,0MOVWFFPOLMOVLW50;ACCA賦初值,ACCA=10(十進(jìn)制)MOVWFACCAHICLRFACCALOMOVLW04MOVWFEXPAMUl5BTFSSEXPB,7;階碼EXPB<0?GOTOMUl2;否,轉(zhuǎn)MU12MUl1CALLF_mpy;是,ACCA×10INCFC_MUL;小數(shù)點(diǎn)左移,寄存器加1GOTOMUl5;從頭判斷階碼是否小于零MUl2MOVLW.12;階碼EXPB<12?SUBWFEXPB,0BTFSCSTATUS,CGOTOMUl4;否,轉(zhuǎn)MU14MUl3CALLF_mpy;是,ACCA×10INCFC_MUL;小數(shù)點(diǎn)左移,寄存器加1GOTOMUL2;重判階碼值MUl4MOVLW.16;階碼EXPB>16?SUBWFEXPB,0BTFSSSTATUS,CGOTONEXT;否,表示階碼12≤EXPB<16,求取BCD碼值DIV1CALLFDIV;是,EXPB÷10INCFC_DIV;小數(shù)點(diǎn)右移寄存器加1GOTOMUl4;從頭判斷階碼值NEXTCALLFTOW3;調(diào)子程序,將浮點(diǎn)數(shù)變換為定點(diǎn)數(shù)CALLBtoBCD;調(diào)雙字節(jié)數(shù)到BCD碼子程序,求BCD碼MOVFACCCHI;ACCCHI=0?BTFSSSTATUS,ZRETLW0;否,返回MOVLW04;是,結(jié)果左移4次,保證ACCCHI不為0MOVWFTIMESBCFSTATUS,CMUl6RLFACCDHIRLFACCCLORLFACCCHIDECFSZTIMESGOTOMUl6MOVFC_DIV;C_DIV=0?BTFSCSTATUS,ZGOTOTEMUL;是,轉(zhuǎn)判斷C_MULDECFC_DIV;否,小數(shù)點(diǎn)右移,寄存器減1RETLW0TEMULINCFC_MUL;小數(shù)點(diǎn)左移,寄存器加1RETLW0(11)進(jìn)制碼和BCD碼變換程序LISTP=16F877INCLUDE“P16F877.INC”;---------------------------------------------------------------------#DEFINEBiTOBCD’Y'R2EQU0x20R1EQU0x2lR0EQU0x22BinHEQU0x23BinLEQU0x24CNTEQU0x25TMPEQU0x26BinBHEQU0x27BinBLEQU0x28;----------------------------------------------------------ORG0x00GOTOMAINORG0x10BiBCDMOVLW0x10;MOVWFCNT;移位次數(shù)BCFSTATUS,CCLRFR0CLRFR1CLRFR2LOOPRLFBinLRLFBinHRLFR0RLFR1RLFR2DECFSZCNTGOTOADJDECRETURNADJDECMOVLWR0;調(diào)整R0MOVWFFSRCALLADJBCDMOVLWR1;調(diào)整RlMOVWFFSRCALLADJBCDMOVLWR2;調(diào)整R2MOVWFFSRCALLADJBCDGOTOLOOPADJBCDMOVLW0x3ADDWFINDF,WMOVWFTMPMOVWFINDF;LSD=LSD+3MOVLW0x30ADDWFINDF,WMOVWFTMPMOVWFINDF;MSD=MSD+3RETURNBCDBiCLRFBinHMOVFR2,WANDLW0x0FMOVWFBinL;(BinL)=R2<3:0>CALLMPY10A;(Bin)=(Bin×10SWAPFRI,WCALLMPY10B;(Bin)=[(Bin)+R1<7:4>]×10MOVFR1,WCALLMPY10B;(Bin)=[(Bin)+R1<3:0>]*10SWAPFR0,WCALLMPY10B;(Bin)=[(Bin)+R0<7:4>]*10MOVFR0,W;(Bin)=(Bin)+R0<3:0>ANDLW0x0FADDWFBinLBTFSCSTATUS,CINCFBinHRETURNMPY10BANDLW0x0FADDWFBinLBTFSCSTATUS,CINCFBinHMPYl0ABCFSTATUS,CRLFBinL,WMOVWFBinBLRLFBinH,WMOVWFBinBHBCFSTATUS,CRLFBinLRLFBinHBCFSTATUS,CBCFSTATUS,CRLFBinLRLFBinHMOVFBinBL,WADDWFBinLBTFSCSTATUS,CINCFBinHMOVFBinBH,WADDWFBinHRETURNMAINORG0x100IFBiTOBCD=='Y’MOVLW0x7FMOVWFBinHMOVLW0xFFMOVWFBinLCALLBiBCD

;(Bin)×2——(BinB);(Bin)*8——(Bin);主程序;二進(jìn)制變換為BCD碼;結(jié)果在R2,R1,R0中ENDIFIFBITOBCD=='N'MOVLW0x6MOVWFMOVLW0x55MOVWFMOVLWMOVWFCALLBCDBiENDIFGOTO$END

R2R10x35R0

;BCD碼變換為二進(jìn)制數(shù);結(jié)果在BinH、BinL

中(12)定點(diǎn)數(shù)開方程序LIST

INCLUDEACCALOACCAHIEXPA

p=16f877p16f877.incEQUEQUEQU

0X20ACCALO+1ACCALO+2ACCBLOEQUACCALO+3ACCBHIEQUACCALO+4EXPBEQUACCALO+5ACCCLOEQUACCALO+6ACCCHIEQUACCALO+7ACCDLOEQUACCALO+8ACCDHIEQUACCALO+9TEMPEQUACCDHI+1SIGNEQUACCDHI+2SQRTLOEQUACCALOSQRTHIEQUACCAHINUMLOEQUACCDHI+4NUMHIEQUACCDHI+5COUNTEQUACCDHI+6;此方法定義的數(shù)據(jù)塊為連續(xù)層斷,只需;將第一行改變,就能夠?qū)?shù)據(jù)整塊挪動到;新的地方,為調(diào)試帶來方便,是比較推;崇的一種寄存器定義方法LUPCNTEQU.10ORG0X00GOTOMAINORG0X10INITMOVLWLUPCNTMOVWFCOUNTMOVFNUMHI,0MOVWFSQRTHIMOVFNUMLO,0MOVWFSQRTLOBCFSTATUS,CRRFSQRTHI,1RRFSQRTLO,1RETLW0DIV2BCFSTATUS,CRRFACCBHI,0MOVWFSQRTHIRRFACCBLO,0MOVWFSQRTLORETLW0SQRTCALLINITSLOOPMOVFNUMLO,0MOVWFACCBLOMOVFNUMHI,0MOVWFACCBHICALLD_DIVSCALLD_ADDCALLDIV2DECFSZCOUNT,1GOTOSLOOPRETURND_DIVSCALLSETUPCLRFACCCHICLRFACCCLODLOOPBCFSTATUS,CRLFACCDLORLFACCDHIRLFACCCLORLFACCCHIMOVFACCAHI,0SUBWFACCCHI,0BTFSSSTATUS,ZGOTONOCHKMOVFACCALO,0SUBWFACCCLO,0NOCHKBTFSSSTATUS,CGOTONOGOMOVFACCALO,0SUBWFACCCLO,1BTFSSSTATUS,CDECFACCCHI,1MOVFACCAHI,0SUBWFACCCHI,1BSFSTATUS,CNOGORLFACCBLORLFACCBHIDECFSZTEMPGOTODLOOPRETLW0SETUPMOVLW16MOVWFTEMPMOVFACCBHI,0MOVWFACCDHIMOVFACCBLO,0MOVWF

ACCDLOCLRF

ACCBHICLRF

ACCBLORETLW

0NEG_A

COMF

ACCALO,1D_ADD

INCFBTFSCDECFCOMFRETLWMOVFADDWFBTFSCINCFMOVFADDWFRETLW

ACCALO,1STATUS,ZACCAHI,1ACCAHI,10ACCALO,0ACCBLO,1STATUS,CACCBHI,1ACCAHI,0ACCBHI,10(13)浮點(diǎn)數(shù)開方程序LIST

P=16f877C_DIV

INCLUDEACCALOACCAHIEXPAACCBLOACCBHIEXPBACCCLOACCCHIACCDLOACCDHITEMPTEMP1TIMESSIGNCOUNTC_MULFPOL

EQU

p16f877.incEQUEQUEQUEQUEQUEQUEQUEQUEQUEQUEQUEQUEQUEQUEQUEQUEQU

20HACCALO+1ACCALO+2ACCALO+3ACCALO+4ACCALO+5ACCALO+6ACCALO+7ACCALO+8ACCALO+9ACCALO+0AACCALO+0BACCALO+0CACCALO+0DACCALO+0EACCALO+0FACCALO+10ACCALO+11

;符號放置位NUMLONUMHINUMMLUPCNT

EQUEQUEQUEQU

FPOL+1FPOL+2FPOL+4.10CONSTANT

C=0CONSTANTCONSTANTCONSTANT

Z=2MODEL16=1FALSE=0ORG0X0000NOPGOTOMAINORG0X0010INIT1DECFEXPB;假定迭代根的初始值為其原值的一半MOVFACCBHI,WMOVWFACCAHIMOVFACCBLO,WMOVWFACCALOMOVFEXPB,WMOVWFEXPARETLW0SQRTFMOVLWLUPCNTMOVWFCOUNTMOVFACCBHI,WMOVWFNUMHIMOVFACCBLO,WMOVWFNUMLOMOVFEXPB,WMOVWFNUMM;存儲被開方的數(shù)BTFSCACCBHI,7GOTOTIQIAN;如果被開方數(shù)是個負(fù)數(shù),則返回小數(shù)CALL

INIT1SLOOP1

MOVF

NUMLO,0MOVWF

ACCBLOMOVF

NUMHI,0MOVWF

ACCBHIMOVF

NUMM,0MOVWF

EXPBCALL

FDIVCALL

F_addCALL

INIT1DECFSZGOTO

COUNT,1SLOOP1RETURNTIQIAN

MOVLWMOVWF

0X40ACCBHICLRFACCBLOMOVLW0X80MOVWFEXPB;如果被開方數(shù)是一個負(fù)數(shù),返回一個極小的浮點(diǎn)數(shù)RETURN(14)均值濾波程序INDFEQU00H;定義INDF寄存器STATUSEQU03H;定義狀態(tài)寄存器FSREQU04H;定義FSR寄存器TRISAEQU05H;定義TRISA寄存器RP1EQU06H;定義狀態(tài)寄存器中的頁選位RP1RP0EQU05H;定義狀態(tài)寄存器中的頁選位RP0INTCONEQU0BH;定義中止寄存器PIR1EQU0CH;定義PIR中止寄存器ADRESHEQU1EH;定義ADRESH寄存器ADCON0EQU1FH;定義ADCON0寄存器ADRESLEQU9EH;定義ADRESL寄存器PIE1EQU8CH;定義PIE1寄存器ADCON1EQU9FH;定義ADCON1寄存器GIEEQU07H;定義中止寄存器中止使能位CEQU00H;定義狀態(tài)寄存器中的進(jìn)借位標(biāo)志位CZEQU02H;定義狀態(tài)寄存器中的零標(biāo)志位ZHHEQU20H;定義16位輸入高8位LLEQU21H;定義16位輸入低8位AAEQU22H;定義BCD碼最高位BBEQU23H;定義BCD碼4/3位CCEQU24H;定義BCD碼2/1位TEMPHEQU25H;定義臨時變量TEMPHTEMPLEQU26H;定義臨時變量TEMPLCOUNTEQU27H;定義計數(shù)器變量COUNTADHEQU28H;定義臨時變量ADHADLEQU29H;定義臨時變量ADLST_TEMPEQU2AH;定義臨時變量ST_TEMPW_TEMPEQU2BH;定義臨時變量W_TEMPDATA1EQU2CH;定義外循環(huán)變量DATA2EQU2DH;定義存儲外循環(huán)次數(shù)的變量COUNT2EQU08H;定義存儲內(nèi)循環(huán)次數(shù)的變量ADIEEQU06H;定義ADIEPEIEEQU06H;定義PDIEORG00HGOTOMAINORG04HGOTOINTERRETFIEMOVLW01H;初始化ADCON0MOVWFADCON0;BCFSTATUS,RP1;選擇體1BSFSTATUS,RP0;MOVLW0XFF;將RA口設(shè)置為輸入MOVWFTRISA;MOVLW0FFH;初始化ADCON1MOVWFADCON1;BSFPIE1,ADIE;開AD中止BCFSTATUS,RP1;選擇體0BCFSTATUS,RP0;CLRFPIR1;清AD中止標(biāo)志BSFINTCON,GIE;開中止BSFINTCON,PEIE;開外圍中止MOVLW00H;初始化COUNT寄存器MOVWFCOUNT;BSFADCON0,2;開ADLOOPBTFSSCOUNT,3;是否已經(jīng)采樣8次了GOTONEXT;否,等待BCFINTCON,GIE;關(guān)中止BCFADCON0,2;關(guān)ADBCFSTATUS,C;消除進(jìn)位位RRFADH;ADH/L除以2RRFADLRRFADH;ADH/L除以2RRFADLRRFADH;ADH/L除以2RRFADLMOVFADH;存儲濾波量ADHMOVWFTEMPH;MOVFADL;存儲濾波量ADLMOVWFTEMPL;CLRFADH;清ADH寄存器,為下一次作準(zhǔn)備CLRFADL;清ADL寄存器MOVLW00H;初始化COUNT寄存器MOVWFCOUNTBSFINTCON,GIE;開中止NEXTCALLDELAY;GOTOLOOP;等待INTERMOVWFW_TEMP;暫存W寄存器MOVFSTATUS,0;暫存STATUS寄存器MOVWFST_TEMPBCFSTATUS,RP1;選擇體0BCFSTATUS,RP0;BCFPIR1,6;清AD中標(biāo)志位BTFSSCOUNT,4;計數(shù)達(dá)到8?GOTONEXT1;否,采樣周期沒完,求和CLRFADH;是,新的采樣周期開始,清ADH寄存器CLRFADL;清ADL寄存器GOTORETURN1;是,則恢復(fù)現(xiàn)場,返回NEXT1BSFSTATUS,RP1;選擇體1BCFSTATUS,RP0;MOVFADRESL,0;AD采樣結(jié)果低8位送W寄存器BCFSTATUS,RP1;選擇體0BCFSTATUS,RP0;ADDWFADL;加至ADL寄存器BTFSCSTATUS,C;有進(jìn)位?INCFADH;有,加進(jìn)位位MOVFADRESH,0;加AD結(jié)果高半字節(jié)ADDWFADHINCFCOUNT;計數(shù)器自加1MOVFST_TEMP,0;恢復(fù)STATUS寄存器值MOVWFSTATUSMOVFW_TEMP,0;恢復(fù)W寄存器值RETFIE;中止返回DELAYMOVLWCOUNT1;設(shè)置外部循環(huán)的次數(shù)MOVWFDATA1;LOOP1MOVLWCOUNT2;設(shè)置內(nèi)部循環(huán)的次數(shù)MOVWFDATA2;LOOP2DECFSZDATA2,1;內(nèi)部循環(huán)變量自減1,為0則跳轉(zhuǎn)GOTOLOOP2;DECFSZDATA1,1;外部循環(huán)變量自減1,為0則跳轉(zhuǎn)GOTOLOOP1;RETURN;延時子程序返回END;源程序結(jié)束(15)中值濾波程序INDFEQU00H;定義INDF寄存器STATUSEQU03H;定義狀態(tài)寄存器FSREQU04H;定義FSR寄存器TRISAEQU05H;定義TRISA寄存器RP1EQU06H;定義狀態(tài)寄存器中的頁選位RP1RP0EQU05H;定義狀態(tài)寄存器中的頁選位RP0INTCONEQU0BH;定義中止寄存器PIR1EQU0CH;定義PIR中止寄存器ADRESHEQU1EH;定義ADRESH寄存器ADCON0EQU1FH;定義ADCON0寄存器ADRESLEQU9EH;定義ADRESL寄存器PIE1EQU8CH;定義PIE1寄存器ADCON1EQU9FH;定義ADCON1寄存器GIEEQU07H;定義中止寄存器中止使能位CEQU00H;定義狀態(tài)寄存器中的進(jìn)借位標(biāo)志位CZEQU02H;定義狀態(tài)寄存器中的零標(biāo)志位ZHHEQU20H;定義16位輸入高8位LLEQU21H;定義16位輸入低8位AAEQU22H;定義BCD碼最高位BBEQU23H;定義BCD碼4/3位CCEQU24H;定義BCD碼2/1位TEMPHEQU25H;定義臨時變量TEMPHTEMPLEQU26H;定義臨時變量TEMPLCOUNTEQU27H;定義計數(shù)器變量COUNTAD1HEQU28H;定義臨時變量AD1HAD1LEQU29H;定義臨時變量AD1LAD2HEQU2AH;定義臨時變量AD2HAD2LEQU2BH;定義臨時變量AD2LAD3HEQU2CH;定義臨時變量AD3HAD3LEQU2DH;定義臨時變量AD3LST_TEMPEQU2EH;定義臨時變量ST_TEMPW_TEMPEQU2FH;定義臨時變量W_TEMPDATA1EQU30H;定義外循環(huán)變量DATA2EQU31H;定義內(nèi)循環(huán)變量OUTHEQU32H;定義輸出高8位OUTLEQU33H;定義輸出低8位COUNT1EQU04H;定義存儲外循環(huán)次數(shù)的變量COUNT2EQU08H;定義存儲內(nèi)循環(huán)次數(shù)的變量ADIEEQU06H;定義ADIEPEIEEQU06H;定義PDIEORG00HGOTOMAINORG04HGOTOINTERRETFIEMOVLW01H;初始化ADCON0MOVWFADCON0;BCFSTATUS,RP1;選擇體1BSFSTATUS,RP0;MOVLW0XFF;將RA口設(shè)置為輸入MOVWFTRISA;MOVLW0FFH;初始化ADCON1MOVWFADCON1;BSFPIE1,ADIE;開AD中止BCFSTATUS,RP1;選擇體0BCFSTATUS,RP0;CLRFPIR1;清AD中止標(biāo)志BSFINTCO

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論