CN1119898A - 用于蜂窝式无线电收发机系统的自诊断系统 - Google Patents

用于蜂窝式无线电收发机系统的自诊断系统 Download PDF

Info

Publication number
CN1119898A
CN1119898A CN94191585A CN94191585A CN1119898A CN 1119898 A CN1119898 A CN 1119898A CN 94191585 A CN94191585 A CN 94191585A CN 94191585 A CN94191585 A CN 94191585A CN 1119898 A CN1119898 A CN 1119898A
Authority
CN
China
Prior art keywords
call
mov
transceiver
signal
cellular
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN94191585A
Other languages
English (en)
Other versions
CN1064808C (zh
Inventor
L·R·奥蒂斯
A·托里斯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Telular International Inc
Original Assignee
Telular International Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Telular International Inc filed Critical Telular International Inc
Publication of CN1119898A publication Critical patent/CN1119898A/zh
Application granted granted Critical
Publication of CN1064808C publication Critical patent/CN1064808C/zh
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W24/00Supervisory, monitoring or testing arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W84/00Network topologies
    • H04W84/02Hierarchically pre-organised networks, e.g. paging networks, cellular networks, WLAN [Wireless Local Area Network] or WLL [Wireless Local Loop]
    • H04W84/10Small scale networks; Flat hierarchical networks
    • H04W84/14WLL [Wireless Local Loop]; RLL [Radio Local Loop]

Landscapes

  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Engineering & Computer Science (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Monitoring And Testing Of Transmission In General (AREA)
  • Transceivers (AREA)
  • Radar Systems Or Details Thereof (AREA)
  • Telephonic Communication Services (AREA)
  • Telephone Function (AREA)
  • Measurement Of Velocity Or Position Using Acoustic Or Ultrasonic Waves (AREA)
  • Maintenance And Management Of Digital Transmission (AREA)
  • Reduction Or Emphasis Of Bandwidth Of Signals (AREA)
  • Circuits Of Receivers In General (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

一种自诊断系统,它用于检查带有蜂窝式接口装置的蜂窝式无线电收发机,所说的接口装置将标准的电话机连接于蜂窝式收发机,并且将DTMF或脉冲式拨号信号转换成数字格式以便传输给收发机,在该收发机中,可以使用陆用电话上拨出的号码去呼叫蜂窝系统范围内的号码。本发明不仅可监控和检查收发机及其相关电源的适当功能,而且可以监控和检查上述接口装置。

Description

用于蜂窝式无线电收发机系统 的自诊断系统
本专利文献所公开内容的一部分包含了受版权保护的资料。当本专利文献或专利公开内容披露在专利及商标局(Patent&Trademark Office)的文件或资料中时,本版权拥用人不反对对其任何一部分进行复制,但在任何情况下均保留版权。
背景技术
本发明涉及到一种用于检验蜂窝式无线电收发机系统的所有功能的自诊断系统。本发明特别涉及诸如美国专利第4,658,096号和4,737,975号所公开的蜂窝式接口系统。本文包括了上述专利所公开的系统以作为参考。在上述专利的系统中,一接口装置将标准的电话机、传真机、调制解调器或其它通信设备连接于蜂窝或蜂窝式无线电收发机,该接口装置能使上述通讯设备经由无线电收发机作正常的操作。所说的接口装置还可将DTMF或脉冲式拨号信号转换成数字格式以便传递给无线电收发机,因此,通过该无线电收发机可利用所拨的号码来呼叫无线电系统范围内的号码。本发明的系统可检测上述适配器接口装置的所有功能的正常运转以及其它特征,如无线电收发机的功率输出或该无线电收发机正在使用时的频率等,来自无线电收发机的信号或来自无线电网络的信号可以改变上述功率输出,而无线电收发机或蜂窝式网络则可有选择地改变前述频率。
本发明的诊断与检测系统可用于诸如纯蜂窝系统之类的任何蜂窝式系统或者诸如ISDN(综合业务数字网络)及其它个人通信系统之类的蜂窝式系统,在上述蜂窝式系统中设置有一蜂窝式适配器或接口装置以便将DTMF或脉冲式拨号信号转换成数字格式从而传递给与该蜂窝式系统相联的蜂窝式无线电收发机。
已知提供有用于整个蜂窝系统的诊断与检测设备。还已知提供有可自检测的机载装置。该机载装置公开于Rogers的美国专利第5,016,269号,此专利公开了一种蜂窝式电话的应急电话亭,本文包含了该专利以作为参考。上述专利公开了由电话亭自身执行的自诊断程序。该专利的电话亭中带有自诊断程序并定期性地将所检查到的作业状态经由蜂窝式网络报告给总局。Rogers公开了一种蜂窝式便携式手机和无线电收发机以及相关的自动诊断系统,该系统用于对所说的蜂窝式系统进行检查并报告给总局。但是,该专利未公开对诸如上述美国专利第4,658,096号和第4,737,975号中所使用的DTMF转换器的监控与自诊断功能,而且,Rogers也未说明从总局产生回铃以便对系统的适当作业进行检查。
除纯蜂窝系统以外,可使用本发明的蜂窝式系统是这样一些系统,它们一般涉及到无线数字个人通信系统(这些系统带有多个智能基地台和智能便携式手机终端,每个基地台和手机均具有预定的无线电信号覆盖面积),具体地说,它们涉及到数字无线电电话式个人通信系统(PCS),这种系统带有一全ISDN接口装置,从而便于PCS呼叫业务经由ISDN接口装置及公共电话交换网或任何交换网的连接和转换,所说的个人通信系统其有声音/数据/图像(或它们的组合形式)以及双路全双工呼入呼出能力,并且可充分加以使用,同时可与任何所选定的调制方法相兼容,而且与通过在软件中实现的分布式逻辑电路所设置的蜂窝间协议切换相兼容,所说的软件则驻留在便携式智能手机、智能基地台以及配备有PCS服务控制数据库的公共电话交换网(或任何交换网)中。
在过去十年内,移动式及便携式通信日益增加的可用性使商业及住宅用户正在摆脱完全有线的电信网络的束缚。具体地说,蜂窝式通信系统连同寻呼及其它附加业务第一次使得电信业务有了真正的可移动性。移动与便携技术以及诸如无线电信数字传输之类新技术方面的重大技术进步业已显著地增加了使用用户可以利用的无线电频谱的无线电信服务的数量和类型。这些未来的服务包括但不局限于蜂窝式电话服务的高级形式、高级数字式无线电话服务、便携式传真服务、无线交换台、无线专用支局服务以及无线局域网服务,并且,可以通过现有的公共交换网或通过可替代的局部有线网(如电缆电视)来使用上述未来的服务。因此,数字或个人通信系统可独立于有线局域网而存在,也可与有线局域网共存,从而填补了当前通信系统中的空白,并且,还能形成新的市场,这些市场中的多数是尚未明朗化的。PCS的出现通过显著地改进所有电信网的灵活性与功能,从而对它们的开发与结构产生巨大的影响。所以,PCS的供应商能在全国范围内以经济和快捷的方式获得并服务于现有及新的市场。
用于用户日益增加的流动性,美国个人通信的要求正在随着对即时通信的需求的增加而迅速改变。PCS的优点之一在于这种系统能用单一的通信设备在任何时间、任何地点与任何人进行联系。PCS会促进用户日益增加的流动性和灵活性,这是因为,这种方法能解决与用户进行稳定通信中所存在的潜在问题。PCS的无线化能使得用户不会错过重要的呼叫,并且减小回话时的时间和费用。PCS将无线电的功能与公共电话交换网(PSTN)技术和基本设施结合起来并且能提供无线电蜂窝间的全双工能力(双向呼出)以及切换(从而使得用户在不中断通话的情况下自由地从一个无线电蜂窝移至另一个无线电蜂窝)。注意到以下实事是很重要的:对于新型PCS设施和用于多种(有时是相矛盾的)应用即无线电专用交换支局、小型轻质蜂窝式便携电话、便携式传真机、多通路无绳电话以及目的在于便于与特定个人用户进行联络(而不是与特定电台进行联络)的辅助设施的需求正在持续地增加。目前所提供的无线电设备及相关的设施(即无绳电话、无线电寻呼以及蜂窝式无线电话)无法完全满足对上述新型PCS设施的要求。例如,无绳电话只能在家庭或办公室内及周围使用并且只能处理非常少的信道(10个左右),这些信道拥挤在一起并只限于在与它们相联的基地台附近使用。无线电寻呼设施仅仅是单向的并且容量有限。蜂窝式及专门的移动式无线电设施无法满足所有对PCS的预期要求。随着时间的推移,PCS会具有标准化的设备,这种设备在硬件方面带有通用的组件,从而能在不受外部信号源瞬时干扰的相关设备方面提高了可靠性,并且,PCS带有自动通话登记、自动通话发送、语音邮件、传真能力、方便的漫游特征、远程数据传送、增加了的保密性/主叫用户的ID/分级设施、增加了的电池寿命以及通用协议。为了能最佳地实现这种市场授权,数字式PCS是一种必需的设备。无线PCS最终会不需要有用于通讯的用硬电缆相连的建筑设施。一般地说,PCS会简化带有辅助特征的通信设备。数字式PCS会便于改进技术性的通信设备、系统与装置。
所以,本发明可在设置有蜂窝式适配器或接口插板的ISDN或其它PCS系统中使用,所说的适配器或接口插板通过将DTMF或脉冲信号转换成可发送给PCS无线电收发机的数字格式或者通过提供所述系统专用的其它功能,从而允许在系统内使用标准的陆用电话机或其它通信设备。例如,在无线电收发机只能进行呼出的专用报警系统中,接口装置不必提供响铃、忙音或类似的信号。另外,在只需呼入的系统中,接口装置不必将拨号的DTMF或脉冲信号转换成数字格式。正如美国专利第4,658,096号和第4,737,975号所述的蜂窝接口插板那样,PCS-蜂窝适配器还提供诸如产生拨号音、振铃或类似信号之类的全部所需的其它功能。
发明概要
所以,本发明的基本目的是提供一种自诊断系统,这种系统用于检测带有蜂窝式接口装置的蜂窝式无线电收发系统的所有功能,所说的接口装置将标准的陆用电话机或其它通信设备连接于蜂窝无线电收发机或者连接于诸如蜂窝式PCS或ISDN无线电收发机,并且,所说的接口装置还将DTMF或脉冲式拨号信号转换成数字式以便传送给蜂窝或蜂窝式无线电收发机,从而,可以使用在陆用电话机或与其相当的设备上所拨叫的号码去呼叫上述蜂窝或蜂窝式系统范围内的号码。本发明不仅能监控和检测蜂窝或蜂窝式无线电收发机及相关电源和类似设备的适当功能,而且会监控和检测蜂窝或蜂窝式接口装置。
本发明的检测设备能与接口装置相连,此接口装置则将通信设备连接于无线电收发机,以便通过该收发机呼入或接收呼叫,所说的检测设备带有自身的诊断程序,从而能监控并报告接口装置的适当功能。
上述检测设备还可将诊断程序连接于接口装置,该诊断程序模拟诸如陆用通信电话、传真机、调制解调器以及类似设备之类的通信设备所执行的功能,以便在接口装置内产生各种相应的应答,从而确定该接口装置是否在正常的操作。
上述检测设备还会对接口装置产生摘机信号,并检测接口装置因响应摘机信号而产生的拨号音信号是否出现。
上述检测设备还生成DTMF信号并将该信号传送给接口装置,并且检测接口装置因响应所生成的DTMF信号而输出的DTMF信号。
上述检测设备还会对接口装置产生挂机信号,并且在接口装置正在生成振铃信号时对该接口装置产生摘机信号,以便确定接口装置在应答电话呼入时能适时地断开振铃信号。上述检测设备还能在接口装置连接于无线电收发机时通过电话网产生电话呼出并送回给该无线电收发机,从而,所说的诊断程序会使得收发机呼叫自己,并且,该诊断程序检测收发机因响应上述呼叫而产生的忙音信号。
参照附图将很容易地理解本发明,在附图中:
图1A和图1B显示了本发明的自检测所包含的步骤的总体流程图;
图2是显示本发明的自检测摘机子例程所包含的步骤的流程图;
图3是显示本发明的自检测拨号音生成子例程所包含的步骤的流程图;
图4是显示本发明的自检测DTMF音生成子例程所包含的步骤的流程图;
图5A至图5C显示了本发明的自检测振铃生成子例程所包含的步骤的流程图;
图6是显示本发明的自检测应答振铃过程子例程所包含的步骤的流程图;
图7A与图7B是显示本发明的通话检测子例程所包含的步骤的流程图,该子例程检查适当的通话检测以及对呼入的应答。
图8A和图8B显示了本发明的出错码生成子例程;
图9是显示本发明的重置子例程的流程图;
图10是本发明的系统的框图;
图11至图14是显示用于通过模拟所需检测的事件而检测蜂窝或蜂窝式接口及收发机的各种电路的概略图。
发明的详细公开
本发明的自动诊断维护系统可用于诸如美国专利第4,658,096号和第4,737,975号所公开的蜂窝或蜂窝式接口插板及系统。此外,本发明的自诊断维护系统还可以供诸如IMTS之类的其它无线电收发机系统使用,在这类系统中,提供了基地台与主控台之间的无线通讯,并且,无线电收发机与诸如美国专利第4,658,096和第4,737,975号所公开的适配器接口插板相连,这种接口插板则将诸如陆用通讯电话、传真机、调制解调器或类似设备之类的通信器材连接于所说的无线电收发机并使这些通信器材正常地发挥功能。上述接口装置根据预定的用途而提供多种功能。例如,在无线电收发机只进行呼出的专用报警系统中,接口装置就不必向通信设备产生振铃、产生忙音信号以及类似的信号。另外,在只需要有呼入的系统中,接口装置不必将拨号的DTMF或脉冲信号转换成数字格式。依照本发明,提供了一种软件,这种软件与美国专利第4,658,096号和4,737,975号所公开的蜂窝接口插板或其它无线电收发机接口插板的微处理器相通讯,这种软件可人工或自动地启动以便启动本发明的自动诊断接口插板,并且,这种软件可以诊断上述专利的整个系统内所包括的全部软件和硬件系统的适当功能。可以检测每个单一的项目。例如,对接口插板来说,可以检测DTMF转换器,与两线路接头相连的四线路接口、忙音软件以及接口的其它功能。此外,还会检测无线电收发机、电池以及接口的其它方面。本发明的维护系统能在蜂窝或蜂窝式网络范围内呼叫中心台或基地台的预定电话号码,然后,中心台可发回一个回音或者拨叫接口系统的当前号码以获得忙音信号。这种情况被看做是一次检测。本发明还能在蜂窝或蜂窝式系统的范围内发送另一个电码号码以呼叫相同或不同的中心台,因而,该中心台可发回一个1000Hz的精确单音,从而,本发明的软件会比较上述1000Hz的单音与其自身预定的配置,以便确定线路是否接通以及蜂窝或蜂窝式系统是否在正确地运行。这是一种特别有用的系统,因为,即使最终用户认为电话有问题,该系统也能使该用户使用电话。然后,这种检测会通知电话公司:是蜂窝系统的中心局有错还是最终用户的基本装置有问题。
依照本发明,有两种不同的组件,第一种是遥测维护(telemaintenance)电路,第二种是遥测计费(teletariff)电路。遥测维护电路进行将如以下详细说明的复合检测,该复合检测包括对预定的号码进行电话呼叫。遥测维护电路将检测的结果报告给上述特定的号码。此外,遥测维护电路还能拨叫自己的号码以便确认所述基本装置通过接收忙音信号而正在进行接收和传输。用户按下位于基本装置一侧的按钮可以启动上述的成组的检测。在按下按钮时,按钮附近的LED(发光二级管)会持续地闪烁以表示检测正在进行。如果在检测结束时LED仍继续闪亮,这就表示所述的基本装置有问题。上述检测活动一般最多不超过40秒钟。另一方面,如果LED停止闪亮并且关闭,就表示检测成功并且基本装置在检测所检查的项目方面处于适当的工作状态。作为一种可选择方案,如果传输介质允许的话(即无线电收发机处于工作状态以接收电话号码),那么,前述软件和硬件就能使得用一外部号码来进行所说的检测。
第二种电路的功能包括:它使用来自蜂窝或蜂窝式系统的计费信号并产生用于标准的台式电话或付费电话的相应的计费脉冲。这种设备判读来自蜂窝或蜂窝式的信号并且不作任何的局内计费。这种电路以与产生长音相类似的方式运行,并且可供能发送计费信号的任何蜂窝或蜂窝式系统使用。
对遥测维护程序组件流程的说明
用户可以通过按下自诊断按钮而激活检测工作程序。当被调用时,按口插板的控制权被转交给用于进行自动检测的遥测维护组件的主自诊断子例程。
图1A和图1B显示了DO_TEST例程或主自诊断例程。对各种检测过程进行多次调用。每一过程之后都检查出错标识。在有任何出错的情况下都停止检测程序。然后,对其状态进行编码并按如下所述那样将结果通过四个LED显示给用户。
参照图1A,在步骤1中,检测工作程序以初始化变量和标识开始。在步骤2中,程序调用Hook_Test子例程。在Hook_Test子例程中,用户的电话与塞尖和塞环(TIP及RING)线是断开的,而遥测维护组件(Telemaintenance Module,以下将予以详细说明)则在适当位置处与诸如美国专利第4,658,096号和第4,737,975号所公开的接口插板相连以准备进行检测。步骤3检查Hook_Test中所检测到的任何错误。如果发现有任何一种错误,该检测程序就会停止,程序会进入图1B中的步骤14。但是,如果未检测到错误,程序就会在步骤4中调用Dial_Tone测试例程。步骤5检查任何的拨号者错误。如果发现有任何一种错误,该检测程序就会停止,程序会进入图1B中的步骤14。但是,如果未检测到错误,程序就会在步骤6中调用下一个检测例程即步骤6的DTMF_Test例程。程序在图1B的步骤7处继续,在该步骤处,检查任何一种DTMF_Tone例程。如果发现有任何一种错误,该检测程序就会停止,程序会进入步骤14。但是,如果来检测到错误,程序就会在步骤8中调用下一个检测例程即步骤8的Ring_Test例程。步骤9检查任何的振铃错误。如果发现有任何一种错误,该检测程序就会停止,程序会进入步骤14。但是,如果未检测到错误,程序就会在步骤10中调用下一个检测例程即Ring_Answer_Test例程。步骤11检查任何的振铃应答错误。如果发现有任何的错误,该检测程序就会停止,程序会进入步骤14。但是,如果未检测到错误,程序就会在步骤12中调用下一个检测例程即步骤12中的Make_Call_Test例程。步骤13检查任何的呼出错误。如果发现有任何一种错误,该检测程序就会停止,程序会进入步骤14。但是,如果未检测到错误,程序就会在步骤15调用下一个检测例程即步骤15的Fin_Self_Test例程。如果在执行任一子例程的过程中发现有任何的错误,程序就会转至步骤14。在步骤14中,程序会调用Error_Acc例程。最后,检测程序在步骤15清除了所有的变量和标识之后结束,从而将控制权交还给电话机并且继续接口的正常操作。
以下对图2至图9的解释对应于并且详细说明了上述各个检测例程。
参照图2,Hook_Test例程(图1A的步骤2)在步骤16处开始于对变量和标识的初始化。在步骤17中,程序清除LED的任何输出。在步骤18中,使用户的电话与接口板的TIP和RING线相断开,而在步骤19中,本发明的遥测维护组件则替代电话而被连接。步骤20进行延时以便上述连接有足够的反应时间。在步骤21中,本发明的遥测维护组件模拟并产生摘机。步骤22进行延时以便有足够的时间进行上述摘机。在步骤23中,程序检查接口插板的叉簧状态,而接口板则与遥测维护组件相连。步骤24对摘机进行检测。如果未检测到摘机,则程序进入步骤25,在该步骤中设置ERROR_FLAG并将MATN_FLAG_ERROR置为1。但是,如果未检测到错误,程序就会进入到步骤26,在该步骤中,启动拨号音以便进行图3所示的下一步检测。最后,Hook_Test例程结束,程序返回至图1A和图1B中的主例程DO_Test。
参照图3,Dial_Test例程在步骤27处开始于对变量及标识的初始化。步骤28进行延时以便有足够的时间产生拨号音。步骤29对拨号音进行检测。如果拨号音出错,则程序进行步骤30,在步骤30中设置ERROR_FLAG并将MAIN_FLAG_ERROR置为3。但是,如果未检测到错误,程序就会进入步骤31,在该步骤中,程序循环返回至步骤29以检测拨号音至少711毫秒。711毫秒结束后未检测到错误,Dial_test例程结束,程序返回至图1A和图1B的主例程Do_Test。
参照图4,用于检测接口板将适当的DTMF转换成数字数据的DTMF_Test例程通过关闭来自前一个检测例程的拨号音而在步骤32开始。步骤33将第一个DTMF音置为0。在步骤34中,遥测维护组件送出与上述值相对应的DTMF音。步骤35进行延时以便使上述DTMF音延续足够的时间。步骤36断开DTMF音。步骤37进行延时以使得接口装置检测DTMF音的脉冲。在步骤38中,接口装置读取DTMF音。步骤39检查所接收到的DTMF音。如果所送出的DTMF音不等于接收到的DTMF音,或者未接收到DTMF音,那么,程序就会进入步骤40,在该步骤中设置ERROR_FLAG并且将MAIN_FLAG_ERROR置为4。但是,如果上述两个DTMF音是相同的,则程序进入步骤41并选定下一个DTMF数字。在步骤42中,程序检验是否已检测了所有的DTMF音,如果没有,则程序循还返回以检测下一个DTMF数字。最的,在已检测了所有的DTMF音之后,DTMF_Test例程结束,程序返回至图1A和图1B中的主例程DO_Test。
参照图5A和图5B,它们显示了Ring_Test例程。Ring_Test例程检测接口插板振铃电路所产生的振铃的两个脉冲的定时。参照图5A,Ring_Test例程在步骤43处开始于对变量和标记的初始化。在步骤44中,遥测维护组件进行一次挂机。步骤45进行延时以便接口装置检测上述挂机。在步骤46处,设置接口装置以确认正在进行呼入,所以,该接口板产生振铃。步骤47至步骤53的目的是:验证振铃开始于以后的两秒钟内并且未检测到摘机。在步骤47中,将计时器清零。步骤48对摘机进行检测。如果检测到摘机,则停止检测,程序转至图5C中的步骤49以显示错误。但是,如果检测到挂机,则程序进入步骤51,在该步骤中,遥测维护组件检查振铃的被激励。步骤52检测振铃是否已开始。如果已开始振铃,则程序进入图5B的步骤54。但是,如果尚未开始振铃,则程序会在步骤53中检查计时器。如果该计时器的时间小于两秒,则程序循环返回步骤48直至振铃开始。但是,如果上述两秒钟的计时器已完成计时,则检测就会停止,程序转至图5C中的步骤49以指示错误。参照图5B,步骤54进行延时。步骤55至步骤59的目的是检验振铃持续至少一次,长度为1.3秒,并且检验未检测到摘机。在步骤55中,将计时器清零。步骤56对挂机进行检测。如果检测到摘机,则检测停止,程序转至图5C中的步骤49以指示错误,但是,如果检测到挂机,则程序进入步骤57,在该步骤中,遥测维护组件检查被激励的振铃。步骤58检测振铃是否已停止。如果振铃已停,则程序进入图5B中的步骤49。但是,如果振铃尚未停止,则程序在步骤59内检查计时器。如果计时器小于1.3秒,则程序循环返回至步骤56直至振铃停止。但是,如果计时器完成计时,则检测停止,程序转至图5C中的步骤49。步骤60至步骤62的目的是检验振铃持续不超过2.5秒。在步骤60中,遥测维护组件检查振铃是否是被激励的。步骤61检测振铃是否已经停止。如果振铃停止,则程序转至图5C中的步骤63。但是,如果振铃尚未停止,则程序在步骤62中检查计时器。如果计时器小于2.5秒,则程序会循环返回步骤60直至振铃停止。但是,如果计时器完成了计时,则检测停止,程序转至图5C中的步骤49。
参照图5C,步骤63至步骤65的目的是检验在两秒钟的时间内未检测到摘机。在步骤63中,将计时器清零。步骤46对挂机进行检测。如果检测到摘机,则检测停止,程序在步骤49处继续以指示错误。但是,如果未检测到摘机,则程序在步骤65中检查计时器。如果计时器小于两秒,则程序会循环返回步骤64直至振铃开始。但是,如果计时器完成了计时,则程序在步骤66处继续,在该步骤中,程序检测本子例程业已进行了多少次检测振铃循环。如果只对振铃检测了一次,则程序在步骤64处继续,在该步骤中,设置标识Ring_Second。此后,程序循环返回至步骤47以便第二次检测振铃。但是,如果已对振铃检测了两次,则本例程结束,程序返回至主例程Do_Test。如果在Ring_Test例程的任何一部分中检测到错误,则程序会转至步骤49。步骤49清除呼入状态,所以,振铃停止。然后,程序在步骤50处继续,在该步骤中,设置ERROR_FLAG并将MAIN_FLAG_ERROR置为5。然后,本例程结束,程序返回至主例程Do_Test。
参照图6,它显示了Ring_Answer_Test例程。当应答呼入的电话时,本例程检测在振铃期间将摘机信号传给接口插板时该接口板的响应。步骤68至步骤69的目的是检验振铃将在以后的两秒钟内开始并且未检测至摘机。在步骤68中,将计时器清零。步骤69对挂机进行检测。如果检测到摘机,则检测停止,程序转至步骤73。但是,如果检测到挂机,则程序继续并且振铃是处于被激励的。步骤71检测是否已开始振铃。如果已开始振铃,则程序进入步骤74。但是,如果尚未开始振铃,则程序会在步骤72处检查计时器。如果计时器少于两秒,则程序循环返回至步骤69以等待振铃开始。但是,如果上述的两秒计时器已完成了计时,则检测停止,程序转至步骤73。在步骤74中,遥测维护组件产生一次摘机。步骤75进行延时以便使接口板检测上述摘机。在步骤76中,接口板检查叉簧的状态。如果在步骤77中未检测到摘机,则检测停止,程序转至步骤73。但是,如果接口板检测到摘机,则程序在步骤78处继续。如果在Ring_Answer_Test例程的任何一部分中检测到了错误,则程序转至步骤73,在该步骤中,设置ERROR_FLAG并且将MAIN_FLAG_ERROR置为6。然后,程序在步骤78处继续。在步骤78中,清除呼入状态,所以,接口插板会使振铃停止。此后,本例程结束,程序返回到主例程Do_Test。
参照图7A和图7B,它们显示了Call_Test例程。该例程按下述方式检测与接口板相连的蜂窝或蜂窝式无线电收发机:首先检查电源,然后产生一个呼叫自身的电话号码。参照图7A,步骤79检查收发机的电源是否“接通”,如果电源是“断开”的,则在步骤81中将MAIN_FLAG_ERROR置为1,然后程序转至图7B中的步骤93。但是,如果电源是“接通”的,则程序进入步骤82,在该步骤中,接口板请求并获取收发机所指定的电话号码。步骤83进行延时以提供用于收发机的应答时间。在步骤84中,接口板对自己进行电话呼叫。步骤85进行延时以便接通蜂窝或蜂窝式网络与无线电收发机。在步骤86中,接口板向收发机请求IN USE(使用中)状态。步骤87检查呼叫的状态。如果该状态不是IN USE,则在步骤88中将MAIN1_FLAG_ERROR置为4,然后程序转至图7B中的步骤93。但是,如果收发机处于IN USE状态,则程序进入图7B的步骤89。在图7B中,遥测维护组件在步骤89中检查。如果在步骤90中检测到忙音,则程序转至步骤93以指示所有的装置均在正确运行。但是,如果未检测到忙音,则程序进入步骤91,在该步骤中检查计时器。如果计时器少于18.2秒,则程序循环返回步骤86。这就使蜂窝或蜂窝式网络有更多的时间返回忙时向应。但是,如果计时器结束了计时,则程序进入步骤92,在该步骤中将MAIN_FLAG_ERROR置为3。在步骤93中,接口板向收发机发送一呼叫END(结束标志)。然后,遥测维护组件在步骤94中向接口板提供一挂机信号。最后,Call_Test例程结束,程序返回至主例程Do_Test。
图8A和图8B的目的是以能通过LED在以后输出其结果的方式根据前述错误标识来生成一个ERROR_CODE。参照图8A,此例程开始于检查两个错误标识中的一个即MAIN_FLAG_ERROR。步骤95检查MAIN_FLAG_ERROR是否等于1或叉簧SLIC错误(Hook Slic Error)。如果相等,则在步骤96中将ERROR_CODE置为1,然后程序返回主例程Do_Test。但是,如果不相等,则程序在步骤97处继续。步骤97检查MAIN_FLAG_ERROR是否等于2或叉簧振铃错误(Hook_Ring Error)。如果相等,则在步骤98中将ERROR_CODE置为2,然后程序返回至主例程Do_Test。但是,如果不相等,则程序在步骤99处继续。步骤99检查MAIN_FLAG_ERROR是否等于3或拨号音错误(Dial_Tone_Error)。如果相等,则在步骤100中将ERROR_CODE置为3,然后程序返回至主例程Do_Test。但是,如果不相等,则程序在步骤101处继续。步骤101检查MAIN_FLAG_ERROR是否等于4或DIMF单音错误(DTMF Tone Error)。如果相等,则在步骤102中将ERROR_CODE置为4,然后程序返回至主例程Do_Test。但是,如果不相等,则程序在步骤103处继续。步骤103检查MAIN_FLAG_ERROR是否等于5或振铃检测错误(Ring_Detection_Error)。如果相等,则在步骤104中将ERROR_CODE置为5,然后程序返回至主例程Do_Test。但是,如果不相等,则程序在步骤105处继续。步骤105检查MAIN_FLAG_ERROR是否等于6或振铃应答错误(Ring_Answer_Error)。如果相等,则在步骤106中将ERROR_CODE置为6,然后程序返回主例程Do_Test。如果不相等,则程序转向图8B的步骤107。在图8B中,例程开始于检查第二个出错标识的值即MAIN1_FLAG_ERROR。步骤107检查MAIN1_FLAG_ERROR是否等于1,或功率射频错误(Power_Radio Error)。如果相等,则在步骤108中将ERROR_CODE置为7,然后程序返回至主例程Do Test。但是,如果不相等,则程序在步骤109处继续。步骤109检查MAIN1_FLAG_ERROR是否等于2或乎叫错误(Call Error)。如果相等,则在步骤10中将ERROR_CODE置为8,然后程序返回至主例程Do_Test。但是,如果不相等,则程序在步骤111处继续。步骤111检查MAIN1_FLAG_ERROR是否等于3或忙音错误(Busy_ToneError)。如果相等,则在步骤123中将ERROR_CODE置为9,然后程序返回至主例程Do_Test。但是,如果不相等,程序就在步骤113处继续。步骤113检查MAIN1_FLAG_ERROR是否等于4或“使用中”错误(“In Use”Error)。如果相等,则在步骤114中将ERROR_CODE置为10,然后程序返回至主例程Do_Test。如果不相等,程序就会在步骤115处继续。步骤115检查MAIN1_FLAG_ERROR是否等于5或1000Hz错误(1000Hz Error)。如果相等,则在步骤116中将ERROR_CODE置为11,然后程序返回至主例程Do_Test。如果不相等,程序就会返回至主例程Do_Test。
参照图9的FIN_SELF例程,该例程的目的是将接口板重置为正常的功能并通过使LED闪亮四次而表示检测结束。FIN_SELF例程始于步骤117,在该步骤中,遥测维护组件产生一次挂机。在步骤118中,将所有的变量和错误标识均清零。步骤119关掉所有的LED。步骤120进行延时。步骤121接通所有的LED。步骤122进行延时。步骤123循还返回步骤119从而使LED闪亮四次。最后,步骤124关掉所有的LED,然后程序返回至图1A和图1B的主例程Do_Test。
以下说明本发明的操作情况,然后说明用于进行上述自检测的各个电路,再说明用于进行本文所述之操作的软件程序。
参照图10,它显示了遥测维护电路组件的框图,该组件总的用标号10表示。遥测维护电路组件10安装在诸如美国专利第4,658,096号和第4,737,975号所公开的蜂窝或蜂窝式适配器系统内,并被设计成能根据按钮的启动或根据每隔约12小时的自动检测而从电话用户的设备开始执行上述图1A至图9中流程图详细说明的自动检测。自检测的最终结果通过安装在蜂窝或蜂窝式适配器右侧壁面上的橙黄色发光器(LED)提供给用户。遥测维护电路组件10能将检测的结果报告给远距离服务中心。这种报告是通过自动呼叫预定的服务中心号码而实现的。这一功能要求服务中心配备有进行通信所需的硬件和软件并能判读接收到的报告。本发明的自诊断检测能检验蜂窝或蜂窝式适配器,包括其组件如接口卡的基本电路、无线电台设备与接口间的数据电缆、传输线、天线、蜂窝或蜂窝式无线电收发机、计费电路以及电源等的正确操作。遥测维护电路被配置成能够呼叫分配给正在进行检测的适配器收发机的相同号码。对自诊断电路编程以便将忙音和占线信号作为表示可以进行通话且传输电路正在正确运转的信号而加以检测。
遥测维护电路组件10设计成能在蜂窝或蜂窝式适配器装置中使用,以便在无需使技术人员到安装有设备的现场的情况下检验适配器装置是否在正确地运转。所说的蜂窝或蜂窝式接口板能直接地提供遥测维护电路组件10。高级的遥测维护电路不是自激电路(autonomous Circuit)。其操作取决于从蜂窝或蜂窝式接口板内的审查程序(auditor)中所接收的控制信号。审查程序将检测的结果与系统运行程序的参数作比较。遥测维护电路组件10的自诊断电路进行下列检测:应答错〔错误号〕,用两种可替代的方法来进行上述检测;振铃电压,自诊断电路进行一次呼叫并检测接口插板所产生的振铃电压的出现;呼叫应答,验证一旦进行了应答就使振铃停止;拨号音,验证拨号音的出现;MFTO操作,确保接口插板能适当地检测收到的MFTO(多频率声音检测器)单音;无线电收发机检测;接收电路检测;传输电路检测;计费电路检测,验证以12KHz产生的脉冲的频率特征;收发机电源;电源系统的性能。在对图1A至图9的说明中已详细叙述了这些检测活动。
遥测维护电路组件10可通过一具有20个位置的插接式连接器而与通常的蜂窝或蜂窝式接口插板相连。通过一安装在适配器箱右侧的手动开关可以启动检测例程。当发现电话操作不正常时,例如拿起听筒时听不到拨号音,用户可转向适配器箱并按下被适当标识的检测钮。遥测维护电路组件10会断开用户电话与蜂窝或蜂窝式接口插板的联系并进行一系列如前所述的自诊断检测。还对遥测维护电路组件10进行编程以便从接通蜂窝或蜂窝式接口插板开始每隔约12小时就自动地启动检测例程。在自动启动检测时,并不产生检测呼出的程序。通过进一步的研制开发,可从遥控中心激活自诊断检测的启动功能。遥测维护功能可对接口插板的正在运行的软件进行调整并可对遥测维护中心的硬件和软件进行辅助开发。启动自检测例程时,橙黄色发光指示器(LED)会闪亮以告知用户正在进行检测。维护电路每完成一种检测,指示器的闪亮就暂停约一秒钟。全部的检测约持续40秒钟。结束检测时,发光指示器保持发光以表示检测成功。在这种情况下,存在的问题可能涉及到线路或者是与蜂窝或蜂窝式接口插板相连的电话设备。只要发光指示器连续地发光,则蜂窝或蜂窝式接口插板就会返回至正常的操作状态。当通过检测而发现蜂窝或蜂窝式接口插板有故障时,发光指示器会长时间地熄火。这告知用户蜂窝或蜂窝式适配器内存在问题。一旦检测例程结束,蜂窝或蜂窝式接口插板就会在与所检测到的故障无关的情况下返回至正常操作状态。尽管检测到的故障会引起限制,但用户仍可以继续使用适配器。
蜂窝或蜂窝式接口插板的电路中使用了四个发光指示器(LED)以便标识检测到的故障。这种方法对能接近适配器箱内部以确认可能的故障特性的维修技术人员来说是有帮助的。“开”、“关”LED的组合可以表示检测中所检测到的主要故障。一旦检测结束,这种组合将保持发光60秒。以下给出了用蜂窝或蜂窝式接口插板的LED所表示的可能的故障代码表。
在完成了自检测时,如果已检测到了故障,则对遥测维护中心发起呼叫。一旦建立起了联系,就报告所检测到的故障。这种遥测功能将为每一个装置都建立一个数据库。如果是通过按钮而人工启动检测,则不管是否检测到了故障,所完成的检测的全部结果均会报告给遥测维护中心。
以下是LED组所显示的代码表:错误类型    LED5   LED4   LED3   LED2无故障       关      关      关      关循环错       关      关      关      开循环错       关      关      开      关拨号音       关      关      开      开MFTD检测器          关    开    关    关振铃检测器          关    开    开    开呼叫应答            关    开    开    关收发机馈送          关    开    开    开发送器(呼叫)        开    关    关    开听筒(占用)          开    关    关    关以12KHz的单音检测   开    关    开    开来自电源的馈送      开    关    开    关“NO SERVICE”              开    开    开    开传输电路            开    开    开    关不确定              开    开    关    开不确定              开    开    关    关
自检测的顺序如下。遥测维护电路所进行的第一项工作是断开用户的设备。然后模拟“应答用户的电话”的状态。在这种状态下,可以检查对循环闭合的正确检测,从而产生拨号音。然后,在最小的频率和强度范围内确认正确地产生了拨号音。再次,开始对MFTD的复合频率音检测器进行检测。这包括:遥测维护电路组件的自诊断插卡产生完全连续的16种MFTD单音、将该单音发送给蜂窝或蜂窝式适配器的通常的蜂窝或蜂窝式接口插板并且确认已正确地检测到了这些声音。随后,进行检测以确认振铃发生器正在正确地起作用。产生振铃电流以便在预定的最小范围确认其频率和强度。然后。再次模拟应答电话或呼叫应答的状态以便检查振铃电路的功能(振铃电路在应答电话之前应是停用的)。就蜂窝或蜂窝式适配器付费电话而言,随后的检测将检查计费电路的容量以在最小的频率和强度范围按12KHz产生脉冲。遥测维护电路组件10内的精密脉冲检测器以周知的方式检测计费插卡所产生的上述脉冲。对不带有计费组件的蜂窝或蜂窝式适配器系统来说,用分离的跨接线形成蜂窝或蜂窝式接口插板的连接器J1.3。而跨接线则安装在带有计费组件的装置内。
以后的检测是验证蜂窝或蜂窝式收发机的功能。首先,检验对收发机的供电情况。这项检测是通过检查来自收发机的数据连接器的+12VDC(+12V直流电压)而进行的。第二,检验收发机以使得它处于能进行蜂窝或蜂窝式接入服务的状态。这种状态是由不存在“NO SERVICE”信号来表示的。“NO SERVICE”信号的出现被认为是一种故障。这种情况可能是由覆盖故障引起的,而不仅仅是蜂窝或蜂窝式收发机的故障。然后,通过蜂窝或蜂窝式网络呼叫用户所拥有的号码。由于收发机正在呼叫自身,所以,按这样的方式检查收发机的功能,即在从系统中接收到忙音信号的情况下对收发机进行检测。在发现网络被占用的情况下,就将“PATH ENGAGED”状态报告给收发机。然后,收发机产生一占线(忙)音。正常的收发机功能将这种声音看做与忙音信号相同。只有在用按钮启动前述例程时才进行上述检测。在自动启动前述过程的组件中不进行上述检测。还检查系统电源的电压。如果电压小于13.5VDC,则会检测到该电源中的故障。
在图10中,主遥测维护组件10与标准的蜂窝或蜂窝式适配器或接口插板14相连。该遥测维护组件内有多个用于进行上述自我诊断检测的独立电路。这些电路是:忙音信号检测器16,此检测器在对适当地接收的呼叫进行检测时使用,而所说的呼叫则是由遥测维护组件在参照图7A所述的回叫自检测期间进行;12,000次循环检测器电路18,此电路用于计费检测,它检验以12KHz所产生的脉冲的频率特征;MFTD发生器电路20,此电路产生由蜂窝或蜂窝式接口插卡所转换的DTMF信号,如以上参照图4所述;振铃信号检测器电路22,此电路用于在振铃检测和振铃应答例程中检测由蜂窝或蜂窝式适配器接口插板所产生的振铃信号,如以上参照图5A至图6所述;拨号者检测器电路24,此电路检测由蜂窝或蜂窝式适配器接口板14所适当产生的拨号音,如以上参照图3所示;电压检测器电路28,此电路用于检测收发机和整个系统的电源;以及遥测维护控制器30,此遥测维护控制器是控制单元并用于呼叫并将自检测的结果并报告给中心报告台。图11至图14显示了上述每个电路的实际结构,以下对每个电路的结构予以详细说明。
参照图11至图14,它们显示了用于在整个自检测过程中进行上述模拟检测的硬件电路。参照图11,它显示了遥测维护电路组件10的互连电路。图11中标号为“A”的部分显示了遥测维护电路与通常的蜂窝或蜂窝式适配器接口插板的塞尖及塞环(TIP及RING)线相连接的位置。标号为“继电器1”(“RELY1”)的继电器用于在维护操作检测时断开用户电话与蜂窝或蜂窝式接口的联系。相反,遥测维护电路也可在该继电器处连接于塞尖和塞环以便进行所说的检测。当把“ENABLE_TEST”信号置为HI时,晶体管Q3被迫进入饱和状态并激励继电器1,从而将维护电路连接于塞尖和塞环。图11中标号为“B”的部分显示了用户电话的挂机连接器,在该部分中,用户电话可以按两种可能的方式挂接于接口插板。J1是通常RJ11电话插座P1的双端头式连接器。
图11中标号为“C”的部分是音频接口电路,此电路用作塞尖和塞环线与音频之间的接口。T1是电话匹配用变压器。其功能是在接收和传输音频信号时保持电话的相类似的交流与直流电流特征。齐纳二级管D1和D2用于在电压高于±4.5V时截除任何的信号。还包括有一光隔离器(opto-isolator)SSR1,此器件连同晶体管Q4提供了用于闭合塞尖和塞环电路的机制。在把“Conn_Loop”信号置为HI时,晶体管Q4被迫进入饱和状态,然后启动SSR1从而闭合上述电路并且挂机。
图11中标号为“D”的部分是振铃检测电路,该电路包括两个主要的部分:振铃检测器集成电路U2,以及带有光隔离器的U9,所说的光隔离器提供适当的CMOS信号电平输出。当塞尖和塞环线上出现振铃电压时,U2的接头4与接头7之间会产生用作输出信号的电流。光隔离器U9对上述电流进行变换,然后将一个有效的LOW信号提供给I/O。
图11中标号为“E”的部分显示了环路电流检测器,该检测器包括一用于所检测到的环路电流的光隔离器。当检测被起动(在A部分中“Enable_Test”信号为HI)并且正在进行摘机(在C部分中“Conn_Loop”信号为HI)时,塞尖和塞环线成为闭合电路以便提供摘机电流。U17将摘机电流转换成提供给I/O的有效的Low信号。
图11中标号为“F”的部分是输入-输出音频电路,该电路包括U1的1/4以及一个运算放大器集成电路。上述电路的主要功能是隔离并预先放大呼入的音频信号。这一电路的输出称为“音频-入”(“Audio-In”)。而且,在这一部分中将本发明的遥测维护电路所产生的DTMF输出送至塞尖和塞环线。DTMF信号被标记为“单音-出”(“Tone-Out”)。
参照图12,标号为“G”的部分是DTMF音发生器,它包括一个DTMF音发生器U4以及用作输出放大器的U1的1/4。为了能产生DTMF单音,首先将一个四位的代码提供给U4中标号为“DTMF0-OUT”、“DTMF1-OUT”、“DTMF2-OUT”和“DTMF4-OUT”的输入接头。其次,在保持上述四位代码的同时将标号为“DTMF-OUT”的启动信号从Low电平转换为HI电平,从而能产生DTMF单音。在按U∶C而放大了音频之后,将音频在“单音-出”(“TONE-OUT”)处输出。为了使DTMF单音停止,使“DTMF-OUT”信号返回至低电平即可。
图12中标号为“H”的部分是输入/输出端口,即标号为U8的I/O端口集成电路。蜂窝或蜂窝式接口插板的微控制器使用这一集成电路去读取输入的数据并控制遥测维护组件的所有输出。端口A和C均为输入口,而端口B则为输出口。转接器J4是一个选择器,它用于按可选择的12或24小时来进行的自动定期检测。J5用于使对“自动应答”的呼叫启动。
图12中标号为“I.1”和“I.2”的部分是电源、数据以及控制连接器并且包括一个2×10的凸头连接器,该连接器用于导电以及向I/O端口发送或接收数据。上述部分还包括:一个接头连接器,它用于显示检测状态的外部LED;以及一个外部按钮,用此按钮可手工地启动所说的检测。图12中标号为“J”的部分是稳压器,并且带有一5V的固定正压稳压器,该稳压器向前述数字电路提供所需的电压。
遥测维护组件10包括六个单个的单音检测器,它们用于检测正在接收的ROH音、拨号音、忙音及占线音的音频路径、频率和定时韵调(timing cadence)。每个单音检测器均包括一运算放大器以及一单个的单音检测器集成电路。运算放大器的输入端与“音频-入”线相连。位于接头5与6之间的晶体管以及接头6与地线之间的电容可调节检测频率。当一个真实的单音与由RC所规定的单音相匹配时,就使得单音检测器的输出接头从HI转换成Low。
图12中标号为“k”的部分显示了拨号音检测器电路。当在U3的输入端出现真实的拨号音时,“拨号-检测”(“DIAL-DETECT”)线变为Low。图12中标号为“L”的部分显示了忙音检测器电路。当在U6的输入端出现真实的忙音时,“BUSY-DETECT”线变为Low。
图13中标号为“M”的部分显示了一个400Hz单音检测电路。当在U14的输入端出现真实的400Hz的单音时,“400-DETECT”线变为Low。
图14中标号为“N”的部分显示了一个800Hz单音检测电路。当在U13的输入端出现真实的800Hz的单音时,“800-检测”(“800-DETECT”)线变为Low。标号为“0”的部分显示了一个1020Hz声音检测器电路。当在U16的输入端出现真实的1020Hz的单音时,“1020-检测”(“1020-DETECT”)线变为Low。标号为“P”的部分显示了一个12KHz的单音检测器电路。当在U12的输入端出现真实的12KHz的单音时,“12KHz-检测”(“12Hz-DETECT”)线变为Low。
图13中标号为“Q”的部分显示了一个DTMF单音解码器,它包括一个DTMF单音检测器U11以及用作输入预放大器的U1的1/4。当在输入接头(IN-)处出现真实的DTMF单音时,控制线“DTMF-选通”(“DTMF-STROBE”)变为Low,同时集成电路进行解码。在对单音进行解码之后,将四位代码输出给U11中标号为“DTMF0-IN”、“DTMF1-IN”、“DTMF2-IN”以及“DTMF4-IN”的接头。然后,控制线“DTMF-选通”再次恢复成HI。标号为“R”的部分是一个交流监控器,它带有一个4.5V的欠压检测器U10。电阻R17和R33构成了一分压器,此分压器可使U10感知13V以下的电压而不是4.5V的电压。该电路在这样的前提下进行工作:当电压来自电源时,在遥测维护电路组件的输入端存在有14V的电压。在交流电源出现故障的情况下,该电压会降至不超过13V的后备电池的电平。所说的电路会检测到这种电压降落,并且,U10会使标号“AC-检测”(“AC-DETECT”)的线路变为Low。
以下是实现本发明的源代码:
Snopi nosb db noge nomo nopr ep
Snolist
Sinclude(reg252.pdf)
Slist
;***************************************************************
;
;Maxjack by Alexis V.Torres for Codecom Rural Comm.Inc.
;(C)Copyright Codecom Rural Comm.Inc.1993
;Telephone/cellular interfacc:
;Main program with the maintenance board
;
;11-29-92 maint.asm
;
;************************************************************************
;These are the universal landline phone key codes.
zero   equ    0ah           ;[O]key code
star   equ    0bh           ;[*]key code
pound  equ    0ch           ;[#]key code
;Buffer area pointers for the HS display and the TRU messages.
dspbuf_start         equ           80h            ;Start of 16 byte LCD display buffer
dspbuf_end           equ           90h            ;End of LCD display buffer
msgbuf_start         equ           90h            ;Start of TRU(etc)msg buffer
msgbuf_end           equ           0h             ;End of TRU msg buffer
main_flag            equ           0b0h           ;use indirect address for test flag
;hook_slic                        1
;dial                             2
;dtmf_                            3
;ring_test                        4
;ans_test                         5
main_flag_error      equ           0b1h
;hook_slic_error                  1              ;hook error
;hook_ring_error                  2              ;hook error
;dial_error                       3              ;dial tone error
;dtmf_error                       4              ;dtmf error
;ring_test_error                  5              ;ring error
;ans_test_error                   6              ;ring answer error
mainl_flag           equ           0b2h           ;ditto
;power_radio                      1              ;power radio error
;call_test                        2              ;call error
;call_tone                        3              ;call audio error
mainl_flag_error     equ           0b3h           ;ditto
;power_radio_error                1              ;spare
;call_test_error                  2              ;call spare error
;call_tone_error                  3              ;call audio spare error
				
				<dp n="d29"/>
;inuse                              4              ;inuse error
;1000hz                             5              ;1000hz error
error_code             equ           0b4h           ;final indication LED indication
;hook_slic_error                    1              ;hook
;hook_ring_error                    2              ;hook
;dial_error                         3              ;dial
;dtmf_error                         4              ;dtmf
;ring_test_error                    5              ;ring
;ans_test_error                     6              ;ring answer
;power_radio_error                  7              ;radio power
;call_test_error                    8              ;call
;call_tone_error                    9              ;call audio
;inuse                              10             ;inuse
;1000hz                             11             ;1000 hz
cero                  equ            00h
uno                   equ            08h
dos                   equ            04h
tres                  equ            0ch
cuatro                equ            02h
cinco                 equ            0ah
seis                  equ            06h
siete                 equ            0eh
ocho                  equ            01h
nueve                 equ            09h
estrella              equ            0dh
libra                 equ            03h
;*************************************************
;
;            Internal Ram variable definitions
;
;*************************************************
;Registers occupy bytes 00h-07h (reg. bank 0)
;r0         storage pointer (also address pointer for I/O expander)
;r1         pointer to storage of data from TRU
;r2         digit count
;r3         delay loop for bus timer
;r4         delay loop for bus timer
;r5         used in rohtone timer
;r6         used in send time
;r7         used in rohtone timer
;Variable storage locations
time_off1             data           10h            ;Measures off-hook time
time_off2             data           11h            ;Measures off-hook time
time_off3             data           12h            ;Measures off-hook time
time_on1              data           13h            ;Measures on-hook time
time_on2              data           14h            ;Measures on-hook time
				
				<dp n="d30"/>
pulse_digit             data           15h            ;Valuc of pulse dialed digit
in_use_off_timcr        data           16h            ;Checks for 2 sec after in use lamp

                                                      ;goes out to do cpd
ring_timer              data           17h            ;Timer checks time between rings
bell_timer              data           18h            ;Timer generates 20hz for ringer
bell_timer2             data           19h            ;Timer for ringer
gndstart_timer1         data           1ah            ;Releases GS line if no connect in lsec
gndstart_timer2         data           1bh            ;Same as above
;highpoint             data           1ch            ;Stores dph for tone tables
;lowpoint              data           1dh            ;Stores dpl for tone tables
highpoint               data           35h            ;Stores dph for tone tables
lowpoint                data           36h            ;Stores dpl for tone tables
test_min                data           1eh
;free                  data           1fh
;*****************************************************************
;
;The Ram area 20h thru 29h is reserved for use by the main
;module cither as data BYTEs or individual BITs
;
;****************************************************************
flags                   DATA           20h            ;This byte contains the following flags

                                                      ;as individually addressable bits
fhook                   bit            00h            ;Off hook flag set by coming off hook,

                                                      ;cleared when processed
fsend                   bit            01h            ;Send flag
fflash                  bit            02h            ;Flash flag
fhang                   bit            03h            ;Hang up flag
ftime                   bit            04h            ;40 second timer flag
fdigit                  bit            05h            ;Flag for pulse dig input
fonhook                 bit            06h            ;On hook flag set 700msec

                                                      ;After hup,cleared by coming off-hook
fdtmfin                 bit            07h            ;Dtmf input flag
inds                    DATA           21h            ;Indicators-this byte contains the

                                                      ;following bits:
roam                    bit            08h            ;Roam indicator
noserv                  bit            09h            ;No service indicator
lock                    bit            0ah            ;Lock indicator
rdis                    bit            0bh            ;Reset digit display
horn                    bit            0ch            ;Horn indicator
f_init                  bit            0dh            ;Set by TRU only!(1=inits done)
f_start                 bit            0eh            ;1=on hook ints disabled for 500ms
test_enable             bit            0fh            ;auto test

                                                      ;after first offhook to deglitch the 
                                                      ;contact bounces
indasc                  DATA           22b            ;Indicators &amp; audio switch control this

                                                      ;byte contains the following bits:
inuse                   bit            10h            ;In use indicator
				
				<dp n="d31"/>
ap1                    bit            11h            ;Audio path
ap2                    bit            12h            ;Audio path
test_end               bit            13h
;not_error            bit            14h            ;no error flag for self test
return_ring            bit            15h
error_flag             bit            16h            ;self test error
ring_second            bit            17h
io_status              DATA           23h            ;Bits 18h-1fh
strobe                 bit            1ch 
flags2                 DATA           24h            ;Bits 20h-27h
fdig_ready             bit            20h            ;Digit ready flag
fanswer                bit            21h            ;Ring answer flag
fsendtimer             bit            22h            ;Flag to send after 4 seconds
f_inuseofftiming       bit            23h            ;Flag shows timer is running to check

                                                     ;2 sec with in use lamp off
funlocktimer           bit            24h            ;Flag to unlock after 4 seconds
fdtone                 bit            25h            ;Flag shows DT is on
fdecoder_busy          bit            26h            ;Flag shows dtmf decoder has not

                                                     ;cleared yet
fbellsound             bit            27h            ;Flags ringer is sounding
px1_temp               DATA           25h            ;Input/output buffer for port px1-

                                                     ;contains these bits:
mitelq1                bit            28h            ;From dtmf decoder
mitelq2                bit            29h            ;From dtmf decoder
mitelq3                bit            2ah            ;From dtmf decoder
mitelq4                bit            2bh            ;From dtmf deeoder
power_hold             bit            2ch            ;Maintain power after power failure to

                                                     ;turn off TRU
spare1                 bit            2dh            ;Spare I/O pin
spare2                 bit            2eh            ;Spare I/O pin
no_ring                bit            2fh            ;Spare I/O pin
px2_temp               DATA           26h            ;I/O buffer for port px2 (30h-37h)
loopswitch_            bit            30h            ;Low closes loop
ring_                  bit            31h            ;Low turns on ring ps
mute                   bit            32h            ;Mute rx audio
roh_boost              bit            33h            ;Increase gain for roh tone
sw_sendtimer           bit            34h            ;Jumper in gives 4 sec send option
sw_dialtone            bit            35h            ;Jumper in=diff dial tone for roa

                                                     ;out means maintenance module
sw_gndstart            bit            36h            ;IN=loop start,OUT=groundstart
sw_data                bit            37h            ;Jumper in prevents,out allows digit

                                                     ;data to TRU after send (to allow

                                                     ;features from cell. switch)
lamps_temp             DATA           27h            ;Contains these bits:
;free                 bit            38h            ;Not really lamps--these store the
;free                 bit            39h            ;current status of indicators
;free                 bit            3ah
				
				<dp n="d32"/>
;free                bit            3bh
roamlamp              bit            3ch
noservlamp            bit            3dh
locklamp              bit            3ch
inuselamp             bit            3fh
flags3                DATA           28h           ;More flags-this byte contains the

                                                   ;following individually addressable

                                                   ;bits
frohtimeout           bit            40h           ;Set when rohtone has been on 1 minute
fcall                 bit            41h           ;Set when call incoming,clear if not
f_one_sec             bit            42h           ;Set when off hook for one sec so

                                                   ;change in inuse lamp won′t cause

                                                   ;remote hangup if phone taken off

                                                   ;hook quickly after local hangup
roh_on                bit            43h           ;Turns rohtone on &amp; off
fspec1                bit            44h           ;Flag for speeial use with specific TRU

                                                   ;processed in update_displays every

                                                   ;71.1ms,calls spec1
fspec2                bit            45h           ;Flag for special use with specific TRU

                                                   ;processed in on- or off-hook timers

                                                   ;every277.8usec,calls spec2
fremote_hup           bit            46h           ;Indicates remote hup for 700 msec

                                                   ;delay
flocktimer            bit            47h           ;Flag to lock after 2 seconds
				
				<dp n="d33"/>
;****************************************************************
;
;                                  Implemented TRU tasks
;
;****************************************************************
f_cmds                 DATA          29h                 ;Optional TRU specific task numbers
;TRU tasks are for calls from the main into the TRU module.
;Task1:
;a.)Power loss check for NEC 3700(see nae01)
;b.)Send change in hook switch status to OKI and also send initial CLR
;          for the Motorola(see oee02 and mae04)
;c.)Call rdbus routine to read indicator status in the Audiovox TRUs
;          (see tae01 and tbe01)
;d.)Monitor for silent alert mode in Audiovox CTX-3100A and set
;          silent alert mode if necessary(see tbe01)
;
;Task 2:
;a.)Dual NAM switching for NEC 3700(see nae01)
;
;Task 3:
;a.)Power loss check for NEC 3700(see nae01)
;b.)Sead any change in hook switch status to OKI and Motorola
;          (see mae04 and oee02)
;c.)Call rdbus routine to read indicator status in the Audiovox
;          TRUs(see tae01 and tbe01)
;d.)Monitor for silent alert mode in Audiovox CTX-3100A and set
;          silent alert mode if necessary(see tbe01)
;
;Task 4:
;a.)Call rdbus routine to read indicator status in the Audiovox
;          TRUs (see tae01 and tbe01)
;b.)Monitor for silent alert mode in Audiovox CTX-3100A and set
;          silent alert mode if necessary (see tbe01)
;****************************************************************
;
;The Ram area 2Ah thru 2dh is reserved for use by the TRU modules
;either as DATA bytes or individual BIT variables.
;
;****************************************************************
;TRU_bits1          data         2ah          ;Bit 50h through 57h
;TRU_bits2          data         2bh          ;Bit 58h through 5fh
;TRU_bits3          data         2ch          ;Bit 60h through 67h
;TRU_bits4          data         2dh          ;Bit 68h through 6fh
;
;            Used for the maintanence board   !check the tru routine!
io_m_b               data         2eh          ;Bit 70h through 77h
td0                  bit          70h
				
				<dp n="d34"/>
