版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
基于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,Fdt“+++PCNummerViser+++”,13dt“Firmwarev1.04”,13,13dt“JaCOBBlichfELDt’98”,13,13,13,0ENDIFpwrupidenttable:IFPWRUPID==1addwfPCL,Fdt“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,Fgotopwrup13decfsztemp2,Fgotopwrup12decfsztemp3,Fgotopwrup11MOVlwh’0FF’MOVwftemp3pwrup2:clrwdtincftemp3,FMOVftemp3,Wcallpwrupidenttable;Fetchtextclrftemp2subwftemp2,FbtfscSTATUS,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,Fretlwb’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,FretlwA’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,FMOVlwd’3’subwfidentval,WbtfssSTATUS,ZgotoidentendbsfIdentOKident1:clrfidentvalidentend:retlw0ENDIF;TransmitsWat2400bps/std.RS232.Calculatesparity-bit.Returnswhendone.txser:MOVwftemp1bcfSTATUS,C;Transmitstart-bitcalltxcarryMOVlwd’8’;Transmit8databitsMOVwftemp2txbits:clrwdtrrftemp1,Fcalltxcarrydecfsztemp2,FgototxbitsIFPARITY==1rrftemp1,F;calculateparity(even)swapftemp1,Wxorwftemp1,WMOVwftemp1rrftemp1,Frrftemp1,Fxorwftemp1,Frrftemp1,Wxorwftemp1,FbcfSTATUS,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,FMOVftemp3,Wcallidenttable;Fetchtextclrftemp2subwftemp2,FbtfscSTATUS,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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 心理健康教育计划健康教育工作计划
- 教育局校管办工作计划
- 2024年街道工作计划报告
- 国企工会的工作计划
- 平面设计实习计划例文
- 农经站工作总结及计划行政工作总结
- 【课件】工程项目QHSE管理培训
- 媒体销售下半年工作计划
- 幼儿园小班上学期音乐教学计划
- 安全生产法培训计划 安全生产法
- 小学英语复习讲座课件
- 2023年中级经济师考试真题及答案完整版
- 网络安全攻防实训平台解决方案
- 拆除评定表资料
- 钢筋材料计划申报表
- 2023年08月中国科学技术大学国际合作与交流部招聘1名管理助理笔试历年高频考点试题含答案带详解
- 医院护理三基考试试题及答案
- 中职英语新高教版基础模块1unit4school-life
- 2023年北京国家公务员行测考试真题及答案-行政执法类
- 2023输电工程项目规范
- 初中信息技术课程课件《初识Python》
评论
0/150
提交评论