版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
基于PIC12C508DTMF拔號程序編寫分享pIC12C508DTMF拔號程序;|Name:MAIN.ASM|;|Description:DTMF-》RS232converter(forusewithPCNummerViser)|;|DetectsDTMFandringing,andtransmitstoastd.|;|RS232port,at2400baud.|;|||;++;|Platform:PIC12C508(A)(usinginternal4MHzRC-oscillator)|;|Uses:90-342W/512Wprogram-mem(all’switches’setto0/1)|;|6B/25Bdata-mem|;|Assembler:MPASM2.20(MPLAB4.00.00)|;|Comments:-|;+====================================================================+TITLE’DTMFtoRS232converter’PROCESSOR12C508__CONFIG_CP_OFF&_MCLRE_OFF&_IntRC_OSC&_WDT_ONINCLUDERADIXDEC__IDLOCSh’0104’OTPSET1;Usefactory-storedcal.-value(onOneTimeProgrammable)TMR0CLKSET1;UseTMR0externalclockat3,579545MHz(insteadofIntRC)。PARITYSET1;Useevenparity-bitwhentransmittingtotheserialport.CLIONLYSET1;TransmitsCLI(A-numbers)only.RINGSET1;Transmitsringing.IDENTTXSET1;Transmits’ident’whenpressing’***’(DTMF)。PWRUPIDSET1;Transmitsshort’ident’atpowerup.ASCIISET1;TransmitsASCII-charsinsteadofbinary:;DigitASCIIBinaryDigitASCIIBinary;00(48d)0000000099(57d)00001001;11(49d)00000001AA(65d)00001010;22(50d)00000010BB(66d)00001011;33(51d)00000011CC(67d)00001100;44(52d)00000100DD(68d)00001101;55(53d)00000101**(42d)00001110;66(54d)00000110##(35d)00001111;77(55d)00000111RingR(82d)00010000;88(56d)00001000;+++***Constants***+++IFTMR0CLK==0;InternaloscillatorOPTION_REGequb’10000001’;’Default’timer/prescalersetupENDIFIFTMR0CLK==1;ExternalTMR0source(3,579545MHz)OPTION_REGequb’10100011’;’Default’timer/prescalersetupENDIF#defineDTMF0GPIO,0;Bit0(LSB)fromMT8870#defineDTMF1GPIO,1;Bit1fromMT8870#defineDTMF2GPIO,3;Bit2fromMT8870/_Ring-detector#defineDTMF3GPIO,4;Bit3fromMT8870/TxD-output(high=sPACe)#defineDTMFOKGPIO,5;DTMFdetected,andreadyatDTMF0-3;+++***Variabledeclaration***+++cblock0ChDTMFvalidentvalmisctemp1,temp2,teMP3;Temp-variablesendc#defineCLIPmisc,0;SetwhenCLIPdetected#defineCLIPendmisc,1;SetbyCLIPdetwhen#received#defineIdentOKmisc,2;Setwhen’ident’detected(***);+++***Resetvector***+++ORG0hrst_vector:MOVwfOSCCAL;Setoscillatorcalibration.callinitIFPWRUPID==1gotopwrupidentpwrupidentreturn:ENDIFgotomain;+++***Identity(located’low’becauseofnoCP《64b)***+++identtable:IFIDENTTX==1addwfPCL,F(xiàn)dt“+++PCNummerViser+++”,13dt“Firmwarev1.04”,13,13dt“JaCOBBlichfELDt’98”,13,13,13,0ENDIFpwrupidenttable:IFPWRUPID==1addwfPCL,F(xiàn)dt“DTMFTORS232”,60,“0104”,62,0ENDIF;+++***Initialization***+++init:;SetupI/O-direction(GP0-3,5=input,GP4=output)MOVlwb’11101111’trisGPIO;TxD=Space(GP4=low)MOVlwb’00000000’MOVwfGPIO;EnableportBpull-up,dISAblewake-uponPINchange;SetupT0=inc.oneitherOSC.orTMR0,prescaler=4/16(dependsonTMR0CLK)clrwdtMOVlwOPTION_REGoptionclrfmiscclrfidentvalretlw0;+++***Power-upidentitytransmission***+++IFPWRUPID==1pwrupident:MOVlw4;waitapprox.1secondMOVwftemp3pwrup11:clrftemp2pwrup12clrftemp1pwrup13:clrwdtdecfsztemp1,F(xiàn)gotopwrup13decfsztemp2,F(xiàn)gotopwrup12decfsztemp3,F(xiàn)gotopwrup11MOVlwh’0FF’MOVwftemp3pwrup2:clrwdtincftemp3,F(xiàn)MOVftemp3,Wcallpwrupidenttable;Fetchtextclrftemp2subwftemp2,F(xiàn)btfscSTATUS,Z;Endoftable?gotopwrupendcalltxsergotopwrup2pwrupend:gotopwrupidentreturnENDIF;+++***Main***+++main:gotoDTMFdetDTMFdetreturn:gotoringdetringdetreturn:gotomain;Repeatmain;ReadDTMF-bitsfrom8870,convertstonibble,andreturnsinW.readDTMF:MOVfGPIO,Wandlwb’00000011’;Getbit0-1MOVwfDTMFvalbsfDTMFval,2;Getbit2btfssDTMF2bcfDTMFval,2MOVlwb’11111111’;Getbit3(DTMF3=input)bcfDTMFval,3trisGPIOMOVlwb’11101111’btfscDTMF3bsfDTMFval,3trisGPIO;DTMF3=OutputbcfDTMF3MOVfDTMFval,W;Convertfrom8870-》’normal’andlwb’00001111’callDTMFtableMOVwfDTMFvalretlw0DTMFtable:addwfPCL,F(xiàn)retlwb’00001101’;DTMF’D’retlwb’00000001’;DTMF’1’retlwb’00000010’;DTMF’2’retlwb’00000011’;DTMF’3’retlwb’00000100’;DTMF’4’retlwb’00000101’;DTMF’5’retlwb’00000110’;DTMF’6’retlwb’00000111’;DTMF’7’retlwb’00001000’;DTMF’8’retlwb’00001001’;DTMF’9’retlwb’00000000’;DTMF’0’retlwb’00001110’;DTMF’*’retlwb’00001111’;DTMF’#’retlwb’00001010’;DTMF’A’retlwb’00001011’;DTMF’B’retlwb’00001100’;DTMF’C’;ConvertsreceivedDTMFtoASCII(returnsinW)conASCII:IFASCII==1addwfPCL,F(xiàn)retlwA’0’retlwA’1’retlwA’2’retlwA’3’retlwA’4’retlwA’5’retlwA’6’retlwA’7’retlwA’8’retlwA’9’retlwA’A’retlwA’B’retlwA’C’retlwA’D’retlwA’*’retlwA’#’ENDIF;Testsfor3subsequent’*’。ident:IFIDENTTX==1bcfIdentOKMOVlwb’00001110’;DTMF’*’subwfDTMFval,WbtfssSTATUS,Zgotoident1incfidentval,F(xiàn)MOVlwd’3’subwfidentval,WbtfssSTATUS,ZgotoidentendbsfIdentOKident1:clrfidentvalidentend:retlw0ENDIF;TransmitsWat2400bps/std.RS232.Calculatesparity-bit.Returnswhendone.txser:MOVwftemp1bcfSTATUS,C;Transmitstart-bitcalltxcarryMOVlwd’8’;Transmit8databitsMOVwftemp2txbits:clrwdtrrftemp1,F(xiàn)calltxcarrydecfsztemp2,F(xiàn)gototxbitsIFPARITY==1rrftemp1,F(xiàn);calculateparity(even)swapftemp1,Wxorwftemp1,WMOVwftemp1rrftemp1,F(xiàn)rrftemp1,F(xiàn)xorwftemp1,F(xiàn)rrftemp1,Wxorwftemp1,F(xiàn)bcfSTATUS,Cbtfsctemp1,0bsfSTATUS,CcalltxcarryENDIFbsfSTATUS,C;Transmit2*stop-bitcalltxcarrybsfSTATUS,Ccalltxcarryretlw0;transmitcarry-flagIFTMR0CLK==0txcarry:MOVlw(256-104);2400=416,666us=1666,666c/16=104,17ENDIFIFTMR0CLK==1txcarry:MOVlw(256-93);2400=416,666us=1491,477c/16=93,22ENDIFtxndone:btfscTMR0,7;Lastbittransmitted(TMR0ovfl.)?gototxndonebsfDTMF3;SpacebtfscSTATUS,C;Settomark(-12V)ifCarry=1;(RS232invertsoutput)bcfDTMF3;MarkMOVwfTMR0retlw0;RecognizesCLIP(DTMFreceivedinA),andsets/clearsCLIP.IFCLIONLY==1CLIPdet:MOVwftemp1MOVlwb’00001010’;DTMF’A’subwftemp1,WbtfssSTATUS,ZgotoCLIPdet2bsfCLIPgotoCLIPdetendCLIPdet2:MOVlwb’00001101’;DTMF’D’subwftemp1,WbtfssSTATUS,ZgotoCLIPdet3bsfCLIPgotoCLIPdetendCLIPdet3:btfssCLIPgotoCLIPdetendMOVlwb’00001111’;DTMF’#’subwftemp1,WbtfssSTATUS,ZgotoCLIPdetendbcfCLIPbsfCLIPendCLIPdetend:retlw0ENDIF;DTMF-detection-CallsreadDTMF,CLIPdet,conASCIIandtxserifDTMFispresent.;ReturnswhenDTMFisreMOVed.DTMFdet:clrwdtbtfssDTMFOKgotoDTMFdetreturngoto$+1;DoublenopbtfssDTMFOKgotoDTMFdetreturncallreadDTMF;DTMFpresent,read!IFIDENTTX==1;Transmitidentif’***’receivedcallidentbtfssIdentOKgotoDTMFdet2MOVlwh’0FF’MOVwftemp3DTMFdet1:clrwdtincftemp3,F(xiàn)MOVftemp3,Wcallidenttable;Fetchtextclrftemp2subwftemp2,F(xiàn)btfscSTATUS,Z;Endoftable?gotoDTMFdet2calltxsergotoDTMFdet1ENDIFDTMFdet2:MOVfDTMFval,WIFCLIONLY==1;TransmitonlyCLIcallCLIPdetbtfssCLIPend;LastdigitinCLI(#)?gotoDTMFdet21bcfCLIPendgotoDTMFdet22DTMFdet21:btfssCLIPgotoDTMFoffDTMFdet22:MOVfDTMFval,WENDIFIFASCII==1;ConverttoASCIIMOVfDTMFval,WcallconASCIIENDIFcalltxser;TransmittoserialportDTMFoff:clrwdt;WaitforDTMFtostopbtfscDTMFOKgotoDTMFoffDTMFend:gotoDTMFdetreturn;Ring-detection-Ifringingispresent,callstxserwithW=(ascii)’R’。;ReturnswhenringingendsorDTMFispresent.ringdet:clrwdtIFRING==1btfscDTMF2gotoringendringdet2:;Waitforringing-pulsetoclrwdt;stop(orDTMFpresent)。btfscDTMFOKgotoringendbtfssDTMF2gotoringdet2MOVlwb’10000111’;Setuptimer:50msbeforeoverflow.optionMOVlwd’50’MOVwfTMR0ringdet3:clrwdt;Waitfornewringing-pulseMOVlw0subwfTMR0,WbtfscSTATUS,ZgotoringendbtfscDTMF2gotoringdet3;Newpulsepresent.MOVlwOPTION_REG;RestoreoldprescaleroptionMOVlwA’R’;Transmit’R’calltxserbcfCLIP;TerminateCLIP-sequence(ringdet.)MOVlwb’10000111’;Setuptimer:50msbeforeoverflow.optionringdet4:MOVlwd’50’MOVwfTMR0ringdet5:clrwdt;WaitforringingtoendbtfssDTMF2gotoringdet4MOVlw0subwfTMR0,WbtfscSTATUS,ZgotoringendbtfssDTMFOKgotoringdet5ringend:MOVlwOPTION_REG;RestoreoldprescaleroptionENDIFgotoringdetreturnIFOTP==0ORGh’1FF’;(old12C508calibration-val.)MOVlwh’0A0’ENDIFEND++|History|++Rev.ChangeReasonDate0.0aSource-filecreated.-24.03.980.5aHierarchischdiagramfinished.-25.03.981.0aEverythingimplemented,readyfortest.-26.03.981.0bTestedin’reallife’。。.Everythingok,-27.03.98(minorbugsreMOVed)。1.0Firstversion,’inuse’。-27.03.981.01Fixed’#’nottransmittedwhenCLIP=1.-29.03.98Fixed’D’-sequencesnotrecognizedasCLIP(nottransmittedwhenCLIP=1)。ImplementedPwr
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 樂器維修配件供應合同
- 產(chǎn)品監(jiān)制合同格式范例
- 人力資源培訓與咨詢服務合同
- 二手房購房合同
- 交通運輸工程師合同范本
- 農(nóng)村租房合同協(xié)議書簡單版
- 前期物業(yè)合同對業(yè)主約束力 法律規(guī)定
- 2024-2025學年高二物理上學期期中考點大串講(人教版2019)專題01 靜電場及其應用(考點清單)含答案及解析
- 醫(yī)療機構(gòu)周邊綠化冬季保養(yǎng)方案
- 高檔品牌店門面租房合同要素
- 電子產(chǎn)品維修合同范本1
- 試用期員工轉(zhuǎn)正規(guī)章制度(8篇)
- 2023-2024學年全國小學二年級上數(shù)學人教版期中考試試卷(含答案解析)
- 《籃球原地雙手胸前傳接球》教案 (三篇)
- 3上修改病句練習
- 2024年廣東茂名高州市教師發(fā)展中心和高州市教育事務中心選聘歷年高頻難、易錯點500題模擬試題附帶答案詳解
- 2024年建筑繼續(xù)教育-一級建造師繼續(xù)教育考試近5年真題集錦(頻考類試題)帶答案
- 上海市浦東新區(qū)2023-2024學年六年級上學期期中考試英語試題
- 責任保險行業(yè)研究報告
- (高清版)JGT 225-2020 預應力混凝土用金屬波紋管
- 化學實驗室安全考試試題-及答案
評論
0/150
提交評論