td1                   bit           71h
td2                   bit           72h
td3                   bit           73h
dtmf_out              bit           74h
enable_test           bit           75h
enable_tone           bit           76h
enable_tone_in        bit           77h
io_m_c                data          2fh            ;Bit 78h through 7fh
ext_led               bit           78h
enabble_special       bit           79h
enable_busy           bit           7ah
enable_16h            bit           7bh
conn_loop             bit           7ch
;*************************************************************
;
;More internal(BYTE addressable)ram variables
;
;*************************************************************
looptest_timer         data          30h           ;Delays looptest for 2ms after loopsw
looptest_timer2        data          31h           ;closes to allow SLIC to respond
display_delay          data          32h           ;Delays display update to every 71.1ms
dsp_ptr                data          33h           ;Handset LCD display buffer pointer
msg_ptr                data          34h           ;TRU message buffer pointer
;*****************************************************************
;

;The following bytes are reserved for the TRU modules for use
;only as DATA bytes (not BIT addressable)
;
;****************************************************************
;TRU_byte0          data          38h
;TRU_byte1          data          39h
;TRU_byte2          data          3ah
;TRU_byte3          data          3bh
;TRU_byte4          data          3ch
;TRU_byte5          data          3dh
;TRU_byte6          data          3eh
;TRU_byte7          data          3fh
;Stack occupies bytes 40h-5fh
;**************************************************************
;
;Digits dialed are stored in bytes from 60h to 7fh permitting
;a total of 32,including the SND code used as a terminator.
;
;**************************************************************
				
				<dp n="d35"/>
prefix                  data           60h           ;Only[0]or[1]are valid,else FFh
first_digit             data           61h           ;First three locations in the digit
second_digit            data           62h           ;buffer (emergency numbers,area code
third_digit             data           63h           ;start of 7digit number,etc.)
;****************************************************************
;8051 port1&amp;port3 bit definitions,(common to all units)
;****************************************************************
io_select               bit            p1.2
dt_pwm                  bit            p1.4          ;Dial tone pwm
twenty_hz_pwm           bit            p1.5          ;20hz pwm for ringer
;power_fail_           bit            p1.6          ;Input,0=power supply is failing
Ic_                     bit            p3.2          ;Loop current sense,(ExtInt0)
ring_ground_            bit            p3.4          ;Input:shows ground on ring lead
;strobe                bit            p3.5          ;Input:digit ready from DTMF decoder
a0                      bit            p1.6
a1                      bit            p3.5
;****************************************************************
;Power up entry point, and interrupt routine vectors:
;****************************************************************
org            0000h                                 ;Reset vector
jmp            init
org            0003h                                 ;ExtInt0 service vector
jmp            offhook_edge                          ;Off hook,flash,&amp;pulse dial
db             0ffh,0ffh,0ffh,0ffh,0ffh            ;Fill for Eprom and emulator
org            000bh                                 ;Timer0(t10)svc vector
jmp            onhook timer                          ;To keep track of how long on hook
db             0ffh,0ffh,0ffh,0ffh,0ffh
org            0013h                                 ;ExtInt1 service vector
jmp            int1_service                          ;Usually to read data from TRU
db             0ffh,0ffh,0ffh,0ffh,0ffh
org            001bh                                 ;Timer1(th0) svc vector
jmp            offhook_timer                         ;For periodic timer ints
db             0ffh,0ff,0ffh,0ffh,0ffh
org            0023h                                 ;Serial port svc vector
jmp            ser_port_service                      ;Usually to read data from TRU
db             0ffh,0ffh,0ffh,0ffh,0ffh
org            002bh                                 ;Timer2/ex12 svc vector
jmp            timer2_service
db             0ffh,0ffh,0ffh,0ffh,0ffh
				
				<dp n="d36"/>
               org           0033h                    ;PCA service vector

               jmp            pca_service             ;For puise width modulators

               db            ′(c)Copyright Codecom′

                 db            ′1992.′
Sinclude(main.msg)
Sinclude(tru.msg)
init:

                %set(intmask,0)                        ;Normally two interrupt levels unless

                                                      ;intmask set to other than zero in

                                                      ;TR Usection(TAE01_ASM:Audiovox)

         mov            sp,#3fh                      ;Stack starts at 40h

         clr            rs0                           ;Select register bank 0

         clr            rs1                           ;Ditto

         mov            a,#0                         ;To full ram with zero

         mov            r0,#0                        ;Point to first ram
fill_ram:

          mov           @r0,a                         ;One location at a time

         inc            r0                            ;Point to next location

         cjne           r0,#0,fill_ram              ;Fill up end of ram(FFh)

         clr            p1.2

         mov            r1,#main_flag

         mov            @r1,#0                       ;read second flag

         inc            r1

         mov            @r1,#0

         inc            r1

         mov            @r1,#0

         inc            r1

         mov            @r1,#0

         call           reset_io m                    ;reset the maintanence board

         mov            io_m_b,#0                    ;disable module

         call           write_io_m_ b

         mov            io_m_c,#0                    ;disable module

        call           write_io_m_c

        call           reset_io                      ;reset i/o expauded to #13

        mov            p2,#0f8h                     ;Set p2 to drive port expander

        mov            px1_temp,#11111111b          ;Initialize including power_hold on

        call           write_px1

        mov            px2_temp,#11110011b          ;Initialize:loopsw open,not ringing

        call           write_px2

        call           read_px2                      ;Read option switches

        nov            tmod,#00000011b              ;Timer0 is two timers,and timer1 can

                                                            ;be baud rate gen

        mov            ip,#01001010b                ;Set int priorities

        mov            ie,#11001011b                ;Enable PCA,Timer1,Timer0,Ext0

                                                          ;Tmr/Ext2,SerFort,Ext1 by TRU inits

        setb           it0                           ;ExtInt0 is edge trig′d

        setb           it1                           ;ExtInt1 is edge trig′d

        mov            cmod,#80h                    ;Counter off during idle,clock/12
				
				<dp n="d37"/>
        mov               ch,#0                         ;Load high counter

        mov               cl,#0                         ;Load low counter

        mov               ccap01,#0ffh                  ;Low byte for timer comparator

        mov               ccap0h,#0                     ;High byte for timer comparator

        mov               ccapm0,#049h                  ;PCA0:software timer

        mov               ccapm1,#0                     ;PCA1:(Dial Tone)off for now

        mov               ccapm2,#0                     ;PCA2(20hz pwm)is off now

        clr               tr1                            ;Off-hook int timer not running yet

        clr               tr0                            ;On-hook timer not running
; Initialize byte variables

        mov               time_on1,#0                   ;Initialize onhook interrupt timers

        mov               time_on2,#0

        mov               time_off1,#0                  ;Initialize offhook interrupt timers

        mov               time_off2,#0

        mov               time_off3,#0

        mov               flags,#0                      ;Clear all the flags

        mov               flags2,#0                     ;Clear all the flags

        mov               flags3,#0                     ;Clear all the flags

        mov               inds,#0tfh                    ;Initial vals

        mov               indasc,#0ffh                  ;Initial vals

        mov               pulse_digit,#0                ;0=no pulse digit(s) available now

        mov               f_cmds,#0                     ;0=no TRU task commanded
;Initialize bit variables

        clr               test_enable

        clr               test_end

        clr               error_flag

        clr               return_ring

        setb              fonhook                        ;1=Assume phone on hook on

                                                                       power up

        clr               f_init                         ;0=TRU init not completed yet

        clr               fremote_hup

        clr               fcall                          ;0=No incoming call(ALERT)yet

       call              clr_dsp                        ;Clear handset LCD display buffer

        call              clr_msg                        ;Clear TRU messages buffer

        call              specific_inits                 ;Do TRU specific initializations

        mov               ccap41,#Offh                  ;Low byte for watchdog match word

        mov               ccap4h,#Offh                  ;High byte for watchdog match word

        mov               ccapm4,#48h                   ;PCA4:Enable comparator&amp;interrupt

        orl               cmod,#40h                     ;Enable watchdog timer

        setb              cr                             ;Start PCA counter

        setb              tr0                            ;Start on hook timer
;Wait 2.55 second for TRU to wake up.Clear the dialed digits location,
;then point RO to digits buffer start(60h),and clear R2(dialed digits
;count).
time_wakeup:

    call          watchdog

   mov           a,time_on2                             ;Get elapsed time
				
				<dp n="d38"/>
       cjne          a,#2.55,time_wakeup           ;Wait here 2.55sec for tru wakeup

       mov           c,sw_gndstart                  ;Check GS-LS jumper,0=LS 1=GS

       mov           loopswitch_,c                  ;Save start mode

       cir           no_ring

       call          write_px2

       jmp           start
Sinclude(tru.asm)                               ;TRU module here,so INTMASK-can be
 
                                                       ;evaluated at assembly time
;****************************************************************
;
;          Start,and Re-Entry point following hang up
;****************************************************************
start:

       mov            r0,#60h                      ;Point to digit buffer start

       mov            a,#0ffh                      ;Fill with non-digits
clr_digbuf:

       mov            @r0,a                        ;One location at a time

       inc            r0                            ;Point to next location

       cjne           r0,#80h,clr_digbuf          ;Through 7fh

       mov            r0,#60h                      ;Point to buffer start

       mov            r2,#0                        ;Initialize digit count

       setb           f_start                       ;1=enable hook_switch deglitching

       clr            ie0                           ;Clear offhook int just in case

       setb           ex0                           ;Enable offhook int in case disabled
;Endless loop until we either detect an incoming call or we lift
;the handset to dial out.
hookchk:

       call           watchdog

       jb             test_enable,do_teat          ;if auto test activated

       mov            f_cmds,#1                    ;Load command ID

       call           trucmd                        ;Do task1 for TRU,if needed
       jb             fhook,first1                 ;Brif off hook

       jnb            fanswer,hookchk              ;Back ii no incoming ring detected

       jmp            ring_answer                   ;Answer ring,we went off hook during

                                                          ;an ALERT(incoming call)state!
first1:

       jmp            first
do test:
mov                     r1,#main_flag_error
mov                     @r1,#0                       ;set the tone error busy or 1000hz
mov                     r1,#main1_flag_error
mov                     @f1,#0                       ;set the tone error busy or 1000hzclr                     test end
clr                     errorr_flag
				
				<dp n="d39"/>
        clr           error_flag

        mov           r1,#main_flag

        mov           a,@r1                         ;read first flag

        anl           a,#00000001b                  ;check if hook was done

        call          start hook test                ;hook test
test_hook:

        jb            error_flag,rou_error

        call          dial_test                      ;dial test
test_dial:

        jb            error_flag,rou_error

        call          start_dtmf                     ;dtmf test
test_dtmf:

       jb             error_flag,rou_error

       call           start_ring_test                ;ring test
test_ring:

       jb             error_flag,rou_error

       call           start_ring_ans_test            ;ring answer test
test_ring_a:

      jb              error_flag,rou_error

      call            make_call                      ;call test

      jb              error_flag,rou_error

      jmp             umtil_fin_tim                  ;exit without errors
rou_error:

      call            error_acc                      ;load error variable
;      jmp             wait_end
until_fin_tim:

      setb            test_end

      clr             tr0

      mov             time_on2,#0                   ;Every 10 msec while on hook

      mov             time_on4,#0                   ;Reset for next 36

      mov             test_min,#0                   ;10msec×255=2.55sec

      setb            tr0
wait_end:
      call            watchdog                       ;be here until 1 min expire

      mov             a,test_min

      cjne            a,#23,wait_end               ;255×236=60.18

      call            fin_self                       ;return to normal
      jmp             hookchk                        ;return to normal
;************************************************
;start_hook_test-start hook test
;************************************************
start_hook_test:

       mov            r1,#main_flag                 ;read main flag

       mov            a,@r1

       orl            a,#00000001b

       mov            @r1,a                         ;set the off-hook flag

       setb           enable_test                    ;disconnect the telephone

       clr            conn_loop

       call           write_io_m_b                   ;and connect module

       call           reset_io_m                     ;reset the maintanence board

       call           write_io_m_b

       call           write_io_m_c
				
				<dp n="d40"/>
         cir            loopswitch_                     ;Othcr side has disconnccted

         call           writc_px2
tcst_hup:

         setb           frcmotc_hup

         call           hup

         mov            lamps_temp,#0

         call           write_io_c                      ;update the LEDS

         mov            r6,#10
nose:

         push           6

         mov            r6,#0ffh                       ;delay module

         loop_m:

         mov            r7,#0ffh

         djnz           r7,S

         call           watchdog

         djnz           r6,loop_m

         mov            r6,#0ffh                       ;delay module
loop_ma:

         mov            r7,#0ffh

         djnz           r7,S

         call           watchdog

         djnz           r6,loop_ma

         mov            r6,#0ffh                       ;delay module
loop_mb:

         mov            r7,#0ffh

         djnz           r7,S

         call           watchdog

         djnz           r6,loop_mb

         mov            r6,#0ffh                       ;delay module
loop_mc:

         mov            r7,#Offh

         djnz           r7,S

         call           watchdog

        djnz           r6,loop_mc

         pop            6

         djnz           r6,nose
test_hup2:

         clr            fanswer

         clr            fhook                           ;Clear the flag

         jnb            fhook,not_hook_det             ;no off-hook det.ok

                                                        ;off-hook detected error

         jmp            hook_error
not_hook_det:                                                  ;test off-hook

         setb           fonhook

         setb           conn_loop                       ;present off hook to the

         call           write_io_m_c                    ;interface
				
				<dp n="d41"/>
       mov           r6,#0ffh                       ;delay off hook
loop_m_off:

       mov           r7,#0ffh

       djnz          r7,S

       call          watchdog

       djnz          r6,loop_m_off

       mov           r6,#0ffh                       ;delay off hook
loop_m_off2:

       mov           r7,#0ffh

       djnz          r7,S

       call          watchdog

       djnz          r6,loop_m_off2

       mov           r6,#0ffh                       ;delay off hook
loop_m_off3:

       mov           r7,#0ffh

       djnz          r7,S

       call          watchdog

       djnz          r6,loop_m_off3

       mov           r6,#0ffh                       ;delay off hook
loop_m_off4:

       mov           r7,#0ffh

       djnz          r7,S

       call          watchdog

       djnz          r6,loop_m_off4

       mov           r6,#0ffh                       ;delay off hook
loop_m_off5:

       mov           r7,#0ffh

       djnz          r7,S

       call          watchdog

       djnz          r6,loop_m_off5
test_fhook:

       jb            fhook,detected_hook            ;if hook detected ok

                                                            ;not off-hook det error

       jmp           hook_error
detected_hook:

      clr           ex0                             ;Disable offhook int til dial tone to

                                                           ;prevent dialing due to bounce

       clr           hookswout                       ;Show off-hook to TRU

       setb          hookswout_                      ;Ditto

       clr           fhook                           ;Clear the flag
dt_delayl:

       call          watchdog

       jnb           lc,still_off_hook

       jmp           hook_error                      ;fail off hook
still_off_hook:


       jb            f_start,dt_delayl              ;Will be set after 500ms deglitching 
       cir           ie0                             ;Clear offhook int flag just in case

       setb          ex0

       setb          fdtone                          ;1=the Dial Tone is on

       call          dtone                           ;Enable the Dial Tone

       ret                                           ;exit from hook test
				
				<dp n="d42"/>
hook error:

       mov            r1,#main_flag_error

       mov            @r1,#1                       ;hook slic error

       setb           error_flag

       ret
;*************************************************
;dial_test check the dial tone
;*************************************************
dial_test:

        mov           r1,#main_flag                ;read main flag

        mov           a,@r1

        orl           a,#00000010b

        mov           @r1,a                        ;set the dial tone flag

        mov           r6,#0ffh                     ;delay off hook
delay_dial:

        mov           r7,#0ffh

        djnz          r7,S

        call          watchdog

        djnz          r6,delay_dial

        mov           r6,#0ffh                     ;delay off hook
delay_dial2:

        mov           r7,#0ffh

        djnz          r7,S

        call          watchdog

        djnz          r6,detay_diai2

        clr           trl                           ;wait 711 msec to detect dial

        mov           time_off1,#0

        mov           time_off2,#0

        setb          tr1
verify_dial:

        call          read_io_m_a                   ;check dial tone

        anl           a,#00000001b

        cjne          a,#00000001b,dial_ok        ;if 0 dial ok

        call          watchdog

        mov           a,time off2                  ;dial is not detected

        cjne          a,#10,verify_dial           ;wait 711 msecs if busy not detected

                                                          ;dial tone fail

        mov           r1,#main_flag_error

        mov           @r1,#3                       ;dial error

        setb          error_flag

        ret
dial_ok:                                             ;no error

        ret
;*************************************************
;start_dtmf-start the dtmf
;*************************************************
start_dtmf:

        clr           fdtone

        mov           ccapm1,#0
				
				<dp n="d43"/>
       anl             io_m_b,#0f0h

       orl             io_m_b,#cero                    ;send 0

      call            send_dtmf

       call            delay_dtmf

       call            disable_dtnf

       call            delay_dtmf

       call            get_test
test_cero:

       cjne            a,#0h,dtmf_error_flag          ;verify 0

       anl             io_m_b,#0f0h

       orl             io_m_b,#uno                     ;send 1

       call            send_dtmf

       call            delay_dtmf

       call            disable_dtmf

       call            delay_dtmf

       call            get_test
test_1:

       cjne            a,#1h,dtmf_error_flag          ;verify 1

       anl             io_m_b,#0f0h
       orl             io_m_b,#dos                     ;send 2

       call            send dtmf

       call            delay_dtmf

       call            disable_dtmf

       call            delay_dtmf 

       call            get_test
test_2:

       cjne            a,#2h,dtmf_error_flag          ;verify 2

       anl             io_m_b,#OfOh

       orl             io_m _b,#tres                   ;send 3

       call            send_dtmf

       call            delay_dtmf

       call            disable_dtmf

       call            delay_dtmf

       call            get_test
test_3:

       cjne            a,#3h,dtmf_error_flag          ;verify 3

       anl             io_m_b,#0f0h

       orl             iom_b,#cuatro                   ;send 4

       call            send_dtmf

       call            delay_dtmf

       call            disable_dtmf

       call            delay_dtmf

       call            get_test
test_4:

       cjne            a,#4h,dtmf_error_flag          ;verify 4

       jmp             go_to_5
dtmf_error_flag:

       jmp             error_dtrnf
go_to_5:

       anl             io_m_b,#OfOh

       orl             io_m_b,#cinco                   ;send 5

       call            send_dtmf

       call            delay_dtmf

       call            disable_dtmf

       call            delay_dtmf
				
				<dp n="d44"/>
       call            gct_test
test_5:

       cjnc            a,#5b,dtmf_error_flag       ;verify 5

       anl             io_m_b,#0f0h

       orl             io_m_b,#seis                 ;send 6

       call            send_dtmf

       call            delay_dtmf

       call            disable_dtmf

       call            delay_dtmf

       call            get_test
test_6:

       cjne            a,#6h,dtmf_error_flag       ;verify 6

       anl             io_m_b,#0f0h

       orl             io_m_b,#siete                ;send 7

       call            send_dtmf

       call            delay_dtmf

       call            disable_dtmf

       call            delay_dtmf

       call            get_test
test_7:

       cjne            a,#7h,dtmf_error_flag       ;verify 7

       anl             io_m_b,#0f0h

       orl             io_m_b,#ocho                 ;send 8

       call            send_dtmf

       call            delay_dtmf

       call            disable_dtmf

       call            delay_dtmf

       call            get_test
test_8:

       cjne            a,#8h,dtmf_error_flagl      ;verify 8

       anl             io_m_b,#0f0h

       orl             io_m_b,#nueve                ;send 9

       call            send dtmf

       call            delay_dtmf

       call            disable_dtmf

       call            delay_dtmf

       call            get_test
test_9:

       cjne            a,#9h,dtmf_error_flagl      ;verify 9

       anl             io_m_b,#0f0h

       oft             io_m_b,#05h                  ;send a

       call            send_dtmf

       call            delay_dtmf

       call            disable_dtmf

       call            delay_dtmf

       call            get_test
test_a:

       cjne            a,#Oah,dtmf_error_flagl     ;receive a

       anl             io_m_b,#0f0h

       orl             io_m_b,#Odh                  ;es b

       call            send_dtmf

       call            delay_dtmf
       call            disable_dtmf

       call            delay_dtmf

       call            get_test
				
				<dp n="d45"/>
test_b:

        cjne          a,#Obh,dtmf_error_flagl

        jmp           go_to_c
dtmf_error_flagl:

        jmp           error_dtmf
go_to_c:

        anl           io_m_b,#OfOh

        orl           io_m_b,#O3h                      ;es 3
        call          send_dtmf
        call          delay_dtmf

        call          disable_dtmf

        call          delay_dtmf

          call          get_test
test_c:

        cjne          a,#Och,dtmf_error_flag1

        anl           io_m_b,#0f0h

        orl           io_m_b,#0bh                      ;es d

        call          send_dtmf

        call          delay_dtmf

        call          disable_dtmf

        call          delay_dtmf

        call          get_test
test_d:

        cjne          a,#0dh,dtmf_error_flagl

        anl           io_m_b,#0f0h

        orl           io_m_b,#07h                      ;es 7

        call          send_dtmf

        call          delay_dtmf

        call          disable_dtmf

        call          delay_dtmf

        call          get_test
test_e:

        cjne          a,#0eh,dtmf_error_flagl

        anl           io_m_b,#0f0h

        orl           io_m_b,#0fh                      ;es f

        call          send_dtmf

        call          delay_dtmf

        call          disable_dtmf

        call          delay_dtmf

        call          get_test
test_f:


        cjne          a,#0fh,dtmf_error_flag1

        ret                                             ;exit without errors
error_dtmf:

        mov           r1,#main_flag_error

        mov           @r1,#4                           ;dtmf error

        setb          error_flag

        ret
;*************************************************
;start_ring_test-start the ring test
;*************************************************
start_ring_test:
;init the ringing
				
				<dp n="d46"/>
        mov          r1,#main_flag                   ;read main flag

        mov          a,@r1

        or1          a,#00001000b

        mov          @r1,a                           ;set the ring test flag

        clr          ring_second

        clr          conn_loop                        ;present an on hook

        call         write_io_m_c

        setb         fremote_hup

        call         hup

        mov          r6,#6
loop_ring_wait:

        push         6

        mov          r6,#0ffh                        ;delay module
loop_mbb:

        mov          r7,#0fh

        djnz         r7,S

        call         watchdog

        djnz         r6,loop_mbb

        mov          r6,#0ffh                        ;delay module
loop_mcc:

        mov          r7,#0ffh

        djnz         r7,S

        call         watchdog

        djnz         r6,loop_mcc

        pop          6

        djnz         r6,loop_ring_wait

                                                            ;incoming call

        clr          ap1                              ;init an incoming cal

        jb           lc_,loop_ring_off

        jmp          ring_flag
loop_ring_off:                                               ;loop here until ring start or

        clr          tr0                              ;2 sec expire

        mov          time_on2,#0

        mov          time_onl,#0

        setb         tr0
wait_2_sec:

        call         watchdog

        jnb          fanswer,not_answer

        jmp          ring_flag                        ;answer occurred error
not_answer:

        call         read_io_m_a

        anl          a,#00000100b

        cjne         a,#00000100b,ring_starts       ;if 0 ring started

        mov          a,time_on2                      ;check if 2 second expire

        cjne         a,#200,wait_2_sec              ;wait 2sec to stop the dtmf

        jmp          ring_flag                        ;2sec expire,error
ring_starts:

        mov          r6,#0ffh                        ;delay module
loop_mbbc:

        mov          r7,#Offh
				
				<dp n="d47"/>
         djnz           r7,S

         call           watchdog

         djnz           r6,loop_mbbc

         mov            r6,#0ffh                       ;delay module
loop_mccd:

         mov            r7,#0ffh

         djnz           r7,S

         call           watchdog

         djnz           r6,loop_mccd
ring_start:                                                    ;check for ring 1.3s continuity

         clr            tr0

         mov            time_on2,#0

         mov            time_on1,#0

         setb           tr0
wait_130msec:                                                  ;check ring during 1.3sec

         call           watchdog

         jnb            fanswer,not_answerl

         jmp            ring_flag                       ;answer occured error
not_answer1:

         call           read_io_m_a
test_130:

         anl            a,#00000100b                   ;should be low during 1.3sec

         cjne           a,#00000100b,ring_expire

         jmp            ring_flag                       ;ring fail within 1.3sec
ring_expire:

         mov            a,time_on2

         cjne           a,#90,wait_130msec            ;wait 130msec
wait_250msec:                                                ;the ring should stop after 1.5s

         call           watchdog                        ;but we will wait 2.5s to check if

         call           read_io_m_a                     ;it stop
test_250:

         anl            a,#00000100b                   ;should be low during 2sec more

         cjne           a,#00000100b,ring_not_expire
test_stop:

         jmp            ring_stop_                      ;ring stop before 2.5s
ring_not_expire:

         mov            a,time_on2                     ;after 1.5sec it should be high

         cjne           a,#250,wait_250msec           ;wait 250msec
test_flag:

        jmp             ring_flag                       ;ring did not stop within 2.5s error
ring_stop_:                                              ;wait 2.55s

        clr             tr0

        mov             time_on2,#0

        mov             time_on1,#0

        setb            tr0
wait_2_seca:

        call            watchdog
        jnb             fanswer,not_answer2

        jmp             ring_flag                       ;answer occurred error
not_answer2:

        mov             a,time_on2
				
				<dp n="d48"/>
       cjne           a,#255,wait_2_seca             ;wait 2.55s to stop the dtmf

                                                             ;second loop
       jb             ring_second,ring_stop1

       setb           ring_second                      ;chcck ring 2 times

       jmp            loop_ring_off                    ;start again
ring_flag:

       setb           ap1                              ;clear incoming call

       mov            r1,#main_flag_error

       mov            @r1,#5                          ;ring error

       setb           error_flag
ring_stop1:
test_timbre:

       ret                                             ;exit without error
;*************************************************
;start_ring_ans_test-answer the ring
;*************************************************
start_ring_ans_test:

                                                             ;init the ringing

        mov           r1,#main_flag                   ;read main flag

        mov           a,@r1

        orl           a,#00010000b

        mov           @r1,a                           ;set the ring test flag
loop_ring_off2:                                             ;wait here until ring start again

        clr           tr0

        mov           time_on2,#0

        mov           time_on1,#0

        setb          tr0
wait_2_sec2:

        call          watchdog

        jnb           fanswer,not_answera             ;if ring answer exit

        jmp           ans_flag 
not_answera:

        call          read_io_m_a

        anl           a,#00000100b

        cjne          a,#00000100b,ring_present      ;if cero ring present

        mov           a,time_on2

        cjne          a,#200,wait_2_sec2             ;wait 2sec to stop

        jmp           ans_flag                         ;2sec expire
ring_present:

        setb          conn_loop                        ;answer the ring

        call          write_io_m_c

        mov           r7,#0ffh                        ;delay to allow time to set fanswer
wait_ans:

        mov           r6,#0ffh

        djnz          r6,S

        call          watchdog

        djnz          r7,wait_ans

        mov           r7,#0ffh
wait_ansa:
				
				<dp n="d49"/>
        mov            r6,#0ffh

        djnz           r6,s

        call           watchdog

        djnz           r7,wait_ansa
test_ans:

        jb             fanswer,ok_ring                 ;if answer, ring ans ok

        jmp            ans_flag                         ;didn′t answer error
ans_flag:

        mov            r1,#main_flag_error

        mov            @r1,#6                          ;ring error

        setb           error_flag

        setb           ap1

        clr            fanswer

        ret
ok_ring:                                                       ;exit without error
timbre:

        clr            fanswer

        setb           ap1                              ;clear incoming call

        ret
;************************************************
;make_call-make a call to test the radio
;***************************************
make_call:

        mov           r1,#main1_flag                   ;read main1 flag

        mov           a,@r1

        orl           a,#00000001b

        mov           @r1,a                            ;set the call test flag
test_mute:

        jnb           power_,power_is_ok               ;if radio ok line should be low(0)

        mov           r1,#main1_flag_error

        mov           @r1,#1                           ;set the power line error

        setb          error_flag

        jmp           pre_onhook
power_is_ok:

        mov           a,#func                          ;function to read the phone number

        call          wrbus

        mov           a,#7

        call          wrbus

        call          clr_dsp

        mov           a,#star

        call          wrbus

        mov           r7,#0ffh                         ;delay to allow time to send number
wait_min:                                                    ;to interface

        mov           r6,#0ffh

        djnz          r6,S

        call          watchdog

        djnz          r7,wait_min

        mov           r7,#0ffh
wait_mina:

        mov           r6,#0ffh
				
				<dp n="d50"/>
         djnz             r6,S

         call             watchdog

         djnz             r7,wait_mina

         mov              a,#9h

         call             wrbus

         mov              a,#0ah

         call             wrbus

                                                        ;generate a call to its phone number

         mov              a,#dspbuf_start          ;Get current pointer

         add              a,#3

         mov              r1,a

         mov              a,@r1                    ;Read msg in buffer

         anl              a,#0fh

         call             wrbus

         inc              r1

         mov              a,@r1                    ;Read msg in buffer

         anl              a,#0fh

         call             wrbus

         inc              r1

         mov              a,@r1                    ;Read msg in buffer

         anl              a,#0fh

         call             wrbus

         inc              ri

         nov              a,@r1                    ;Read msg in buffer

         anl              a,#0fh

         call             wrbus

         inc              r1

         mov              a,@r1                    ;Read msg in buffer

         anl              a,#0fh

         call             wrbus

         inc              r1

         mov              a,@r1                    ;Read msg in buffer

         anl              a,#0fh

         call             wrbus

         inc              r1

         mov              a,@r1                    ;Read msg in buffer

         anl              a,#0fh

         call             wrbus

         setb             fsend                     ;Set send flag

         mov              a,#send                  ;make a call
         call             wrbus
         setb             enable_special            ;enable Q4

         call             write_io_m_c
test_mute1:

         clr              mute                      ;do not mute

         call             write_px2
				
				<dp n="d51"/>
        cir           tr1                           ;delay to check inuse

        mov           time_off1,#0

        mov           time_off2,#0

        setb          tr1
delay_call:

        mov           a,time off2

        call          watchdog

        cjne          a,#80,delay_call             ;wait 1?seconds
test_mute2:                                                ;test busy tone

        clr           tr1

        mov           time_off1,#0

        mov           time_off2,#0

        mov           time_off3,#0

        setb          tr1
cont_waiting:
        jnb           inuse,still_inuse

        mov           r1,#main1_flag_error

        mov           @r1,#4                       ;set the inuse error

        jmp           call_error                    ;if iube disapear set error
still_inuse:

        call          read_io_m_a                   ;check dial tone

       anl           a,#00000001b
       cjne          a,#00000001b,busy_ok         ;if 0 busy ok

        call          read_io_m_a                   ;check dial tone

        anl           a,#00001000b

        cjne          a,#00001000b,t1000hz        ;if 1000khz busy ok

        mov           a,time_off3                  ;busy is not detected

        call          watchdog

        cjne          a,#1h,cont_waiting          ;wait 18.2 secs if busy not detected

        mov           r1,#main1_flag_error

        mov           @r1,#3                       ;set the tone error busy or 1000hz
call_error:

        mov           a,#end1                      ;make a call

        call          wrbus
        setb          error_flag                    ;present and on hook

        jmp           pre_onhook
t1000hz:                                                   ;950hz-1100hz tone detected
busy_ok:                                                   ;400hz-620hz tone detected

        mov           a,#end1                      ;make a call

        call          wrbus
pre_onhook:

        clr           conn_loop                     ;present and on-hook

        call          write_io_m_b                  ;and connect module

        call          hup
        ret  ;************************************************
;error_acc-set the error code
;************************************************
error_acc:

       mov            r1,#main_flag_error

       mov            a,@r1
				
				<dp n="d52"/>
        cjnc           a,#1,check_hook_ring

        mov            r1,#error_codc               ;hook slic error

        mov            @r1,#1

        jmp            exit_error
check_hook_ring:

        cjne           a,#2,check_dial_flag

        mov            r1,#error_code               ;hook ring error

        mov            @r1,#2

        jmp            exit_error
chcck_dial_flag:

        cjne           a,#3,check_dtmf_flag

        mov            r1,#error_code               ;dial error

        mov            @r1,#3

        jmp            exit_error
check_dtmf_flag:

        cjne           a,#4,check_ring_flag

        mov            r1,#error_code               ;dtmf error

        mov            @r1,#4

        jmp            exit_error
check_ring_flag:

        cjne           a,#5,check_ring_ans_fiag

        mov            r1,#error_code               ;ring detection error

        mov            @r1,#5

        jmp            exit_error
check_ring_ans_flag:

        cjne           a,#6,check_power_flag

        mov            r1,#error_code               ;ring answer error

        mov            @r1,#6

        jmp            exit_error
check_power_flag:                                         ;check calls flag

        mov            r1,#main1_flag_error

        mov            a,@r1

        cjne           a,#1,check_call_test

        mov            r1,#error_code               ;power radio error

        mov            @r1,#7

        jmp            exit_error
check_call_test:

        cjne           a,#2,check_busy_test

        mov            r1,#error_code               ;xxx error

        mov            @r1,#8

        jmp            exit_error
check_busy_test:

        cjne           a,#3,check_inuse_test

        mov            r1,#error_code               ;busy tone error

        mov            @r1,#9

        jmp            exit_error
check_inuse_test:

        cjne           a,#4,check_1000_test

        mov            r1,#error_code               ;inuse error

        mov            @r1,#10

        jmp            exit_error
check_1000_test:
        cjne           a,#5,exit_error

        mov            r1,#error_codc               ;1000hz tone error

        mov            @f1,#11
				
				<dp n="d53"/>
    jmp         exit_error
exit_error:
    ret
;************************************************
;fin_self-return to normal
;************************************************
fin_sell:

     clr         conn_loop                 ;present on hook to the

     call        write_iom_c               ;interface

     call        hup

     clr         enable_test               ;connect the the telephone

     call        write_io_m_b              ;and disconnect module

     ctr         test_enable               ;init maint test

     ctr         test_end                  ;finish test

     ctr         error_flag                ;error flag

     jnb         error_flag,turn_on_led

     clr         ext_led                   ;turn off external led while testing

     call        write_io_m_c              ;turn on/off the external led

     call        loop_bad
turn_on_led:

     setb        ext_led                   ;turn off external led while testing

     call        write_io_m_c              ;turn on/off the external led

     call        loop_bad

     clr         ext_led                   ;turn off external led while testing

     call        write_io_m_c              ;turn on/off the external led

     call        loop_bad

     setb        ext_led                   ;turn off external led while testing

     call        write_io_m_c              ;turn on/off the external led

     call        loop_bad

     clr         ext_led                   ;turn off external led while testing

     call        write_io_m_c              ;turn on/off the external led

     call        loop_bad

     setb        ext_led                   ;turn off external led while testing

     call        write_io_m_c              ;turn on/off the external led

     call        loop_bad
test_4on:

     clr         ext_led                   ;turn off external led while testing

     call        write_io_m_c              ;turn on/off the external led

     call        loop_bad

     ret
loop_bad:

     mov         r7,#0ffh                 ;delay to allow time to set fanswer
wait_emb:

     mov         r6,#0ffh

     djnz        r6,S

     call        watchdog
				
				<dp n="d54"/>
        djnz            r7,wait_emb

        mov             r7,#0ffh
wait_emba:

        mov             r6,#0ffh

        djnz            r6,S

        call            watchdog

        djnz            r7,wait_embs

        ret
;Get here when we lifted the handset to dial.
first:

        call            ctr_msg                     ;Clear previous TRU messages

        ctr             ex0                         ;Disable offhook int til dial tone to

                                                          ;prevent dialing due to bounce

        clr             hookswout                   ;Show off-hook to TRU

        setb            hookswout                   ;Ditto

        clr             fhook                       ;Clear the flag
dt_delay:

        call            watchdog

        mov             f_cmds,#4                  ;NOTE:INT0&amp;TIMER0 have been suspended

                                                          ;at this point-do not use any tru
                                                          ;specific function which relies on
  
                                                          ;these interrupts.

       call            trucmd                       ;Perform any TRU specific commands

      jb              f_start,dt_delay            ;Will be set after 500ms deglitcting

       clr             ie0                          ;Clear offhook iht flag just in case
test_lc:

       jnb             lc_,alert_check             ;Brif still off hook after 500ms
test_Ic1:

       call            hup                          ;Phone put back on hook=500msec

       jmp             start
alert_check:

       setb            ex0                          ;Reenable offhook int(DT is on now)

       jb              inuse,make_dt               ;Brff not INUSE,we are ready to dial

       jmp             wait                         ;If already INUSE probably answered

                                                         ;an incoming call by coming offhook
;We are off hook for 500ms lets generate a dial tone.
make dt:

       setb            fdtone                       ;1=the Dial Tone is on

       call            dtone                        ;Enable the Dial Tone

       call            get                          ;Get a character or exit if hang up

       jb              inuse,check_prefix

       clr             fdtone

       mov             ccapm1,#0

       jmp             wait
				
				<dp n="d55"/>
check_prefix:

        jb             lock,prefix_0                  ;BrifTRU isn′t locked

        cjne           a,#pound,nosend               ;Brif locked,only#(unlock)is valid
prefix_0:

        cjne           a,#zero,prefix_1              ;Brif not a[0]

        jmp            store_it                        ;Go to store[0]as prefix
prefix_1:
        cjne           a,#1,no_prefix                ;Brif not a [1] either

        jmp            store_it                        ;Go to store[1]as prefix
no_prefix:

        inc            r0                              ;Leave prefix slot unchanged(FFh)

        inc            r2                              ;But up the digit count
; Store current digit and get another one until time to send them out.
store it:

        cjne           r0,#7fh,do_store_it           ;Brif digit buffer is not full yet

        jmp            check_number _                  ;Brif buffer is full,w/o storing
do_store_it:

        mov            @r0,a                          ;Store the digit

        inc            r0                              ;Advance digit buffer pointer
;Check the entered digits and analyze them for valid sequences.
check_number:

        clr            fsendtimer                      ;Assure it is off

        mov            a, first_digit                 ;Point to 1st digit slot

        cjne           a,#0ffh,check_one             ;Brif first digit entered

        jmp            check_send                      ;Else check if time to send
check_one:

        cjne           a,#pound,check_send           ;Brif not[#](lock,unlock,etc.)

        mov            a,second_digit                 ;Point to 2nd digit it first is[#]

        cjne           a,#0ffh,check_two             ;Brif second digit entered

        jmp            check_send                      ;Else check if time to send
check_two:

        cjne           a,#pound,check_nam            ;Brif not[#][#](lock or unlock)

        mov            a,third_digit                  ;Two #′s might be lock or unlock

        cjne           a,#pound,check_unlock         ;Three #′s mean locking

        jnb            lock,nosend                    ;Do not lock if already locked

        jmp            lock_it                         ;[#][#][#]means locking
check_nam:

        cjne           a,#star,check_send            ;Abort if not[#][*]sequence

        mov            a,third_digit                  ;Else get the third digit also

        cjne           a,#0ffh,check_naml            ;Brif third digit entered

        jmp            check_send                      ;Else check if time to send
check_nam1:

        mov            f_cmds,#2                      ;Load function number,then go to

        call           trucmd                          ;Switch to alternate NAM
,Abort on invalid number(dial)sequences.
nosend:

        cir            funlocktimer                    ;Turn off unlock timer#sign set it
				
				<dp n="d56"/>
       sctb           fonhook                       ;As if on hook

       sctb           ic0                           ;Go to Extlnt0 service

       jmp            start                         ;just like off hook again
check_unlock:

       cjne           a,#0ffh,unlocking_it        ;Brif any digit was dialed after ##

       jmp            check_send                    ;Else go to check if time to send
unlocking_it:

       setb           funlocktimer                  ;Will send after 2sec w/o SND code

       jmp            get_nex1                      ;to avoid unlock code being sent fikc

                                                    ;a valid number
;Get here if the digit sequence entered did not qualify as any
;of the special function(lock,unlock,dual NAM,etc)options.
check send:

       jb             sw_sendtimer,chcck_intl      ;Brif sw7=1,interntnl calls enabled

       setb           fsendtimer                    ;Enable sending after 4 sec ff sw7=0

       jmp            get_next                      ;And back for next digit
check_intl:

       mov            a, preftx                    ;Test for prefix in acc

       cjne           a,#zero,check_op            ;Brff not[0]

       mov            a,first_digit                ;Else get the first real digit

       cjne           a,#1,check_op               ;Brif not[1],may be operator call

       setb           fsendtimer                    ;International call!Starts with 01-

       jmp            get_next                      ;Back for more, only timer sends now!
check_op:

       mov            a,prefix                     ;Get prefix digit again

       cjne           a,#10,check_service         ;Brif prefix is not 0

       cjne           r2,#0,check_service         ;Brff digit(s) also were dialed

       setb           fsendtimer                    ;Else it may be a call to operator
check_service:

       cjne           r2,#3,check distance        ;Brif not 3 digits

       mov            a,second_digit               ;Else if emergency, inform. etc.

       cjne           a,#1,check distance         ;Brif second digit is 1

       mov            a,third_digit                ;Get third digit
       cjne           a,#1,check_distance         ;Brff third digit is not 1

       jmp            send_it                       ;It must be an emerg., send it
check_distance:

       cjne           r2,#10,check_local          ;Ten digit was dialed?

       jmp            send_it                       ;Send on 10th unless international
check_local:

       cjne           r2,#7,get_next              ;Brff less then seven digit was dialed
       setb           fsendtimer                    ;Prepare to send in 4 sec

       mov            a,second_digit               ;Get 2nd digit

       subb           a,#1                         ;Is it a #1?

       jz             get_next                      ;Brff so,could be area code,or local

       mov            a,second_digit               ;Get 2nd digit again
				
				<dp n="d57"/>
       subb           a,#10                    ;Is it a0?

       jz             get_next                  ;Brif so, maybe area code, maybe local

       ctr            fsendtimcr                ;Don′t want another,send 5sec later

       jmp            send_it
get_next:

       inc            r2

       call           get                       ;Get a new digit

       jmp            store_it                  ;Do all the checks with the new digit
;*************************************************
;;           Dialing done,send the number out
;
;************************************************
;Check if the TRU is locked,and abort if no unlock code was entered.
send it:

        jb           lock,send1                ;Brif TRU is not locked
locked:

        mov          a,third_digit             ;Get third digit

        cjne         a,#0ffh,send1            ;Brif any digit entered

        jmp          nosend                     ;Don′t send if no unlock code entered
;Send dialed digit.
send1:

        setb         mute                       ;Mute rx audio

        call         write_px2

        mov          @r0,#send                 ;Put send at end of digits

        mov          a,#clear                  ;Clear code

        call         wrbus                      ;Put clear code first to clear any

                                                      ;digits from TRU memory in case

                                                      ;handset has entered some first

       mov           r0,#60h                   ;Reset pointer to show storage

        mov           a,@r0                     ;Put preftx in acc
        cjne          a,#0ffh,out

        inc           r0                         ;Skip prefix if it is ff
out:    mov           a,@r0

        call          wrbus                      ;Write to the bus
 
        jnb           fhang,send_ok
test_lc2:

        call          hup                        ;Abort dump if hangup
        jmp           start
send_ok:

        inc           r0

        cjne          a,#send,out              ;Keep on til SND code

        setb          fsend                      ;Set send flag

        clr           mute                       ;Unmute rx audio

       call          write_px2
				
				<dp n="d58"/>
;Dialing done,conditionally echo digit to TRU,then wait for
;further possible digits(extension,ctc.),or let the interrupts
;take over the show.
wait:   call           get                           ;Check for any digits from MJ phone

       jnb            sw_data,wait                  ;Discard if data after snd is disabled

       call           wrbus                          ;Else send data to TRU

       jmp            wait                          ;Loop til we or other party hangs up
;*************************************************
;      
;             Dial Tone Generator
;
;*************************************************
;This routine selects and generates the proper dial tone,
;corresponding to our current(roam,holler,etc)status.dtone:  push          psw

       jb            lock,serv_check

       mov           dptr,#table_350               ;350hz for lock

       jmp           tone_out
serv_check:

       jb            noserv,roam_check

       mov           dptr,#table_620               ;620hz tone for no-serv

       jmp           tone_out
roam_check:

       jb            sw_dialtone,normal            ;If option sw is closed(=0)make a

                                                          ;diff dial tone for roam

       jb            roam,normal

       mov           dptr,#table_roam              ;440-620hz for roam

       jmp           tone_out
normal:mov            dptr,#table_dt                ;350-440hz(normal DT)
tone_out:

       mov           lowpoint,dpl                  ;Remember where the table starts

       mov           highpoint,dph

       mov           ccapm1,#01000010b             ;Enable the tone

       pop           psw

       ret
;*************************************************
;
;Get a digit from the handset keypad
;
;*************************************************
;
;This routine processes the digit input and/or process flags.
;On return-returns data in acc
get:

       push           psw
get1:

       mov            f_cmds,#3                    ;Flag indicates which functions apply

       call           trucmd                        ;Perform any TRU specific commands

       call           watchdog
				
				<dp n="d59"/>
  ;Wait for a pulse. If the pulse was not flagged as a pulsc dial input

  ;by FXTINTO(Off_Hook_Service),we check for a DTMF digit input. If it

  ;was a pulse dial input then we continue counting pulses, until 250ms

  ;has passed after receiving the last pulse. At that point we consider

  ;assembling the pulse dial digit completed,so we copy it into the acc,

  ;and set the fdig_ready flag.

  get_pulse:

         jnb            fdigit,get_dtmf

         clr            fdtone                        ;Clear dial tone flag

         mov            ccapm1,#0                    ;Turn off dial tone

         mov            a,#2                         ;If there was an input

         ctr            c                             ;Clear carry for subtraction

         subb           a,time off2                  ;See if 213.3 msec (3×71.1ms) passed

         jnc            get_dtmf                      ;If not yet,then digit not complete

         mov            a,#1B1

         clf            c                             ;Clear carry for subtraction

         subb           a,time_off1                  ;See if additional 36.7msec

                                                            ;(132×277.8usec)has passed(total

                                                            ;time of 250msec)

         jnc            get_dtmf                      ;If not yet, then digit not complete

         mov            a,pulse_digit                ;Put digit in a

         mov            pulse_digit,#0               ;Clear for next dig

         setb           fdig_ready                    ;To show a digit ready

         clr            fdigit                        ;Clear the flag
;If a DTMF dial digit is ready,copy it into the acc.Check for special
;conditions, flash, hang up etc. Branch on special conditions,or continue
;checking for more pulse(s),and/or completed digits.
get_dtmf:

        jnb            fdtmfin,hang

        clr            fdtone                         ;Clear dial tone flag

        mov            ccapm1,#0                     ;Turn off dial tone

        cir            fdtmfin                        ;Clear dtmf input flag

        mov            a,px1_temp                    ;Put digit in acc

        anl            a,#0fh                        ;Keep only low 4 bits

        setb           fdig_ready                     ;To show a digit ready
;Check for hangup (pulseφ700ms). 
hang:    jnb            fhang,gflash                  ;Ifno hang up

         pop            psw
test_lc3:

        call           hup

        dec            sp                             ;Correct stack pointer

        dec            sp                             ;Leaving subrout without ret

        jnb            fremote_hup,no_remote         ;Brif no remote hup occured

        clr            fremote_hup
no_remote:

        jmp.           start                          ;Exit,somebody hung up
;Check for flash(230=pulse=700ms).
				
				<dp n="d60"/>
gflash:   jnb            fflash,time                   ;If no flash

        clr             fflash                         ;Clear flash flag

         mov             ccapm1,#0                     ;Turn off dial tone

         jb              fdtone,just_flash             ;If dial tone on just a send for last

                                                              ;number redial

         jb              fsendjust_flash                ;If send flag is set don′t put digits,

                                                                ;just a send 

         clr             fdtone                         ;Clear dial tone flag

         pop             psw

         dec             sp                             ;Correct stack pointer

         dec             sp                             ;Leaving subrout without ret

         jmp             send_it                        ;Output all digits+send
;Transmit only a SEND code, but not the digits, if
;either the Dial Tone or the Send flag is high.
just_flash:

         clr             fdtone                         ;Clear dial tone flag

         mov             f_cmds,#5

        call             trucmd

        mov              a,#send                       ;Send code

        call             wrbus

        setb             fsend                          ;Send flag

        pop              psw                            ;Restore flags

        dec              sp                             ;Correct stack pointer

        dec              sp

        jmp              wait                           ;Back for digit(s),hangup etc.
;If we did not dial a complete phone number yet,and 40 second passed
;since the last key punch,then we start a 1 minute holler tone.
time:    jnb              ftime,send_time               ;If no timeout

        pop              psw

        dec              sp                             ;Correct the stack pointr

        dec              sp                             ;Leaving subrout without ret

        jmp              rohtone                        ;Then no rohtone
;Check if it time to send(4sec expired since last key.)
send_time:

        jnb              fsendtimer,unlock_time

        mov              r6,time_off2                  ;71.1ms timer in r6

        cjne             r6,#56,unlock_time           ;Check for 4sec(56×71.1ms=3.98sec)

        chr              fsendtimer

        pop              psw

        dec              sp                             ;Correct stack pointer

        dec              sp                             ;Leaving subrout without ret

        jmp              send_it                        ;Output digits and send
;Check if unlock was requested.
unlock_time:

        jnb              funlocktimer,lock_time

        mov              r6,time_off2                  ;71.4 ms timer in r6
				
				<dp n="d61"/>
        cjne            r6,#28,1ook          ;Check for(28×71.4ms=)2sec

        clr             funlocktimer

        pop             psw

        dec             sp                     ;Correct stack pointer

        dec             sp                     ;Leaving subrout without ret

        jb    lock,no_unlock                  ;Do not unlock,if already unlocked

        jmp            unlock_it
no_unlock:

        setb           fonhook                 ;As if on hook

        setb           ie0                     ;Go to ExtInt0 service

        jmp            start                   ;Just like off hook again
;Flocktimer added to allow lock to timeout on less than 4 digits.Go_lock
;label must be added to TRU and also setting of flocktimer(if necessary).
lock_time:

       jnb             flocktimer,look        ;Brif not

       mov             r6,time_off2           ; 71.4ms timer in r6

       cjne            r6,#28,look           ;Check for (28*71.4ms=2sec)

       clr             flocktimer

       pop             psw

       dec             sp                      ;Correct SP

       dec             sp

       jmp             go_lock
;Check if we got a(complete)digit.
look:   jb              fdig_ready,got_a_digit

       jmp             get1                    ;Look again if no digit in
;We got a digit (pulse or DTMF),return it in the acc.
got_a_digit:

       clr             fdig_ready              ;Clear the digit ready flag
got_inuse:

       mov             time_off1,#0           ;Restart timers on every digit input

       mov             time_off2,#0

       mov             time_off3,#0

       pop             psw

       ret
;*************************************************
;
;Get a digit from the handset keypad
;
;*************************************************
;This routine processes the digit input and/or process flags.
;On return-returns data in acc
get_test:

       push            psw
				
				<dp n="d62"/>
;If a DTMF dial digit is ready,copy it into the acc.Cheek for special
;conditions,flash,hang up etc.Branch on special conditions,or continue
;checking for more pulse(s),and/or complctcd digits.
get_dtmf_teat:

     jnb           fdtmfin,no_dtmf_test

     ctr           fdtone                      ;Clear dial tone flag

     mov           ccapm1,#0                  ;Turn off dial tone

     clr           fdtmfin                     ;Clear dtmf input flag

     mov           a,px1_temp                 ;Put digit in acc

     anl           a,#0fh                     ;Keep only low 4 bits

     setb          fdig_ready                  ;To show a digit ready
no_dtmf_test:

     clr           fdig_ready                  ;Clear the digit ready flag

     mov           time_off1,#0               ;Restart timers on every digit input

     mov           time_off2,#0

     mov           time_off3,#0

     pop           psw

    ret
;**********************************************************************
;send_dtmf-send a dial tone
;**********************************************************************
send_dtmf:

     call           watchdog

     clr            dtmf_out                   ;enable the dtmf tone

     call           write_io_m_b

     setb           dtmf_out                   ;enable the dtmf tone

     call           write_io_m_b

     ret
;**********************************************************************
;clr_dtmf-send a dial tone
;**********************************************************************
disable_dtmf:

     clr           dtmf_out                    ;enable the dtmf tone

     call          write_io_m_b

     ret
delay_dtmf:                                     ;delay the DTMF tone

     clr           tr1

     mov           time_off2,#0

     mov           time_off1,#0

     setb          tr1
wait_until_dtmf:

     mov           a,time_off2

     call          watchdog

     cjne          a,#4,wait_until_dtmf     ;wait 40 msec to stop the dtmf

     ret
;*************************************************
;
;                        ROH tone generator
;
;*************************************************
				
				<dp n="d63"/>
;40sec has passed after we lifted the handset w/o dialing any digits,
;or since we have dialed the last digit.We shall generate an ROH tone
;(interrupted at 80 msec intervals) for 1 minute or until we hang_up,
;whichever happens first.
rohtone:

     clr        ftime                     ;Clear the flag

     clr        fdtone                    ;Clear dial tone flag so changes in

                                                ;indicators won′t change roh tone

     mov        dptr,#table 400
     mov        highpoint,dphh           ;Remember table location

     mov        lowpoint,dpl

     setb       roh_boost                 ;Boost the audio

     call       write_px2
rohtone_on:

     mov        ccapm1,#01000010b        ;Turn on the tone
; Loop here for 1 minute,or until hang_up.
check_hangup:

     call       watchdog                  ;Refresh watchdog while waiting here

     jnb        fhang,check_timeout      ;Brif still off hook
test_lc4:

     call       hup                       ;Do orderly hang up if back on hook

     jmp        start                     ;Brand new start
check_timeout:

     jb         frohtimeout,roh_timeout  ;Brif ROH timed out (after 1 minute)

     jb         roh_on,rohtone_on

     mov        ccapm1,#0                ;Turn off the tone

     jmp        check_hangup              ;This loop toggles roh on and off
roh_timeout:

     mov        ccapm1,#0                ;Turn off the tone

     clr        roh_boost                 ;Unboost the audio

     setb       loopswitch_               ;Open the loop

     call       write_px2                 ;Out to the port
test_le5:

     call       hup                       ;Do hang up routine

     jnb        sw_gndstart,looptest     ;Do loop test if loop start

     jmp        looptest_end              ;No loop test if ground start,just

                                                ;leave loop open til ring ground
;Get here if we are in Loopstart mode.
looptest:

     mov        b,#40                    ;Set up 2sec delay(40×50ms)
loopt1:

     mo         a,time_on2               ;Get current onhook time

     add        a,#5                     ; Add 50ms to present time
Ioopt2:

     call       watchdog                  ;Refresh watchdog

     cjne       a,time_on2,loopt2        ;Minor delay is 50ms
				
				<dp n="d64"/>
       djnz           b,loopt1                       ;Wait 2sec total

       clr            loopswitch_                     ;Close loop in every 2sec to check

       call           write_px2                       ;if phone was put back on hook

       mov            looptcst_timer2,#215           ;Load 2.22msec delay(8×277.8usec)
loopt3:

       mov            looptest_timer,#0fth           ;To allow enough time for the SLIC

       djnz           looptest_timer,S               ;chip to indicate the hook status

       call           watchdog                        ;Refresh watchdog

       djnz           looptest_timer2,loopt3

       jb             lc_,looptest_end               ;Brif no loop current(backon hook)

       setb           loopswitch_                     ;Open loop switch again

       call           write_px2

       jmp            looptest                        ;Wait here until hung up
looptest_end:

       clr            frohtimeout                     ;0=has been hung up,or in GS mode

       mov            time_on1,#0                    ;Reset on hook timers

       mov            time_on2,#0

       jmp            start                           ;Start new
;*************************************************
;
;       Subroutine for hang up
;
;*************************************************
hup:
        call           watchdog

       clr            ex0                            ;Disable ExtInt0(offhook,LC_)

        clr            fdigit                         ;In case hangup while ptlse dialing

        mov            pulse_digit,#0                ;In case hup during pulse digit input

        clr            fdig_ready                     ;In case hup during pulse/dtmf input

        clr            fdtmfin                        ;In case hup during dtmf digit input

        clr            flocktimer                     ;In case hup during locking

        clr            funlocktimer                   ;In case hup during unlocking

        jnb            sw_gndstart,hupl              ;Brif loopstart

        setb           loopswitch_                    ;Open loopsw for 750ms ff groundstart

        call           write_px2                      ;to simulate hup

        mov            a,time_on2                    ;Incs every 10ms

        add            a,#75                         ;For 750ms delay

        push           acc                            ;Store for later

        jmp            hp2
hup1:    jb             frohtimeout,hup2

        clr            loopswitch_                    ;If loopstart

        call           write_px2
hup2:

        clr            ftime                          ;Clear timer flag

        clr            fsendtimer                     ;Clear send timer flag

        mov            ccapm1,#0                     ;Make sure dtone is off

        clr            fdtone                         ;Clear the dial tone flag

        clr            roh_boost                      ;Normal audio

        call           write_px2

        jb             ffemote_hup,no_end_sent       ;No end code if remote hup,since it

                                                      ;isn′t needed and clears the buffer

                                                       ;on the Motorola unnecessarily.
				
				<dp n="d65"/>
        mov            a,#endcall               ;Put end code

        call           wrbus                     ;Send it to TRU first,then reset flag
no_end_sent:

        ctr            fsend                     ;in case digits sent or alert answered

        setb           hookswout                 ;Show on hook to TRU

        clr            hookswout_                ;Ditto

        jnb            sw_gndstart,hup4         ;Don′t do timing if loop start

        pop            acc                       ;Get delay time back

        clr            c                         ;Clear carry flag for next
hup3:

       call           watchdog

        cjne           a,time_on2,S+3         ;Wait 750 ms to allow loop to open

                                                      ;and pbx to see it as disconnect.

                                                       ;jmp to next instruction in any case

        jnc            hup3                      ;No carry til time_on2 greaterthan acc

                                                       ;(in case bus write took more than
 
                                                       ;750ms)
bup4:

        setb           fonhook                   ;Set on-hook flag

        clr            fhang                     ;Clear hang-up flag

        clr            f_one_sec                 ;So timer can start again when off hook

        clr            f_inuseofftiming          ;Reset flag

        setb           ex0                       ;Enable extint0(offhook)

        ret
;*************************************************
;
;              TRU status update
;;*************************************************
;Routine updates TRU status every 71.4ms,and turns ringer
;on and off. Also checks for 3.9 second interval after a ring.
update_displays:

       push         acc

       push         psw
upspec1:

       jnb          fspec1,continue_update      ;Check special flag

       call         spec1                        ;Special routine in TRU section
continue_update:

       jb           test_enable,go_to_self      ;check if test started

       mov          a,lamps_temp                ;Hold values for comparison later

       mov          c,roam

       cpl          c                            ;No real lamps for the Maxjack!

       mov          roamlamp,c                  ;Roam indicator(just for storage)

       mov          c,noserv

       cpl          c

       mov          noservtamp,c                ;Noserv indicator(just for storage)

       mov          c,lock

       cpl          c

       mov          locklamp,c                  ;Lock indicator(just for storage)

       mov          c,inuse

       cpl          c

       mov          inuselamp,c                 ;Inuse indicator(just for storage)
				
				<dp n="d66"/>
       call           write_io_c                   ;update the LEDS

       jb             sw_dialtone,not_maint       ;If option sw is out(=1)

                                                         ;not maintenance module
test_push:

       call           read_iom_a                   ;read puah button

       anl            a,#00010000b
       cjne           a,#0h,not_push

       setb           test enable                  ;init maint test

       setb           fremote_hup                  ;set remote hup for 700ms

       setb           loopswitch_                  ;Other side has disconnected

       call           write_px2
not_push:

       jnb            test_enable,not_maint       ;check if test started
go_to_self:

       jnb            test_end,not_error_yet      ;if error was found

       jnb            error_flag,pass_ok
test_led:

       mov            r0,#error_code

       mov            a,@r0

       rl             a

       rl             a

       rl             a

       rl             a
       mov            lamps_temp,a

       call           write_io_c                   ;update the LEDS

       setb           ext_led                      ;turn on external led 1 minute

       jmp            write_to_c
pass_ok:

       clr            ext_led                      ;turn on external led 1 minute

       jmp            write_to_c
not_error_yet:

       jb             ext_led, clr_led

       setb           ext_led                      ;turn on external led while testing

       jmp            write_to_c
clr_led:

       clr            ext_led                      ;turn off external led while testing
write_to_c:

       call           write_io_m_c                 ;turn on/off the external led
not_maint:

       mov            a,lamps_temp                ;Hold values for comparison later

       jb             frohtimeout,compare

       mov            c,ap2                       ;Check we are in ALERT state,

       anl            c,/ap1                      ;(i.e.:incoming call waiting)

       jnc            compare                      ;Brif not ALERT(no incoming call)

       jnb            fonhook,compare             ;Brif off hook,don′t ring bell!

       clr            loopswitch_                  ;Close loop switch if ALERT state,

       call           write_px2                    ;(incoming call is waiting)

       jb             fcall,reset_ring_tiner      ;Brff ringing is already in progress

       setb           fcall                        ;1=start ringing(ALERT detected)

       mov            bell_timer,#0               ;Reset timers

       mov            bell_timer2,#0

       setb           fbellsound                   ;Flag bell sounding

       mov            dptr,#table_20              ;Point to 20hz table for ring

       mov            lowpoint, dpl               ;Save ringer table starts
				
				<dp n="d67"/>
       mov           highpoint,dph

       setb          twenty_hz_pwm                ;So pin can be pwm

       mov           ccapm2,#01000010b           ;Enable pwm
test1:
0        clr           ring_                      ;Turn on ring ps

       setb          no_ring

       call          write_px2                    ;Out to port
reset_ring_timer:                                    ;Reset between-rings timer as long as

       mov           ring_timer,#0               ;we are in ALERT state
compare:

       xrl           a,lamps_temp                ;Bits that differ will be=1

       jnb           f_one_sec,dtbits            ;Wait 1 sec after off hook before

                                                      ;looking at inuse lamp,prevents

                                                      ;disconnect if offhook soon after hup

      mov           c,acc.7                     ;Get INUSE status

       anl           c,/inuselanp                ;1=not INUSE

       jnc           timing_in_use_off            ;Start timer if INUSE lamp just turned

                                                          ;off

       mov           in use off timer,#28        ;Reset timer for 1.99sec(28×71.1ms)

       setb          f_inuseofftiming             ;Show in use off timer is working now
timing_in_use_kff:
       jnb           inuselamp,cont_in_use_timing

                                                        ;If inuse lamp still off

       clr           f_inuseofftiming             ;Otherwise clear flag and stop timing
cont_in_use_timing:

       jnb           f_inuseofftiming,dtbits     ;Continue timing if flag is set

       djnz          in_use_off_timer,dtbits     ;When timer hits 1.99 sec, disconnect

       clr           f_inuseofftiming             ;Clear flag

       jb            fonhook,dtbits              ;If local hangup don′t do remote hangup
;We get here if the other party hang-up and we did not put the phone
;back on hook within 2 seconds.
disconnect:
        setb          fremote_hup                 ;set remote hup for 700ms

        setb          loopswitch_                 ;Other side has disconnected

        call          write_px2
dtbits:

        anl           a,#01110000b               ;Just check bits that affect dial tone

        jz            ring_timeout                ;If nothing chgd

        jnb           fdtone,ring_timeout        ;Or if DT not on already

        mov           ccapm1,#0                  ;Turn off current DT

        call          dtone                       ;Change to new dial tone
ring_timeout:

        jnb            fcall,update_done         ;Don′t time ring if no incoming call

        inc            ring_timer                 ;Every 71.1msec
        mov            a,#53                     ;54×71.1ms=3.84sec

        clr            c                          ;Clear carry for subtraction

        subb           a,ring_timer

        jnc            update_done                ;If not at least 3.84 sec with no ring

        jb             fbetlsound,update_done    ;Also wait til not sounding ring
check_stop_ring_ps:

        mov            a,#3                      ;4×25ms=100ms

        clr            c                          ;Ready to do subtract

        subb           a,bell_timer2
				
				<dp n="d68"/>
        jnc            update_done                 ;When carry,100ms

        jb             ring_,check_stop_null      ;Brif ring PS is already turned off

        setb           ring_                       ;Else turn off ring PS now

        call           write_px2                   ;Out to port

        clr            no_ring

        call           write_px2                   ;Out to port
check_stop_null:

        mov            a,#7                       ;8×25ms=200ms

        clr            c                           ;Ready to do subtract

        subb           a,bell_timer2

        jnc            update_done                 ;When carry,200ms

        mov            ccapm2,#0                  ;Stop pwm

        clr            twenty_hz_pwm               ;Leave output pinlow,pwm has run 100

                                                         ;ms longer than ring ps to smooth out

                                                         ;waveform

       clr             fcall                       ;0=not ALERT,assure no ringing

       jnb             sw_gndstart,update_done    ;Brif loop start

       setb            loopswitch_                 ;GS didnt answer ring

       call            write_px2
update_done:

       jb              fcall,no_reset_io

       jnb             lc_,no_reset_io

       jb              frohtimeout,no_reset_io
no_reset_io:

       pop             psw

       pop             acc

       ret
;*************************************************;
;            Reload Watch Dog Compare Word
;
;*************************************************
watchdog:

        push          ie

        clr           ea                             ;Disable ints

        mov           ccap41,#0                     ;Point to start of current page

        mov           ccap4h, ch                    ;Current page

        pop           ie

        ret
;*************************************************
;
;Timer0(TL0)on-hook interrupt service routine
;
;*************************************************
onhook_timer:

        push           psw

        push           acc

        clr            tr1                          ;Stop offhook timer

        clr            tf1                          ;Clear pending ints by offhook timer
mute_check:

        jb             mute,on_spec2               ;if already muted skip this
				
				<dp n="d69"/>
        setb           mute                        ;Mute rx audio to prevent false

                                                         ;decoding of audio ring as dtmf,

                                                         ;also prevent audio feedback

        call           write_px2                   ;Out to port
on_spec2:

        jnb            fspec2,on_spec2_done       ;Check flag

        call           spec2                       ;Call special routine in TRU section
on_spec2_done:

        djnz           display_delay,gs_init      ;In 71.1ms

        call           update_displays             ;Every 71.1ms
gs_init:

        jb             fcall,cont_service         ;Skip outgoing GS init on incoming call

        jnb            sw_gndstart,cont_service   ;Brif not in GS mode

        jnb            fonhook,cont_service       ;Don′t look for ring ground to start

                                                         ;GS until really hung up

        jb             ring_ground_,cont_groundstart

        clr            loopswitch_                 ;Groundstart service was requested

        call           write_px2

        mov            gndstart_timer 1,#0

        mov            gndstart_timer2,#0         ;Init timer
cont_groundstart:

        inc            gndstart_timer1             ;Subscriber has released ring ground

        mov            a,gndstart_timer1

        cjne           a,#90,cont_service        ;25ms(90×277.8us)

        inc            gndstart_timer2             ;Every 25msec

        mov            gndstart_timer1,#0         ;Reset for next count of 90

        mov            a,gndstart_timer2

        ejne           a,#40,cont_service        ;1sec(40×25ms)

        setb           loopswitch_                 ;Open loop in 1sec if sub didn′t

                                                         ;complete loop

        call           write_px2
cont_service:

        jb             fcall,ring_control         ;Brif ALERT state to generate ringing

        jmp            onhook_timers               ;Else just do timers update
;We shall ring the bell if the TRU is in ALERT state,(an incoming
;call is waiting to be picked up).
ring_control:

        jb             fbellsound,timing_ring     ;When bell not sounding during ring

                                                         ;cycle,check for ring ground to

                                                         ;indicate answer due to ringing

                                                         ;pulses

        jb             ring_ground_,timing_ring

                                                         ;If no ring ground,time the ring. Now

                                                         ;ignore the pulse on ring ground as

                                                         ;ringer stops

        mov            a,bell_timer2              ;Incs every 25ms

        cjne           a,#0,start_bellsound      ;Observe any ring ground after 25ms

        mov            a,#28                      ;29×277.8us=8.1ms

        clr            c                           ;Ready to subtract

        subb           a,bell_timer

        jnc            timing_ring                 ;No carry til 8.1ms sfter ring stops.

                                                   ;Only ignore ring ground 8.1ms
				
				<dp n="d70"/>
        jmp            start_bcllsound             ;If ring ground indicates came off hook
  
                                                         ;during silent time,start 20hz

                                                         ;again to force ring trip
timing_ring:

        inc            bell timer                  ;Every 277.8usec

        mov            a,bell_timer

        cjne           a,#90,ringer_on           ;25msec(90×277.8us)

        mov            bell_timer,#0              ;Reset for next 90

        inc            bell_timer2                 ;Every 25msec
ringer_on:

       jnb             fbellsound,ringer_off      ;Brif bell is not sounding now
;The on time ringer modified from 1.95secs to 1.975secs,because the ring
;stops at the positive peak which causes a continous ringing.This problem;was producing with 5 ringer box applying with maxjack.(ssh)
check_stop_bellsound:

          mov           a,bell_timer2               ;Get elapsed “bell on″time

          cjne          a,#59,onhook_timers        ;Brif less then 79×25ms=1.975secs

          mov           a,bell_timer                ;45×277.8us=12.5ms(total 1.987s

          cjne          a,#45,onhook_timers        ;Ring stops after 1.987secs on negative

                                                        ;peak,chops off last quarter cycle

                                                         ;for proper ring trip
stop_bcllsound:

        mov           ccapm2,#0                   ;Enable pwm

        clr           fbellsound                   ;0=the bell not sounding

        mov           dptr,#table_null            ;Point to table of null tone(nulltone

                                                         ;causes ringer to have zero AC out,

                                                         ;only battery)

        mov           lowpoint,dpl                ;Save the null table start

        mov           highpoint,dph

        mov           ccapm2,#01000010b           ;Enable pwm

        clr           ea

        clr           no_ring

        call          write_px2

        setb          ea

        call          watchdog

        jmp           reset_bell_timers            ;Reset timers
ringer_off:

        mov           a,bell_timer2

        cjne          a,#120,onhook_timers       ;4sec with no ring(160×25)
start_bellsound:

        call          reset_id

        call          write_px1

        call          write_px2

        clr           ea

        setb          no_ring

        call          write_px2

        setb          ea

        mov           ccapm2,#0                   ;Enable pwm

        mov           dptr,#table_20              ;Point to table for 20hz

        mov           lowpoint,dpl                ;Remember where table starts

        mov           highpoinl,dph

        mov           ccapm2,#01000010b           ;Enable pwm
				
				<dp n="d71"/>
test_relayl:

        setb          fbellsound                 ;I=bell is sounding now
reset_bell_timers:

        mov           bell_timer,#0

        mov           bell_timer2,#0
onhook_timers:

        inc           timc_onl                   ;Every 277.8 uscc while on hook

        mov           a,time onl

        cjne          a,#36,onhook_done        ;36×277.8ms=10ms

        inc           time_on2                   ;Every 10msec while on hook

        mov           time_on1,#0               ;Reset for next 36

        mov           a,time_on2

        cjne          a,#0,not_inc255

        inc           test_min                   ;10msec×255=255sec
not_inc2.55:

          jb            ffohtimeout,onhook_done

                                                   ;Skip hang up stuff until loop test

                                                   ;checks out ok
test_fhang1:

          jb            fonhook,onhook_done       ;Don′t do another hang up,one has been

                                                   ;done already
test_fhang2:

          mov            a,time_on2
;                                                       ;ON HOOK STATUS
;        cjne           a,#70,onhook_done       ;700msec indicates hang up

          cjne           a,#30,onhook_done       ;700msec indicates hang up
test_fhang3:

          setb           fhang                     ;Set the hang up flag

          clr            f_inuseofftiming          ;Stop timer to prevent possible remote

                                                   ;hup
onhook_done:

          pop            acc

          pop            psw

          reti
;*************************************************
;
;Timer1(TH0)off-hook interrupt service routine
;
;*************************************************
offhook_timer:

          push           psw                            ;Save entry status

          push           acc

          jnb            fspec2,check_strobe           ;Brif spec2 is not enabled

          call           spec2                          ;Else do TRU specific task
;Check for a DTMF digit,and read it from the MT8870 if there
;is one available.
check_strobe:

          call           read_px1_strobe

          jb             strobe,decode_dtmf            ;Brif a DTMF digit is waiting

          clr            fdecoder_busy                  ;Reset if strobe is gone
				
				<dp n="d72"/>
        jmp            ttimc                         ;and just do offhook timing task
decode_dtmf:

        jb             fdecodcr_busy,ttimc            ;Brif DTMF digit already was read

        call           read_px1                      ;Else read it now

        setb           fdtmfin                       ;1=DTMF digit received!

        setb           fdecoder_busy                  ;1=DTMF digit being processed
;Check elapsed offhook time,update displays in every 71ms,and
;start-end ROH tone as required.
ttime:

        inc            time_off1                     ;Bump minor offhook timer(@277.8us)

        mov            a,time_off1                  ;Get minor offhook time
;JMP TEST_HOOK

        cjne           a,#0,t_one_sec              ;Brif=256*277us=71.1ms

        inc            time_off2                     ;Bump major timer (every 71.1ms)

        call           update_displays               ;Do update every 71.1ms

        mov            a,time_off2                  ;Get major offhook time

        cjne           a,#0,t_one_sec              ;Brif=256*71.1ms=18.2sec

        inc            time_off3                     ;Bump total offhook timer(@18.2sec)
t_one_sec:

        mov            a,time_off2                   ;Get major offhook time

        cjne           a,#14,trohtimer             ;Brif=14*71.1ms=995ms passed

        serb           f_one_sec                     ;so change in INUSE lamp won′t cause

                                                     ;hangup ff phone taken off hook too

                                                     ;soon after hangup
trohtimer:

       jb              fsend,tdone                  ;Brif we originated the call(no ROH)

       jnb             intse,tdone                  ;Brif we are INUSE(no ROH either)

       inc             r5                            ;Bump minor ROH start/end timer

       cjne            r5,#36,trohstart            ;Brif=35*277.8us=10ms passed

       inc             r7                            ;Bump minor ROH on/off timer

       mov             r5,#0                        ;Reset for another pass(10ms)

       cjne            r7,#10,trohstart            ;Brif=10*10ms=100ms passed

       cpl             roh_on                        ;Toggle ROH on/off every 100ms

       mov             r7,#0                        ;Reset for another on/off phase
trohstart:

        mov             a,time_off3                  ;Get total elapsed offhook time

       cjne            a,#2,trohquit               ;Brff=2×18.2=36.3sec passed

       mov             a,time off2                  ;Get additional major time too

       cjne            a,#51,trohquit              ;Brif=40sec total offhook

       setb            ftime                         ;1=ROH period started
trohquit:

        mov             a,time_off3                  ;Get total offhook time again

       cjne            a,#5,tdone                  ;Brif=5*18.2=91sec passed

       mov             a,time_off2                  ;Get additional major time too

       cjne            a,#127,tdone                ;Brif=91+(127*71.1ms)=100sec

       setb            frohtimeout                   ;1=ROH period expired
tdone:

       jab             f_start,tdone0               ;Brif not timing 500ms after″first″

       mov             a,time_off2                  ;Get elapsed offhook time
				
				<dp n="d73"/>
        cjne           a,#4,tdonel               ;Brif=285ms elapsed

        cjne           a,#7,tdonel               ;Brif=500ms elapsed

        clr            f_start                     ;Reenable onhook ints after 500ms
;Get here only after 500ms passed following the first offhook after
;every hang up.
tdonc0:

       jnb            lc_,tdonel                  ;Brif offhook now
test_tr0:

       clr            tr1                          ;Else stop the off hook timer

       setb           tr0                          ;and start on hook timer
tdone1:

       pop            acc                          ;Restore

       pop            psw

       reti
;************************************************
;
;External Interrupt 0 service routine
;
;*************************************************
offhook_edge:

        jb            frohtimeout,offhook_returnl

        jnb           fcall,not_inc_call

        jnb           no_ring,ok_wait

        setb          ring_                        ;Turn off bell

        call          write_px2

        clr           no_ring

        call          write_px2

        setb          return_ring

        clr           ie0                          ;Discard pending EX0(LC_)interrupt

        clr           tr0                          ;Turn off onhook_timer and flag

        clr           tf0                          ;in case onhook_timer int pending
ok_wait:

        mov           r7,#Offh
loop_ring:

        mov           r6,#0ffh

        djnz          r6,S

        call          watchdog

        djnz          r7,loop_ring

        jnb           Ic_,no_set
esta_set:

        jnb           return_ring,do_not_return

        call          reset_io

        call          write_px1
        call          write_px2

        setb          no_ring

        ctr           ring_                          ;Turn off bell

        call          write_px2

        clr           return_ring

        mov           r7,#07fh
loop_ring1:

        mov           r6,#0ffh
				
				<dp n="d74"/>
          djnz           r6,S

          call           watchdog

          djnz           r7,loop_ringl
do_not_return:

          call           reset_io

          call           write_px1

          call           write_px2

          setb           tr0                         ;Turn off onhook_timer and flag

          mov            t10,#0

          reti
offhook_return1:

          jmp            offhook_return
no_set:
not_inc_call:

          clr            tr0                         ;Turn off onthook timer and flag

          clr            tf0                         ;in case onhook timer int pending
 
          push           psw
  
          push           acc

          clr            ie0                         ;Discard pending EX0 (LC_) interrupt

          setb           tr1                         ;Start off-hook timer

          clr            thang                       ;Clear hang up flag for safety

          mov            th0,#0                     ;Reset offhook timer

          mov            time_off1,#0               ;Timers incremented by th0 interrupts

          mov            time_off2,#0

          mov            time_off3,#0

          clr            mute                        ;Unmute rx audio

          call           write_px2

          jnb            fonhook,check_flash        ;Brif wasn′t hung up

                                                     ;coming back off hook

          clr            fonhook                     ;Clear the flag,it was hung up,now
ok_lffhook:
        jnb            fcall,set_hook_flag        ;Btif not in ALERT state

        setb           fanswer                     ;1=off hook during incoming call

        clr            fcall                       ;Clear the ALERT flag(answering call)

        setb           ring_                       ;Turn off bell

        call           write_px2

        clr            no_ring

        call           write_px2

        mov            ccapm2,#0                  ;Stop ringer PWM

        clr            twenty_hz_pwm               ;Leave output pin low

        jmp            offhook_done
set_hook_flag:

        setb           fhook                       ;Show off hook if not in ALERT state
        jmp            offhook_done
check_flash:

        mov            a,#19                      ;20×10=200msec

        clr            c                           ;Clear carry for subtraction
        subb           a,time_on2                 ;200-700msec is flash

        jnc            check_digit

        jnb            lock,offhook_donc          ;No flash if TRU is locked

        setb           fflash                              ;Set flash flag
				
				<dp n="d75"/>
       jmp            offhook_done
check_digit:

       mov            a,#1                      ;2×10=20msec

       clr            c                          ;Clear carry for subtraction

       subb           a,time_on2                ;20-200msec is pulse

       jnc            offhook_done               ;Just a glitch

       inc            pulse_digit                ;Contains the number

       setb           fdigit                     ;Possible digit flag
offhook_done:

       mov            time_on1,#0               ;Reset on-hook timers so they can be

       mov            time_on2,#0               ;restarted on hang up

       mov            t10,#0

       pop            acc

       pop            psw
offhook_return:

       reti
;*************************************************
;           PCA Interrupt Routine
;*************************************************
;PCA interrupts are generated by using module O′s(software timer)
;compare/match option on every low count = FF match. This way we can
;generate an interrupt at the end of each page, 00FF-0100, 01FF-0200
;etc. which gives us an interrupt at every (256*1.085us) 278us.
;This Maxjack implementation is using conditional assembly to produce
;a modified PCA service routine for TRUs with extremely high data transfer
;rates(Audiovox requires the alternate PCA routine).
Sge
pea_service:

       %if(%intmask ne 0)then (

       push           ie                       ;Going to simulate third interrupt

                                                     ;priority level

       mov            ie,#%intmask           ;Defined in TRU section

       call           masklabel                ;To execute the reti

       push           acc

       push           psw

       mov            a,ccapm1                ;Look at tone pwm

       orl            a,ccapm2                ;Look at ring pwm

       anl            a,#00000010b            ;Just look at pwm bit

       jz             pea_done                 ;Skip next part if no tone or ring

                                                     ;output
do_pea:

       mov            a,#0                    ;Inicialize pointer
read_table:

       move           a,@a+dptr              ;Get data from table

       cjne           a,#255,write_tone

       mov            dph,highpoint           ;Reset index this is end of table

       mov            dpl,lowpoint

       mov            a,#0                    ;So index will be right

       jmp            read_table               ;Read first entry
				
				<dp n="d76"/>
write_tone:

       mov            ccapih,a                    ;Pul data in tone pwm

       mov            ccap2h,a                    ;Put data into ring pwm-only tone
                                                         ;or ring pwm is running at any given

                                                         ;time

       inc            dptr                         ;Point to next table entry for next

                                                         ;time
pea_donc:

       clr            ecf0                         ;Reset the module 0 flag

       clr            ea                           ;Disable ints

       mov            ccap01,#0ffh                ;Reload low match and suspend

                                                         ;comparator

       mov            a,ccap0h                    ;Get last page

       inc            a                            ;Point to next page

       mov            ccap0h,a                    ;Load high match and restart comparator

       setb           ea                           ;Enable ints again

       pop            psw

       pop            acc

       pop            ie                           ;Restore original ints

       ret
masklabe1:

       reti

       )else(

       push           acc

       push           psw

       mov            a,ccapm1                    ;Look at tone pwm

       orl            a, ccapm2                   ;Look at ring pwm

       anl            a,#00000010b                ;Just look at pwm bit

       jz             pca_done                     ;Skip next part if no tone or ring

                                                         ;output
;If we are generating Dial Tone now, then get the current
;value from the selected tone table, and send it to the PCA1
;so that proper DTMF frequency is generated on CF X1 (p1.4).
do_pca:

        mov            a,#0                       ;initialize pointer
read_table:

        move           a,@a+dptr                 ;Get data from table

        cjne           a,#255,write_tone
        mov            dph,highpoint              ;Reset index, this is end of table

        mov            dp1,lowpoint

        mov            a,#0                       ;So index will be right

        jmp            read_table                  ;Read first entry
write_tone:

        mov            ccap1h,a                   ;Put data in tone pwrm

        mov            ccap2h, a                  ;Put data into ring pwm only tone or

                                                         ;ring pwm is running at any given

                                                         ;time

        inc            dptr                        ;Point to next table entry for next

                                                         ;time
pca_done:

        clr            ccf0                        ;Reset the module 0 flag

        clr            ea                          ;Disable ints

        mov            ccap01,#0ffh               ;Reload low match and suspend
				
				<dp n="d77"/>
                                                        ;comparator

       mov           a,ccap0h                    ;Get last page

       inc           a                            ;Point to next page

       mov           ccap0h,a                    ;Load high match and restart comparator

       setb          ea                           ;Enable ints again

       pop           psw

       pop           acc

       rcti

       )fi
Snoge
;*************************************************
;
;           I/O Support Routines
;*************************************************
write_px1:                                              ;Data from px1_temp to px1

        push          ie                          ;Save interrupt status

        cir           ea                          ;No interruptions

        clr           io_select

        push          acc

        push          0                           ;Push r0

        setb          a0                          ;B

        cir           a1

        mov           a,px1_temp

        anl           a,#11110000b

        mov           b,a

        mov           a,px2_temp

        anl           a,#00001111b               ;Keep the input bits high

        orl           a,b

        mov           r0,#00h                    ;Low address for I/O chip px1 latch

        movx          @r0,a
        setb          a0

        setb          a1

        pop           0                           ;Restore r0

        pop           acc

        pop           ie                          ;Restore interrupt status

        ret
read_px1:

       push           ie                          ;Save interrupt status

       cir            ea                          ;No interrupts

       clr            io_select

       push           acc

       push           0                           ;Push r0

       cir            a0                          ;A

       clr            a1

       mov            r0,#0h                     ;Low address byte for I/O chip px1 pins

       movx           a,@r0

       anl            a,#00001111b               ;Mask the output bits

       anl            px1_temp,#11110000b        ;Mask the input bits in px1_temp

       prl            px1_temp,a                 ;Combine inputs anloutputs into one

                                                  ;byte
				
				<dp n="d78"/>
       setb           a0

       sctb           a1

       pop            0                   ;Pop r0

       pop            acc

       pop            ic                  ;Restore interrupt status

       ret
read_px1_strobe:

       push           ic                  ;Save interrupt status

       clr            ea                  ;No interrupts

       cir            io select

       push           acc

       push           0                   ;Push r0

       clr            a0                  ;A

       clr            a1

       mov            r0,#0h             ;Low address byte for I/O chip px1 pins

       movx           a,@r0

       mov            io_status,a

       setb           a0

       setb           a1

       pop            0                   ;Pop r0

       pop            acc

       pop            ie                  ;Restore interrupt status

       ret
write_px2:                                     ;Data from px2_temp to px2

       push          ie                   ;Save interrupt status

       clr           ea                   ;No interruptions

       clr           io select

       push          acc

       push          0                    ;Push r0

       setb          a0                   ;B

       clr           at

       mov           a,px1_temp

       anl           a,#11110000b

       mov           b,a

       mov           a,px2_temp

       anl           a,#00001111b        ;Keep the input bits high

       orl           a,b

       mov           r0,#00h             ;Low address for I/O chip px1 latch  
         movx          @r0a
       setb          a0

       setb          al

       pop           0                    ;Restore r0

       pop           acc

       pop           ie                   ;Restore interrupt status

       ret
write_io_c:                                  ;Data from px2_temp to px2

       push          ie                   ;Save interrupt status

       clr           ea                   ;No interruptions

       clr           io_select 

       push          acc

       push          0                    ;Push r0

       clr           a0                   ;B
				
				<dp n="d79"/>
        setb           a1

        mov            a,lamps_temp

        anl            a,#11110000b

        rl             a

        rl             a

        rl             a

        rl             a

        mov            r0,#00h                  ;Low address for I/O chip px1 latch

        movx           @r0,a
        setb           a0

        setb           a1

        pop            0                         ; Restore r0

        pop            acc

        pop            ie                        ;Restore interrupt status

        ret
read_px2:

        push           ie                        ;Save interrupt status

        clr            ea                        ;No interrupts

        clr            io select

        push           acc

        push           0                         ;Push r0

        clr            a0                        ;C

        setb           a1

        mov            r0,#0h                   ;Low address for I/O chip px2 pins

        movx           a,@r0

        anl            a,#11110000b             ;Mask the output bits

        anl            px2_temp,#00001111b      ;Mask the input bits in px2_temp

        orl            px2_temp,a               ;Combine inputs/outputs into one byte

        setb           a0

        setb           a1

        pop            0                         ;Pop r0

        pop            acc

        pop            ie                        ;Restore interrupt status

        ret
read_iom_a:                                           ; Data from px2_temp to px2

        push           ie                        ;Save interrupt status

        clr            ea                        ;No interruptions

        setb           io select

        push           acc

        push           0                         ;Push r0

        cir            a0                        ;b

        clr            a1

        mov            r0,#00h                  ;Low address for I/O chip px1 latch

        movx           a,@r0

        setb           a0

        setb           a1

        clr            io_select

        pop            0                         ;Restore r0

        pop            acc

        pop            ie                        ;Restore interrupt status

        ret
write_iom_b:                                          ;Data from px1_temp to px1
				
				<dp n="d80"/>
        push           ie                ;Save interrupt status

        sctb           io_select

        clr            ea                ;No interruptions

        push           acc

        push           0                 ;Push r0

        setb           a0                ;B

        clr            a1

        mov            a,jo_m_b

        mov            r0,#00h          ;Low address for I/O chip px1 latch

        movx           @r0,a

        setb           a0

        setb           a1

        clr            io select

        pop            0                 ;Restore r0

        pop            acc

        pop            ie                ;Restore interrupt status

        ret
write_iom_c:                                ;Data from px2_temp to px2

        push           ie                ;Save interrupt status

        setb           io_select

        clr            ea                ;No interruptions

        push           acc

        push           0                 ;Push r0

        clr            a0                ;B

        setb           a1

        mov            a,io_m_c

        mov            r0,#00h          ;Low address for I/O chip px1 latch

        movx           @r0,a

        setb           a0

        serb           a1

        clr            io select

        pop            0                 ;Restore r0

        pop            acc
        pop            ie                ;Restore interrupt status

        ret
reset_io_m:

        push          ie                 ;Save interrupt status

        clr           ea                 ;No interrupts
        setb          io select

        push          acc

        push          0                  ;Push r0

        setb          a0                 ;Control

        setb          a1

        mov           r0,#0h            ;Low address for I/O chip px2 pins

        mov           a,#10010000b

       movx          @r0,a

        setb          a0

        setb          a1

        clr           io_select

        pop           0                  ;Pop r0

        pop           acc

        pop           ie                 ;Restore interrupt status

        ret
				
				<dp n="d81"/>
reset_io:

       push          ie                           ;Save interrupt status

       clr           ea                           ;No interrupts

       clr           io select

       push          acc

       push          0                            ;Push r0

       setb          a0                           ;Control

       setb          a1

       mov           r0,#0h                      ;Low address for I/O chip p×2 pins

       mov           a,#10011000b

       movx          @r0,a

       setb          a0

       setb          a1

       clr           io select

       pop           0                            ;Pop r0

       pop           acc

       pop           ie                           ;Restore interrupt status

       ret
;*************************************************
;
;           Support Routines
;
;*************************************************
;Generic messages between the TRU and Celjack can be save to aid
;in debugging. This message btdfer is from 90h to FFh.
clr_msg:

        push          1                            ;Save R1

        mov           r1,#msgbuf_start            ;Point to message buffer start

        mov           msg_ptr, r1                 ;Save buffer start
clr_msg1:

        mov           @r1,#55h                    ;Fill with 55h mask

        inc           r1                           ;Point to next location

        cjne          r1,#msgbuf_end,clr_msg1    ;Til end of the buffer

        pop           1                            ;Restore RI

        ret
savemg:

        push          1                            ;Save R1

        mov           r1,msg_ptr                  ;Get current pointer

        cjne          r1,#msgbuf_end,savem1      ;Brif message buffer is not full yet

        mov           r1,#msgbuf_start            ;Repoint to start when full
savem1:  mov           @r1,a                       ;Save msg in buffer

        inc           r1                           ;Advance pointer

        mov           msg_ptr,r1                  ;Save advanced for next time

        pop           1                            ;Restore R1
exit:    ret
;Clear copy of handset′s LCD display from ram display buffer.
				
				<dp n="d82"/>
clr_dsp:

       push          1                               ;Save R1

       mov           r1,#dspbuf_start               ;Point to message buffer start

       mov           dsp_ptr, r1                    ;Savc buffer start
clr_dsp1:

       mov           @r1,#0ffh                      ;Fill with FFh mask

       inc           r1                              ;Point to next location

       cjnc          r1,#dspbuf_end,clr_dsp1       ;Til end of display buffer

       pop           1                               ;Restore R1

       ret
;Some TRUs must save the handiset LCD display info,in a local display
;buffer.
save_dsp:

       push          1                               ;Save R1

       mov           r1,dsp_ptr                     ;Get current pointer

       cjne          r1,#dspbuf_end,save_dsp1      ;Brif message buffer is not full yet
       mov           r1,#dspbuf_start               ;Repoint to start when full
save_dsp1:

       mov           @r1,a                          ;Save msg in buffer

       inc           r1                              ;Advance pointer

       mov           dsp_ptr,r1                     ;Update pointer for next timc

       pop           1                               ;Restore R1
save_dsp2:
;include(SPAIN.asm)

       ret
Snolist
sinclude(SPAIN4.asm)
Slist

       hop

       nop

       end;

Claims (43)

1.一种蜂窝或蜂窝式无线电收发机设备,它包括:蜂窝或蜂窝式无线电收发机;蜂窝或蜂窝式接口装置以及标准陆用电话机,该电话机与蜂窝或蜂窝式无线电收发机相连,所说的接口装置将DTMF或脉冲型拨号信号转换为数字格式以便发送给蜂窝或蜂窝式无线电接收机,从而,可以用在陆用电话机上所拨出的号码去呼叫蜂窝或蜂窝式系统范围内的号码,所述蜂窝或蜂窝式无线电收发机设备的特征在于包括:
自诊断装置,它用于监控和报告前述蜂窝或蜂窝式无线电收发机以及蜂窝或蜂窝式接口装置的适当功能;
用于将自诊断装置交替地连接于蜂窝或蜂窝式接口装置的装置;
上述用于将自诊断装置交替地连接的装置包括这样的装置,它用于在自诊断装置连接于蜂窝或蜂窝式接口装置时断开标准的陆用电话机与蜂窝或蜂窝式接口装置的联系;
上述自诊断装置包括这样的装置,它用于模拟标准陆用电话机的功能以便在蜂窝或蜂窝式接口装置内产生各种相应的应答,从而确定该接口装置是否在正常运转。
2.如权利要求1所述的蜂窝式无线电收发机设备,其特征在于,用于模拟标准陆用电话机功能的装置包括这样的装置,它用于向蜂窝或蜂窝式接口装置产生一个摘机信号。
3.如权利要求2所述的蜂窝式无线电收发机设备,其特征在于,自诊断装置包括这样的装置,它用于检测前述接口装置响应所生成的摘机信号而产生的拨号音信号是否出现。
4.如权利要求1所述的蜂窝式无线电收发机设备,其特征在于,用于模拟标准陆用电话机功能的装置包括这样的装置,它用于生成一个DTMF信号并将该信号传送给前述接口装置。
5.如权利要求4所述的蜂窝式无线电收发机设备,其特征在于,自诊断装置包括这样的装置,它用于检测前述接口装置因响应生成DTMF信号的装置所生成的DTMF信号而输出的DTMF信号。
6.如权利要求1所述的蜂窝式无线电收发机设备,其特征在于,用于模拟标准陆用电话机功能的装置包括这样的装置,它用于向前述接口装置生成一个挂机信号。
7.如权利要求6所述的蜂窝式无线电收发机设备,其特征在于,自诊断装置包括这样的装置,它用于模拟对收发机所进行的电话呼入,以便使前述接口装置启动自身的振铃发生器;该自诊断装置还包括用于检测由此产生的振铃信号的装置。
8.如权利要求7所述的蜂窝式无线电收发机设备,其特征在于,用于模拟标准陆用电话机功能的装置包括这样的装置,它用于在前述接口装置正在产生振铃信号时向该接口装置产生一个摘机信号,以便确定接口装置在应答电话呼入时适时地断开振铃信号。
9.如权利要求1所述的蜂窝式无线电收发机设备,其特征在于,自诊断装置包括这样的装置,它用于通过前述接口装置和收发机以及电话系统产生一电话呼出并送回给该无线电收发机;上述自诊断装置还包括这样的装置,它用于检测前述收发机因响应上述电话呼叫而产生的忙音信号;上述用于产生电话呼出的装置呼叫业已分配给上述收发机并与该收发机实际相联的电话号码。
10.一种检测设备,它用于检测蜂窝或蜂窝式接口装置的适当操作,所说的接口装置能与陆用电话或电话式设施相连,并且能将来自与之相连的陆用电话设施的DTMF信号或脉冲式拨号信号转换成数字数据格式以便将该数字数据传送给前述收发机,所说的检测设备包括:
诊断装置,它用于监控和报告前述接口装置的适当功能。
11.如权利要求10所述的检测设备,其特征在于,该检测设备还包括用于将诊断装置交替地连接于前述接口装置的装置;
所说的诊断装置包括这样的装置,它用于模拟标准陆用电话的功能以便在前述接口装置内产生各种相应的应答,从而确定接口装置是否在正常运转。
12.如权利要求11所述的检测设备,其特征在于,上述用于交替连接诊断装置的装置包括这样的装置,它能在诊断装置连接于前述接口装置时断开标准陆用电话式设施与前述接口装置的联系。
13.如权利要求11所述的检测设备,其特征在于,用于模拟标准陆用电话式设施功能的装置包括这样的装置,它用于向前述接口装置产生一摘机信号。
14.如权利要求13所述的检测设备,其特征在于,所说的诊断装置包括这样的装置,它用于检测前述接口装置因响应所生成的摘机信号而产生的拨号音信号是否出现。
15.如权利要求11所述的检测设备,其特征在于,用于模拟标准陆用电话式设施的装置包括这样的装置,它用于生成一个DTMF信号并将该信号传送给前述接口装置。
16.如权利要求15所述的检测设备,其特征在于,所说的诊断装置包括这样的装置,它用于检测前述接口装置因响应生成DTMF信号的装置所生成的DTMF信号而输出的DTMF信号。
17.如权利要求15所述的检测设备,其特征在于,用于模拟标准陆用电话式设施功能的装置包括这样的装置,它用于向前述接口装置生成一个挂机信号。
18.如权利要求10所述的检测设备,其特征在于,所说的诊断装置包括这样的装置,它用于模拟对收发机所进行的电话呼入,以便使前述接口装置启动自身的振铃发生器;该诊断装置还包括用于检测由此产生的振铃信号的装置。
19.如权利要求18所述的检测设备,其特征在于,所说的诊断装置还包括这样的装置,它用于在前述接口装置正在产生振铃信号时向该接口装置产生一个摘机信号,以便确定接口装置根据对电话呼入的应答而适时地断开振铃信号。
20.如权利要求10所述的检测设备,其特征在于,所说的诊断装置包括这样的装置,它用于在前述接口装置连接于收发机时通过蜂窝或蜂窝式电话网产生一个电话呼出并送回给上述无线电收发机,从而,所说的诊断装置会使得收发机呼叫自己;上述诊断装置还包括这样的装置,它用于检测前述收发机因响应上述电话呼叫而产生的忙音信号,上述用于产生电话呼出的装置呼叫业已分配给与前述接口装置相连的收发机的电话号码。
21.一种利用诊断装置检测蜂窝或蜂窝式接口装置适当操作的方法,所说的接口装置可与陆用电话或电话式设施相连,并且能将来自与之相连的陆用电话式设施的DTMF信号或脉冲式拨号信号转换成数字数据格式,以便将该数字数据传送给前述收发机,所说的方法包括:
(a)监控并报告前述接口装置功能。
22.如权利要求21所述的方法,其特征在于所说的步骤(a)包括:
(b)将诊断装置交替地连接于前述接口装置;
(c)模拟标准陆用电话式设施的功能以便在前述接口装置内产生各种相应的应答,从而确定接口装置是否在正常地操作。
23.如权利要求22所述的方法,其特征在于,所说的步骤(b)包括在诊断装置连接口装置时断开标准陆用电话式设施与前述接口装置的连接。
24.如权利要求22所述的方法,其特征在于,所说的步骤(c)包括向前述接口装置产生一摘机信号。
25.如权利要求21至24所述的方法,其特征在于,它还包括检测前述接口装置因响应所生成的摘机信号而产生的拨号音信号是否出现。
26.如权利要求22所述的方法,其特征在于,所说的步骤(c)包括生成一个DTMF信号并将该信号传送给前述接口装置。
27.如权利要求26所述的方法,其特征在于,它还包括检测前述接口装置因响应所生成的DTMF信号而输出的DTMF信号。
28.如权利要求236所述的方法,其特征在于,所说的步骤(c)包括向前述接口装置产生一个挂机信号。
29.如权利要求21所述的方法,其特征在于,所说的步骤(a)包括模拟对收发机的电话呼入,以便使前述接口装置启动自身的振铃发生器并且检测所产生的振铃信号。
30.如权利要求29所述的方法,其特征在于所说的步骤(a)还包括在前述接口装置正在产生振铃信号时向该接口装置产生一个摘机信号,以便确定接口装置在应答电话呼入时适当地断开振铃信号。
31.如权利要求21所述的方法,其特征在于,所说的步骤(a)包括在前述接口装置连接于收发机时通过蜂窝或蜂窝式电话网产生一个电话呼出并送回给上述无线电收发机;该产生电话呼出的步骤使收发机呼叫自己,并且还包括检测上述蜂窝或蜂窝式无线电收发机因响应电话呼叫而产生的忙音信号。
32.一种无线电收发机设备,它包括:无线电收发机,接口装置,以及与无线电收发机相连的通信设备;所说的接口装置使通信设备与无线电收发机相连接进行工作,以便通过无线电收发机呼出或接收呼叫,其特征在于:
自诊断装置,它用于监控并报告无线电收发机和接口装置的适当功能;
用于将自诊断装置交替地连接于前述接口装置的装置;
上述装置包括这样的装置,它用于在自诊断装置连接于接口装置时断开通信设备与该接口装置的连接;
上述的自诊断装置包括这样的装置,它用于模拟通信设备的功能以便在接口装置内产生各种相应的应答,从而确定该接口装置是否在正常的操作。
33.如权利要求32所述的蜂窝式收发机设备,其特征在于,用于模拟通信设备功能的装置包括这样的装置,它用于向接口装置产生一个摘机信号。
34.如权利要求33所述的蜂窝式收发机设备,其特征在于,自诊断装置包括这样的装置,它用于检测前述接口装置响应所生成的摘机信号而产生的拨号音信号是否出现。
35.如权利要求32所述的蜂窝式收发机设备,其特征在于,用于模拟通信设备功能的装置包括这样的装置,它用于生成一个DTMF信号并将该信号传送给前述接口装置。
36.如权利要求35所述的蜂窝式收发机设备,其特征在于,自诊断装置包括这样的装置,它用于检测前述接口装置因响应用于生成DTMF信号的装置所生成的DTMF信号而输出的DTMF信号。
37.如权利要求32所述的蜂窝式收发机设备,其特征在于,自诊断装置包括这样的装置,它用于模拟对收发机所进行的电话呼入,以便使前述接口装置启动自身的振铃发生器,该自诊断装置还包括用于检测由此产生的振铃信号的装置。
38.如权利要求32所述的蜂窝式收发机设备,其特征在于,自诊断装置包括这样的装置,它用于通过接口装置和收发机以及与该收发机相联的无线电电话系统产生一个电话呼出并送回给该收发机;自诊断装置还包括这样的装置,它用于检测前述收发机因响应上述电话呼叫而产生的忙音信号;上述用于产生电话呼出的装置呼叫业已分配给上述收发机并与该收发机在操作上相联的电话号码。
39.一种检测设备,用于检测接口装置的适当操作,所说的接口装置能与通信设备相连从而使该通信设备与无线电收发机在操作上相连,以便通过无线电收发机呼出或接收呼叫,所说的检测设备包括:
诊断装置,它用于监控和报告前述接口装置的适当功能。
40.如权利要求39所述的检测设备,其特征在于,该检测设备还包括用于将诊断装置交替地连接于前述接口装置的装置;
所说的诊断装置包括这样的装置,它用于模拟通信设备的功能以便在前述接口装置内产生各种相应的应答,从而确定接口装置是否在正常地操作。
41.一种利用诊断装置检测接口装置适当操作的方法,所说的接口装置可将通信设备与无线电收发机连接起来,从而通信设备可通过无线电收发机呼出或接收呼入,所说的方法包括:
(a)监控并报告前述接口装置的功能。
42.如权利要求41所述的方法,其特征在于,所说的步骤(a)包括:
(b)将诊断装置交替地连接于前述接口装置;
(c)模拟通信设备的功能以便在前述接口装置内产生各种相应的应答,从而确定接口装置是否在正常地操作。
43.如权利要求42所述的方法,其特征在于,所说的步骤(b)包括在诊断装置连接于前述接口装置时断开通信设备与接口装置的连接。
CN94191585A 1993-03-25 1994-03-02 用于蜂窝式无线电收发机系统的自诊断系统 Expired - Fee Related CN1064808C (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
US3762793A 1993-03-25 1993-03-25
US08/037,627 1993-03-25

Publications (2)

Publication Number Publication Date
CN1119898A true CN1119898A (zh) 1996-04-03
CN1064808C CN1064808C (zh) 2001-04-18

Family

ID=21895376

Family Applications (1)

Application Number Title Priority Date Filing Date
CN94191585A Expired - Fee Related CN1064808C (zh) 1993-03-25 1994-03-02 用于蜂窝式无线电收发机系统的自诊断系统

Country Status (34)

Country Link
EP (1) EP0691058B1 (zh)
JP (1) JPH08510872A (zh)
CN (1) CN1064808C (zh)
AT (1) ATE162036T1 (zh)
AU (1) AU674406B2 (zh)
BG (1) BG100027A (zh)
BR (1) BR9405970A (zh)
CA (1) CA2154789C (zh)
CZ (1) CZ287151B6 (zh)
DE (1) DE69407773T2 (zh)
DK (1) DK0691058T3 (zh)
EC (1) ECSP941059A (zh)
EE (1) EE9400437A (zh)
ES (1) ES2080708T3 (zh)
FI (1) FI954509A0 (zh)
GR (1) GR3026552T3 (zh)
HK (1) HK1002642A1 (zh)
HU (1) HU216556B (zh)
IL (1) IL108809A (zh)
LT (1) LT3323B (zh)
LV (1) LV11510A (zh)
MD (1) MD940289A (zh)
MY (1) MY110488A (zh)
NO (1) NO953791D0 (zh)
NZ (1) NZ263661A (zh)
OA (1) OA10229A (zh)
PE (1) PE12695A1 (zh)
PL (2) PL173533B1 (zh)
SI (1) SI9420026A (zh)
SK (1) SK118995A3 (zh)
TR (1) TR28486A (zh)
UY (1) UY23744A1 (zh)
WO (1) WO1994022255A1 (zh)
ZA (1) ZA941880B (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FI102124B1 (fi) 1996-03-07 1998-10-15 Nokia Telecommunications Oy Tilaajaliittymän kaukotestaus johdottoman tilaajaliittymän toteutettavassa radiojärjestelmässä
US6349199B1 (en) 1998-02-12 2002-02-19 Ericsson Inc. Reliable continuously operating fixed cellular terminal
DE19953640A1 (de) * 1999-11-09 2001-05-10 Deutsche Telekom Ag Verfahren zum telekommunikationsgestützten Schutz und Auffinden von Lebewesen
CN100407839C (zh) * 2004-12-17 2008-07-30 中兴通讯股份有限公司 移动电话通讯的自动测试方法及移动电话自动呼叫器

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS5989043A (ja) * 1982-11-12 1984-05-23 Hitachi Ltd 移動電話装置保守診断方式
US4658096A (en) * 1984-09-18 1987-04-14 Metrofone, Inc. System for interfacing a standard telephone set with a radio transceiver
US4737975A (en) 1984-09-18 1988-04-12 Metrofone, Inc. Programmable system for interfacing a standard telephone set with a radio transceiver
US4788711A (en) * 1985-11-25 1988-11-29 Cellular Communications Corporation Apparatus and method for a cellular freeway emergency telephone service
US5020135A (en) * 1987-03-27 1991-05-28 Teletec Corporation Computerized multistandard, field-convertible, multiregional/multiservice, remote controllable, remote programmable mobile two-way radio system with digital serial bus link, built-in programmer and autodiagnostics
GB8823408D0 (en) * 1988-10-05 1988-11-09 Smith Myer Electronic test equipment
US5095500A (en) * 1989-12-07 1992-03-10 Motorola, Inc. Cellular radiotelephone diagnostic system
US5073919A (en) * 1990-10-10 1991-12-17 Teradyne, Inc. Automatically testing telephone lines

Also Published As

Publication number Publication date
LV11510A (lv) 1996-08-20
FI954509A (fi) 1995-09-22
HU216556B (hu) 1999-07-28
CA2154789C (en) 1999-04-20
AU6443194A (en) 1994-10-11
EE9400437A (et) 1996-06-17
MY110488A (en) 1998-06-30
ZA941880B (en) 1994-11-01
PL310775A1 (en) 1996-01-08
NO953791L (no) 1995-09-25
PL173533B1 (pl) 1998-03-31
IL108809A (en) 1997-02-18
PL174142B1 (pl) 1998-06-30
SK118995A3 (en) 1998-05-06
MD940289A (ro) 1995-09-30
HU9502752D0 (en) 1995-11-28
EP0691058B1 (en) 1998-01-07
CN1064808C (zh) 2001-04-18
TR28486A (tr) 1996-09-02
DE69407773D1 (de) 1998-02-12
JPH08510872A (ja) 1996-11-12
NZ263661A (en) 1996-07-26
FI954509A0 (fi) 1995-09-22
BG100027A (en) 1996-09-30
ES2080708T3 (es) 1998-05-01
CZ287151B6 (en) 2000-09-13
ES2080708T1 (es) 1996-02-16
AU674406B2 (en) 1996-12-19
EP0691058A4 (en) 1996-07-03
LT3323B (en) 1995-06-26
GR3026552T3 (en) 1998-07-31
NO953791D0 (no) 1995-09-25
DE69407773T2 (de) 1998-06-18
HK1002642A1 (en) 1998-09-04
IL108809A0 (en) 1994-06-24
ATE162036T1 (de) 1998-01-15
LTIP1901A (en) 1995-01-31
UY23744A1 (es) 1994-08-17
WO1994022255A1 (en) 1994-09-29
PE12695A1 (es) 1995-05-31
CA2154789A1 (en) 1994-09-29
DK0691058T3 (da) 1998-09-07
SI9420026A (en) 1996-06-30
HUT73125A (en) 1996-06-28
OA10229A (en) 1997-10-07
CZ240895A3 (en) 1997-06-11
BR9405970A (pt) 1995-12-12
ECSP941059A (es) 1994-11-16
EP0691058A1 (en) 1996-01-10

Similar Documents

Publication Publication Date Title
US6690923B1 (en) Self-diagnostic system for cellular-transceiver systems with remote-reporting capabilities
US5469494A (en) Self-diagnostic system for cellular-transceiver systems
US5859894A (en) Self-diagnostic system for cellular-transceiver systems with remote-reporting capabilities
US5966428A (en) Self diagnostic system for cellular-transceiver systems with remote-reporting capabilities
CN101483857B (zh) 多模式个人无线通信系统
CN100384260C (zh) 多模式个人无线通信系统
US5896569A (en) Wireless access to telephone network dial tone
IT8922337A1 (it) Sistema di chiamata di emergenza di gruppo.
CN1193448A (zh) 多用户基站及其工作方法
CN1156135C (zh) 用于报告固定无线终端中状态信息的方法及装置
CN1064808C (zh) 用于蜂窝式无线电收发机系统的自诊断系统
CN1179534C (zh) 一种电信系统、一种信道选择方法和一种无线台
CN1124057C (zh) 用于使模拟电话装置与一个数字、模拟或混合电话交换系统相连接的方法和装置
CN1036106C (zh) 程控企业通信系统
CN1889600A (zh) 一种接入网关测试装置、测试系统及测试方法
CN2788466Y (zh) 有线移动通信系统
CN1106601A (zh) 一种无绳电话实现漫游和双向呼叫的方法及其系统
CN1107401C (zh) 用户无线访问系统及发端电话号码显示方法
CN1108042C (zh) 网络接入方法
CN1409533A (zh) 一种无线电话接入系统的实现方法和装置
JP2001358844A (ja) 架空送電線保守監視システム
CN102984407A (zh) 具有近程控制功能的可多个并联使用的电话控制器
CN1140384A (zh) 无统一控制中心超小型大哥大站

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C19 Lapse of patent right due to non-payment of the annual fee
CF01 Termination of patent right due to non-payment of annual fee