电池充电器和利用交变dc充电电流的方法

文档序号:7426781阅读:521来源:国知局

专利名称::电池充电器和利用交变dc充电电流的方法
技术领域
:本发明涉及一种电池充电器,且更明确地说涉及一种针对线性和开关模式电池充电器两者的用于包含汽车和轮船型电池的各种类型电池的电池充电器,其中DC充电电流在非零平均DC充电电流电平之间交变,这允许缩短充电时间且还增加了电池充电器的
背景技术
此项技术中已知各种类型的电池充电器。两种最普遍类型的电池充电器称为线性和开关模式电池充电器。线性电池充电器提供作为输入电压的线性函数的输出电压。未使用的充电功率被完全耗散。开关模式电池充电器较有效。利用此类开关模式电池充电器,仅消耗比产生充电电压和电流所需的输入功率稍多的功率。关于此类开关模式电池充电器存在。电池充电器的充电特性通常经配置以与待充电电池的电池化学性质匹配。举例来说,通常用于汽车和轮船应用中的铅酸电池通常以恒定功率、恒定电流或恒定电压或其组合充电。已知此类电池用线性以及开关模式电池充电器两者充电。转让给与本发明的受让人为同一受让人的第US2005/0088144Al号美国专利申请公开案揭示用于汽车和轮船电池应用的开关模式电池充电器的实例。许多不同考虑因素影响针对特定应用选择特定的电池化学性质。举例来说,铅酸电池由于其传递相对较大量的功率的能力而通常用于汽车和轮船电池应用中。在汽车应用中,需要初始功率突发来启动引擎。在轮船应用(例如,海岸警卫队应用)中,为了用于由美国海岸警卫队部署在美国周围海域中以将天气信息传输给海员的浮标中,电池容量是一个重要的考虑因素。电池容量通常以安培小时为单位进行测量。理论上,安培小时容量是电池可传递指定电平的输出电流的小时数。由于电池内的损失的缘故,已知电池的安培小时输出能力稍小于安培小时输入。在充电期间,有必要在不超过电池制造商所规定的电压、电流或温度(超过的话可能损坏电池)的情况下将电池充电到其完全充电状态。图1中说明示范性轮船电池的示范性电池充电特性曲线。在此实例中,曲线20说明充电电流。最大充电电流受电池制造商所提出的各种参数的限制,例如温度断开(TCO)、温度相对于时间的变化速率(dT/dt)、电流和其它参数。电池充电温度用曲线22标识。曲线24说明电池电压,而曲线26说明周围空气温度。在此特定实例中,在恒定电流模式期间在时间段h期间,最大充电电流限于稍大于40安培的值。基于图1中说明的充电特性,标称充电循环的结束展示于点27处。可通过求得曲线20下方的面积的积分来获得由充电器施加到电池的安培小时。在此示范性情况下,输入到电池的安培小时为40.65Ah。如上文所提及,由于电池内的内部损失的缘故,电池的输出容量将稍低于40.65安培小时。依据图2说明示范性放电曲线。如图所示,当测量端子电压时,根据图1的完全充电的示范性电池在IO安培处放电。对于标称12伏汽车电池,所述电池在IO安培处放电,直到端子电压达到约10.5安培为止,这约为235分钟,如点29所指示。因此,输出容量为10安培X235分钟Xl小时/60分钟,或约39.2安培小时。已知的充电器存在若干问题。首先,充电时间相对较长。第二,已知电池充电器的充电特性要求此类电池充电器额定在相对较低的值。
发明内容本发明涉及一种电池充电器,其用于例如汽车和轮船型电池等各种类型的电池。根据本发明的一方面,充电电流在非零DC充电电流电平之间交变。通过使DC充电电流在两个非零充电电平之间交变,电池可较快地充电到较高的容量(即,安培小时),因此縮短充电时间且同时允许此类充电器的额定值用于相对较高电流应用中。根据本发明的另一重要方面,用于使平均DC充电电流交变的技术可在线性和开关模式电池充电器两者中实施。参看以下说明书和附图将容易理解本发明的这些和其它优点,附图中图1是通过已知电池充电器对示范性轮船电池进行充电的示范性充电曲线。图2是结合图1利用的示范性轮船电池的示范性放电曲线。图3是通过根据本发明的电池充电器对示范性轮船电池进行充电的示范性充电曲线。图4是图3中说明的电池的示范性放电曲线。图5是由根据本发明的开关模式电池充电器产生的示范性充电循环的图。图6是说明叠加在同一照片上的由根据本发明的开关模式和线性电池充电器产生的示范性充电循环的图。图7说明用于本发明的示范性100安培开关模式电池充电器的控制板的示范性示意图。图8说明图7中说明的100安培开关模式电池充电器的配电板的示范性示意图。图9是示范性60安培高频开关模式型电池充电器的控制板的示范性示意图。图IO是图9中说明的60安培电池充电器的配电板的示范性示意图。图11是线性型电池充电器的控制板的示范性示意图。图12是图11中说明的电池充电器的配电板的示范性示意图。图13是线性推动的(linear-wheeled)线性电池充电器的控制板的示范性示意图。图14是图13中说明的电池充电器的配电板的示范性示意图。图15是说明总体控制回路的线性电池充电器的示范性流程图。图16是说明主要控制回路的线性或高频电池充电器的示范性流程图。图17是说明根据本发明的快速充电方法的线性或高频电池充电器的示范性流程图。具体实施方式本发明涉及一种电池充电器和一种对电池进行快速充电并增加电池的放电容量的方法。所述电池充电器用于(例如)各种类型的电池,例如汽车和轮船型电池、铅酸电池、深循环电池、AGM电池和其它电池类型,且可在线性和开关模式电池充电器拓扑两者中实施。根据本发明的一重要方面,平均DC充电电流在非零充电电流电平之间交变。通过使平均DC充电电流在非零充电电平之间交变,电池可充电到较高的电平,因此提供增加的输出容量且还可更快地进行充电。图3中说明根据本发明的电池充电器的示范性充电曲线,而图4中说明示范性放电曲线。首先参看图3,通常由参考标号28标识的曲线说明充电电流。曲线30说明充电电压,而曲线32说明周围温度。曲线34说明电池温度。如图所示,曲线28说明在电池充电器的第一阶段(标识为t。期间,平均DC充电电流波形在两个非零值之间交变,其中最大值稍许超过40安培且最小值约为15安培。最小和最大充电电流值具有以几秒、几十秒等计的周期。最小和最大充电电流的每一周期表示在零安培与某一正DC值之间变化的若干DC充电脉冲的DC平均值。举例来说,已知线性电池充电器产生120赫兹的充电电流脉冲。己知开关模式电池充电器产生高得多的频率的充电电流脉冲。然而,这些充电电流脉冲,不论是由线性电池充电器还是开关模式电池充电器产生,均具有预定工作循环、频率和量值,且可在特定时间段内进行平均以确定其平均值,例如通过DC安培计进行测量。本发明涉及使线性和开关模式电池充电器两者的充电电流脉冲的平均值在两个非零值之间变化。举例来说,如图3中所说明,DC平均值在15安培与40安培之间变化。如图3中所说明,点35说明在约10.3小时处的完全充电状态。如上文所提及,曲线28下方的面积表示对于示范性电池的总体输入容量。在此实例中,以126.1安培小时对电池进行充电;其超过对于图1和2中说明的相同类型的电池的输入充电(inputcharge)的三倍。如上文所提及,电池的放电容量由于电池内的内部损失的缘故而稍小于输入充电。如图4中所说明,电池在IO安培处放电直到端子电压达到10.5伏为止。如点38所指示,认为电池在点38处或约646分钟时放电。因此,放电容量为10安培X646分钟X—小时/60分钟或约107.7安培小时与通过如图1和2中说明的已知电池充电器充电时的电池容量相比,存在150%的改进。交变DC充电波形提供若干益处。首先,根据本发明的充电器允许较快地将较多能量抽运到电池中,藉此减少充电时间。第二,根据本发明的充电器允许电池充电器的额定值增加。举例来说,使用根据本发明的技术允许(例如)在40安培应用中使用15安培电池充电器。根据本发明的一重要方面,DC交变充电电流技术适用于线性和开关模式充电器两者。图5说明开关模式充电器的示范性平均DC充电电流波形,而图6说明开关模式和线性充电器两者的示范性波形。如图5所示,以参考标号40标识的示范性波形在两个非零平均DC电流值10安培与30安培之间交变,周期为270秒(420-150)或4^分钟。如图所示,所述示范性波形提供30安培的平均DC充电电流持续75秒(240-165),以及10安培的平均DC充电电流持续150秒(420-270),总共225秒。如图所示,电流波形可能由于实际DC充电脉冲(由示波器所测量)的相对较高频率的缘故而并非完美的方波,且事实上,可能在两个非零值之间斜线上升和斜线下降。举例来说,如图5中所说明,波形40的上升沿(以参考标号42标识)在(例如)15秒的一个示范性递增时间段中,在10安培的第一非零DC值与30安培的第二非零DC电流值之间斜线变化。波形40的下降沿(以参考标号44标识)在(例如)30安培的两个示范性递增时间段中,在标称30安培与IO安培之间下降。图6说明其它示范性充电波形。明确地说,图6说明对于开关模式和线性电池充电器两者在15安培DC与40安培DC之间交变的示范性DC充电电流波形。明确地说,曲线46说明开关模式充电波形,其类似于图5。曲线48说明线性型电池充电器的示范性交变充电波形。如图所示,线性型电池充电器的波形大体上为方波,其中波形的上升沿50和下降沿52实质上垂直于水平轴。应理解,本发明的原理适用于具有各种周期的各种波形配置。还应了解,充电循环中的交变DC电流充电波形不需要为均一的。举例来说,在同一充电循环内,波形可在不同的上与下DC电流值之间变化,或者可相对恒定。并且,在特定充电循环内,波形的周期可变化。所有此类实施例均预期在本发明的当前范围内。硬件如上文所提及,本发明的原理适用于开关模式和线性模式电池充电器两者。图7-12中说明各种示范性线性和开关模式示意图。2005年4月28日公开的美国专利申请公开案US2005/0088144Al(以引用的方式并入本文中)中大体描述了示范性开关模式充电器硬件。图7-10说明开关模式电池充电器的示范性示意图,而图11-14说明线性型电池充电器的示范性示意图。明确地说,图7说明100安培开关模式电池充电器的控制板的示范性示意图。图8说明图7中说明的IOO安培开关模式电池充电器的配电板的示范性示意图。图9是示范性60安培高频开关模式型电池充电器的控制板的示范性示意图。图10是图9中说明的60安培电池充电器的配电板的示范性示意图。图11是线性型电池充电器的控制板的示范性示意图。图12是图11中说明的电池充电器的配电板的示范性示意图。图13是线性推动的线性电池充电器的控制板的示范性示意图。图14是图13中说明的电池充电器的配电板的示范性示意图。本发明的原理适用于基本上任何线性或开关模式电池充电器或充电电路。一般来说,图7-14中说明的包含各种电池充电器电路的此类电池充电电路均包含功率电路和控制电路。处于控制电路的控制下的功率电路经配置以传递预定充电电流。举例来说,图7和8中说明的开关模式电池充电器经配置以传递2安培、15安培和40安培的可选择充电电流,以及IOO安培的引擎起动充电电流。图9和10说明经配置以传递2安培和60安培的可选择充电电流的示范性开关模式电池充电器。图11-13说明具有可选择的慢速、中速、快速和开始(或起动)充电电流的示范性线性电池充电器。参看图7-14,所述示范性电池充电器的每一者包含若干选择器开关SW1、SW2和SW3,其使得能够选择所需的充电电流。如将更详细论述,这些开关的组合可用于特殊功能,例如手动模式。所述示范性电池充电器还可包含显示器和/或指示灯,其用于指示选定的充电模式且视需要可用于指示适当的启动序列。每一电池充电器,不论是线性还是开关模式的,均包含微处理器或微控制器,例如STMicroelectronics型号ST6225C,如图7、9、11和13中大体说明。微控制器用于控制电池充电器并执行下文论述的软件。作为所述控制的一部分,微控制器监视开关SW1、SW2和SW3的状态如何并且还驱动指示灯,如下文将更详细论述。还应理解,本发明的原理还适用于仅在单一充电电平下进行充电的电池充电器。换句话说,本发明的原理适用于其中充电电流不可选的电池充电器。认为所有此类配置均在本发明范围内。软件下文提供各种电池充电器的源代码。明确地说,文件6,000-P8.asm和10,000-PA.asm中标识的源代码分别针对图9、10和7、8中说明的60和100安培开关模式电池充电器。标识为71223D.asm;71224D細;和30060.asm的源代码文件可用于图11-14中说明的线性电池充电器。图15-17中还说明根据本发明的电池充电器的示范性流程图。尽管图15和17适用于线性电池充电器(接通SCR的步骤除外),但这些图15和17通常也适用于开关模式电池充电器。图16和18适用于线性和开关模式电池充电器两者。首先参看图15,说明总体控制回路。控制回路在电池充电器被加电的任何时间连续运作。明确地说,步骤100说明加电或重设状态。加电或重设之后,在步骤102中,系统检查电池充电器是否已置于测试模式中。可(例如)通过按下测试模式开关(未图示)或按下上文提及的开关SW1、SW2、SW3的组合来启始测试模式。如果电池充电器已置于测试模式中,那么系统在步骤104中依次点亮指示灯(例如,LED)中的每一者,并在步骤106中将控制转移到图16中说明的主要控制回路。在步骤108中,系统检查电池充电器是否已置于手动模式中。可通过单独的开关(未图示)或通过按下开关SW1、SW2、SW3的组合或通过按下开关SW1、SW2、SW3中的一者或一者以上持续预定的时间段来选择手动模式。在手动模式中,电池充电器接通持续预定的时间段,而不管电池是否连接到电池充电器。如果电池充电器不处于手动模式中,那么系统在步骤110中通过检査电池充电器输出端子的电压是否小于预定值(例如,小于0.1伏DC)来检查电池是否连接到电池充电器。如果所述电压小于预定值,那么系统认为无电池连接到电池充电器端子并沿回路返回步骤100。如果电池充电器端子处的电压大于(例如)0.1伏DC,那么系统认为有电池连接到电池充电器端子并前进到步骤112、114和116,其说明图16中所说明的主要程序回路中的各个步骤。在步骤116中,系统离开主要回路。在步骤118中,系统等待定时器中断或不可屏蔽中断(NMI)。明确地说,微控制器测量传入的AC输电线并响应于零交叉而产生不可屏蔽中断(NMI)。NMI用于切断SCR。NMI还启始软件定时器。当定时器超时时,在步骤121中接通SCR。切断SCR之后,在步骤122中读取并存储电池电压。在步骤122中还可维持电池电压的移动平均值。图16是主要控制回路的流程图。初始地,在步骤124中,系统在加电或重设后启始。加电或重设后,在步骤126中,通过初始化I/O、RAM、闲置定时器和测试器模式而初始化电池充电器。一旦电池充电器初始化,就在步骤128中初始化任何电池显示。接着在步骤130中,针对特殊启动模式检査开关SW1、SW2、SW3的状态。举例来说,在线性电池充电器中,系统检查己借助开关SW1、SW2、SW3选择了"慢速"、"中速"还是"快速"充电模式。在步骤132中,系统检查电池充电器是否处于通电自检(POST)模式。如果不是,那么系统在步骤134中检查电池充电器是否处于手动模式,如上文所论述。如果不是,那么系统进入虚线框136内所示的主要程序回路。如果系统确定选择了手动模式,那么在系统进入主要程序回路136之前,在步骤138中设定软件旗标。或者,如果系统在步骤132中确定电池充电器处于POST模式,那么在步骤140中依次点亮各个指示灯或LED。LED点亮之后,系统返回步骤130并检查开关SW1、SW2、SW3以获得选定充电速率。接着,系统再次检查电池充电器是否处于POST模式,如上文所论述。假定系统既不处于POST模式也不处于手动模式,那么电池充电器进入主要控制回路136。进入主要控制回路开始于步骤142,其中系统检査电池充电器是否由于(例如)传入的AC功率的暂时损失的缘故而处于(例如)异常结束模式。如果是,那么系统前进到异常结束模式(状态8)。接着,系统在步骤146中检查电池充电器是否处于手动模式。如果是,那么在步骤148中电池充电器采取手动模式(状态15)。在步骤150中,系统检查电池充电器在引擎启动之后是否正在冷却,即自从电池充电器提供100安培的电流以启动汽车引擎之后是否己过去了预定时间段。如果是,那么系统在步骤152中确定电池容量(例如,以%计)。检査电池容量之后,系统在步骤154中检查电池是否连接到电池充电器端子(如上文所论述)(在步骤154中),并在步骤168中根据选定的充电速率对电池进行充电。如果不是,那么系统在步骤156中采取默认充电状态(状态0)。如果系统在步骤150中确定电池充电器不处于引擎冷却模式(如上文所论述),那么系统在步骤158中检查是否已针对特定充电速率(g卩,快速、中速或慢速)按下开关SW1、SW2、SW3。如果是,那么闲置模式,即不选择任何充电速率时的模式终止。接着,在步骤160中,电池检査是否已选择引擎启动模式。如果是,那么系统前进到步骤152并更新电池容量。如果不是,那么系统前进到步骤162并更新电池容量的任何显示。然后,系统在步骤164中检查电池充电器是否进入了闲置模式(g卩,充电速率开关被取消选定)。如果不是,那么系统在步骤166中检查电池充电器当前是否正在对电池进行充电。如果是,那么系统在步骤154中检查电池是否连接到电池充电器。如果是,那么系统在步骤168中跳到对应于选定的充电速率的状态。如果电池充电器不处于充电模式,如步骤166中所确定,那么系统前进到步骤168并前进到适当状态。如果系统在步骤164中确定电池充电器处于闲置模式,那么系统在步骤170中检查是否已超过闲置时间限制。如果是,那么系统前进到步骤156,进入默认充电状态。如果未超过闲置时间限制,那么系统保持在闲置模式,除非电池充电器正在充电(如步骤166中所确定),且电池连接到电池充电器端子(如步骤154中所确定)。如果电池充电器不在充电(如步骤166中所确定),那么系统前进到步骤168并跳到适当状态。图17是说明对于利用本发明原理并提供如上文所论述处于两个交变非零平均DC充电电流的充电波形的电池充电器的控制的流程图。图17中说明的流程图可配置为来自图15和16的主要程序的分支,只要选择器开关SW1、SW2、SW3选择了充电速率(例如,慢速(2安培)、中速(15安培)或快速(40安培))中的一者或一者以上。如上文所提及,根据本发明的电池充电器提供如上文所论述处于交变非零平均DC电流值的充电电流的充电波形,从而界定快速充电模式。在步骤174中,设定较低平均DC充电电流值。明确地说,设定工作循环以及针对较低平均DC充电电流的定时器。举例来说,参看图5,设定所述波形将供应10安培的平均DC充电电流的工作循环和时间段。接着在步骤176中,系统检査针对较低平均DC充电电流的定时器是否巳超时。如果不是,那么系统在步骤183中检查电池电压是否小于(例如)14.2伏。如果电池电压小于14.2伏,那么在步骤186中设定工作循环以实现恒定电流。如果电池电压大于14.2伏,那么系统在步骤188中继续充电。如果较低速率定时器已超时,那么系统途经步骤180而前进到步骤178并设定工作循环和定时器以实现较高的平均DC值。参看图5,此对应于电池充电器供应30安培的工作循环和时间段。在步骤180中,系统首先确定电池充电器尚未在较高的平均DC充电电流下充电。如果电池充电器正在较高的平均DC充电电流下充电(如步骤182中所确定),那么系统在步骤184中检査电池电压是否小于(例如)Vmax+0.2伏。如果是,那么在步骤186中调节工作循环以实现恒定的平均DC充电电流。或者,如果电池正以较低速率被充电,那么系统在步骤183中检査电池电压是否已达到14.2伏。如果是,那么系统前进到步骤186并如上文所论述调节工作循环。系统接着在步骤176中检査针对较高平均DC充电电平的定时器是否已超时。一旦电池电压超过Vmax+0.2伏(如步骤184中所确定),就在步骤186中设定工作循环以实现较低平均DC充电电流,且系统在步骤188中继续在较低平均DC充电电流下充电。当在较低平均DC充电电流下充电时,在系统己检测到大于Vmax+0.2伏的电池电压之后,系统在步骤190中检查电池电压是否己整平。如果电池电压已整平,那么在步骤192中调节工作循环以实现恒定的充电电压,例如恒定15.5伏DC。系统在步骤194中检查工作循环是否已整平。如果不是,那么系统在步骤196中检查工作循环是否设定为最小值。如果不是,那么系统沿回路返回步骤192。如果是,那么在步骤198中调节工作循环以实现恒定的浮动电压,例如13.2伏。如果系统在步骤190中确定电池电压电平未整平,那么系统在步骤200中检査电池电压是否^Vmax。如果是,那么系统返回步骤192并调节工作循环以实现恒定的充电电压。如果不是,那么系统返回步骤188并继续充电。源代码6000-P8.asmChecksum;RawCode:76E28;W池Info:74B3D;*COPYRIGHT2006SCHUMACHERELECTRIC*ALLRIGHTSRESERVED*SchumacherHighFrequencyAutoCharger/StarterThiscodeisfortheSGS-THOMPSONmicro-controlerPartnumberST62T15/ST62E15/ST62T25/ST62E25*.title"HFSVer.0.80".LINESIZE131.vers"ST6225",romsize4.W一ONDEBUG.SET1;1->normal,0->IgnoreTypeandRateswitchesafterSS5SloRmp,SET1;1->normal,0->RampslowlyfrommintomaxoffsetNoDrop,SET1;1->normal,0->Don'tcalculatecabledropShoOff.SET1;1->normal,0->ShowOFFSETAlt%modeduringchargingShoReg.SET1;1->normal,0->FlashLED'stoindicateup/downchangeFastBI.SET1;1->normal,0->7minuteBurn-Ininsteadof60minutesFastCP.SET1;1->normal,0->7minChkProgintervalinsteadof60minDefinetheporthardwarelocations*Attimes,the.defstatementisfollowedbyavalueand"!迈".The!m;*isusedbythesimulator/emulatorfordebugging.Thissymboltellsthe*equipmentwhatregisterstheuserwantstomonitorduringdebuging.X,def80h!mY.def81hV.def82hW.def83h;Indexregister,Indexregister,Shortdirectregister;ShortdirectregisterA.defOffh!m;AccumulatorDRA.def0c0h!mDRB,defOclh!迈DRC,def0c2h;Portadataregister;Portbdataregister;PortcdataregisterDDRA.def0c4hDDRB.def0c5hDDRC.def0c6h;Portadirectionregister;Portbdirectionregister;PortcdirectionregisterORA.defOcchORB.defOcdhORC.defOcehPortaoptionregisterPortboptionregisterPortcoptionregisterADR,def0d0h!mADCR.defOdlh;A/DdataregisterjA/DcontrolregisterPSC.defO咖TCR'.def0d3h!迈TSCR,def0d4h;Timerprescalerregister;Timercounterregister;TimerstatuscontrolregisterWDR.def0d8h;"WatchdogregisterIOR'def0c8h!mDRWR.defOc9h;Interruptoptionregister;DataromwindowregisterThesearetheramequatesusedbythebatterycharger.DRAbuf,def084h;shadowramforportAdataregisterDRBbuf.def085h;shadowramforportBdataregisterDRCbuf'def086h;shadowramforportCdataregisterATemp.def087h;AccumulatortemporarystorageXTEMP.def088h;XregistertemporarystorageMSECsl,def089h;storagefor8.333mstics-countof120-1secSECsl.def08Ali;storagefortimerlsecondsMINsl.def08Bh;storagefortimerlminutesHRsl,def08Ch;storagefortimerlhoursTicFlagl.def08Dh;overflowflagsforSECsl,MINsl,andhoursMSECs2.def08Eh^millisecondoneccmnterSECs2,def08Fh;storagefortimer2secondsMINs2.def090h;storagefortimer2minutesHRs2.def091h;storagefortkner2hoursTicHag2.def092h;overflowflagsforsecsl'MINs2,andhourslTries,5ef093h;usedbybatterydetectroutinesTEMP.def094h;scratchpadareaTEMPI.def095h;scratchpadareaTemp2.def096h;咖ntusedforFreshBVCurVolt.def097h;currentbatteryvoltageMaintVolt.def098h;storageforMAINTAINvoltagelevelOldVolt.def099h;previousbatteryvoltage,usedfordv/dtCCDcnt.def09Ah;displaycountdownduringcrankcooldownOldOff.def09Bh;oldvalueofOFFSETusedindl/dtBADlo.def09Ch;lowbftsbatteryvoltageaverageBADhi.def09Dh;hibitsbatteryvoltageaverageVmax.def0犯h;maximumbatteryvoltage(perBatteryType)Vref.def09Fli;refvoltagefordesulfationOFFSET.def0A0h;storageforphasedelayvalueFreshBV.def0Alh;avgbattvoltusedfordi/dtrefPBVTotLo,def0A2h;lowbyteoftotalusedforFreshBVFBVTotHi.def0A3h;highbyteoftotalusedforBreshBVCurentSS.def0A4h;storescurrentchargerstateFlags.def0A5h;chargerconfigurationstates;bitO(BatTypeA):0forReg,lforD/C;bit1(BatTypeB;:0forNorm:1forAGM/GEL;bit2(Rate):0forSlow,1forFast;bit3(Crank):1ifinBoostmode;bit4(CrankWait):1duringE/Scooldown;bit5(Started):1ifchargingstarted;bit6(MtrUnits):0forVolts,1for%;bit7(MtrScale》0forBat"1forAltFlags2,def0A6h;storesthefoUowingFlags;5it0(Batt):1ifbatteryconnected;bit1(NoOff):1ifnoPWMofftime(fullon);bit2(HiPwr、1ifoutputis>10A<formula>formulaseeoriginaldocumentpage15</formula>VRcnt.def0B6h;CounterforvoltageregulationintervalPcntL.def0B7h;NMIcounterforpercentdisplayupdatePcn氾.defOB8I1;IntervalcounterforpercentdisplayupdateDspPcnt.def0B9h;storageforlastpercentdisplayedHags4.defOBAh;storesthefollowingFlags;bit0(IdleSet):1if10minuteIdletimerwasstarted;bit1(NoRamp):1duringManualFastcharge;bit2^SOC):1ifatstartofcharge(1st5s);free,defOBBh;free;free.def0BCh;free;free.defOBDh;fi:ee;free.defOBEh;free;free,def0BFh;free;OBFh=lastRAMlocation;承Thesearetheconstantsusedbythebatterycharger,*Volts005.equ008h;0.5VOLTSVoltsO.叫uOOAh;0.7VOLTSVoltsOl.equOOFh;1.0VOLTSVolts09.equ087h;verydischargedbatteryvoltageVoltslO.equ096h;10.0VOLTSBattMin.equOAFk;lowestvalueinBattery%LUTVoltsl2.equ0B4h;lowbatteryvoltageVoltsl22.equOB7hVoltsl25,equOBCIiBattMax.equOBDh;highestvalueinBattery%LUTVoltsl27,equOBEhVoltel28.equOC0h;goodbatterytestvoltageVoltsl3.equOC3hVolts132.equOC6hVoltsl35导OCAhAltMin.equ0CBh;lowestvalueinAlternator%LUTVolts38.equOCThVoltel4.equ0D2hVoltsl42.equ0D5h;startmonitoringdv/dtvoltageVoltsl435,equOD71iVoltsl44,equ0D81iVolts146.equ0DAh;maximuinalowedvoitagefbrreg/gemodeVoltsl47.equ0DQl;starttrickletimervoltageVoltsl49.equOEOh;14.87VVoltsl5.equ0Elh;maxim腿allowedvoltageforKV/DCMarineVoltsl5a,equOE2h;15.07VAltMax.equ0E7h;highestvalueinAlternator%LUTVolts155.equ0E9h;maximumallowedvoltageforAuto/MarineStartingVoltsl6.equ0F0h;maximumallowedvoltageVolts165.equ0F7h;maximumallowedvoltagefordeepcycle2MaxVolts.equOFFh;maximumvoltagereading-17.0VMaxDrpH.equ00Eh;maximumoutputcablevoltagedrop@highpowerMaxD卬L.equ005h;maximumo鄉utcablevoltagedrop@lowpowerSRIM'equ002h;slowrampintervalmultiplier=>secs/intRCinit.equ064h;1003/8-secondintervalsyields37,5secondsRCinitX2.equ0C8h;2003/8-secondintervalsyields75secondsRIinit.equ02Dh;45MMinterruptsyields0.375seconds;RIinit,equ0B4h;180NMIinterruptsyields1.5secondsMSDMIT.equ078h;millisecondinitializationvalue(120)MS500.equ03Ch;millisecondcountervaluefor500mS(60)MS200.equ018h;millisecondcountervaluefor200mS(24);MSINIT.equ07Fh;millisecondinitializationvalue(127);MS500.equ03Fh;millisecondcountervaluefor500mS(60)Seclnit.equ03Ch;secondinitializationvalue(60)MININ1T.equ03Ch;minuteinitializationvalue(60)MaxHrs.equ25;maximumallowedchargehours+1CPint.equSo;minutesperchargeprogressinterval孤.叫u000h;hoursbitofTicFlaglandTicFlag2MIN.equ001h;minutesbitofTicFlaglandTicFlag2SEC.equ002h;secondsbitofTicFlaglandTicFlag2MSEC.equ003h;mimsecondsbitofTicFlaglandTicFlag2VLO.equOCOh;lowlinelimit-100VACVffl.equ0EEh;higlilinevoltagelimit-130VACPCint,equ00Ah;iramberof1-secondintervalsbetween%updatesFUULTHilE.equ0B4h;halfsecondwhenACpowerisOFFMinOff.equ005h;Minoffset->maxdutycycleSlowAmps.equ2;NominalampsoutatSlowrateFastAmps.equ10;NominalampsoutatFastrateRapAmps.equ30;NominalampsoutatRapidrateCrnkAmps.equ60;NominalampsoutatCrankrateCodeRev.equ0;softwarerevisionlevelOffSlow.equ07Fh;Nominaloffsetforslowcharge(~20%)OfERap.equ071h;Nominaloffsetforrapidcharge(~40%)O他I.equ0A4Ji;OffsetformaxBuni-Incharge(~6%)OffCrank.equ036h;OFFSETforCrankstandbyHiOff.equ0A7h;highlimitforOFFSETvariableABORT.equ008h;abortstateLEDslow.equ007h;SlowLED-bitofSwDataLEDrap.equ006h;RapidLED-bitofSwDataLEDfast.equ005h;FastL:ED-bitofSwDataLEDboost,equ004h;CrankLED-bitofSwDataLEDgel.equ003h;AGM/GelLED-bitofSwDataLEDdeep.equ002h;DpCyclLED-bitofSwDataLEDreg.equ001h;RegularLED-bitofSwDataLEDdone.equ000h;ChargedLED-PORTALEDchgng.equ00lh;ChargingLED-PORTALEDalert导002h;FaultLED-PORTALEDprcnt.equ003h;PercentLED-PORTALBDvolt.equ004h;VoltageLED-PORTALEDalt.equ005h;AltmtrLED-PORTASerData.equ006h;SerialData-PORTACkData.equ007h;DataClear-PORTAShftClk.equ000h;ShiftClock-PORTBLtchClk.equ001h;LatchClock-PORTBPWMIo.equ002h;LoPWMCtrl-PORTBDisable.equ003h;Disablectrl-PORTBPWMhi.equ007h;HiPWMCtrl-PORTBFanCtl.equ004h;Fancontrol-PORTCTypeSw.equ005h;Typeswitch-PORTCRateSw.equ006h;Rateswitch-PORTCMeterSw.equ007h;Meterswitch-PORTCSwOff,叫u004h;bitinSwDownfordisabledType&RateswitchesBatTypeA,equOOOh;bitinFlagsforbatterytype:0=Reg,1=D/CBatTypeB,equOOlh;bitinFlagsforbatteryt^e:1-AGM/GelCellRate,equ002h;bitinFlagsforchargerate:0=Slow,1=FastCrank.equ003h;bitinFlagsthatindicatesenginestartCrankWait,equ004h;bitinFlagsthatindicatescooldownbetweencranksStarted.equ0仑5h;bitinFlagsthatindicateschargestartedMtrUnits.equ006h;bitinFlagsformeterunits:0=volts,1=%MtrScale,equ007h;bitinFlagsformeterscale:0=batt,1-altrntrBatt.equOOOh;bitinFlags2:1ifbatteryisconnectedNoO任,equOOlh;bitinFlags2:1ifnoPWMofftimeHiPwr.equ002h;bitinFlags2:1ifoutputis>10ALoPwr.equ003h;bitinFlags2:1ifoutputisonNMInt.equ004h;bitinFlags2:1ifNMinterrupt,0ifTimerChMode.equ005h;bitinFlags2:1ifinChargermode(notTester)Wa加P.equ006h;bitinFlags2:1ifbattery>10VAlert,equ007h;bitinFlags2:1indicatestroubleRmpng.equOOOh;bitinFlags3:1duringRapid->FasttransitionSettle.equOOlh;bitinFlags3:1duringvoltagesettletimeRmplnt.equ002h;bitinFlags3:1during1sthalfeachRampintervalIdle,equ003h;bitinFlags3:1untilabuttonispressedRampUp.equ004h;bitinFlags3:0->rampingdown,1->rampingupNxtCnt.equ005h;bitinFlags3:0duringlasthalfofCCDcntintervalManual.equ006h;bitinFlags3:1duringManualmodesBumln.equ007h;bitinFlags3:1duringBum-InmodeIdleSet.equOOOh;bitinFlags4:Uf10minuteIdletimerwasstartedNoRamp.equOOlh;bitinF〖ags4:1duringmanualfastchargeSOC.equ002h;bitinFlags4:1duringStartOfCharge(1st5sec)CrankOff.equ002h;crankofftimeinminutes(2)CrankON.equ008h;crankontimeinseconds(8)CCDint.equOOlh;crankcooldowndisplaycounterinterval(seconds)CrankSS.equ010h;crankSSisstate16=10hexDecimal.equ004h;bitinDigiDatlfordecimalpointDigitl,equ000h;bitinDigiDat2formostsignificant1DigiOffa.equ111111lib;bitpatternforallsegementsoffDigiOffb.equ1111111lb;bitpatternforallsegementsoffDigiONa.equOOOOOOOOb;bitpatternforallsegementsONDigiONb.equOOOOOOOOb;bitpatternforallsegementsONDashesl.equ11111101b;bitpatternforallsegementsONDashes2.equ11111011b;bitpatternforallsegementsONSwsOff.equ11111111b;bitpatternforallswitchesoffDigiRevl.equ0001OOOOb;bitpatterntodisplay—8DigiRev2.equ01100001b;bitpatterntodisplay—P—*COLDSTART,.org0880h;forST6210/15.org0100h;forST6220/25RESETCALLRstWDR;resetwatchdogtimerRAMCLRLDIX,084h;pointXto1stRAMLocationRAMCLR1CLRA;clearALD(X),A;storeAatlocationpointedtobyXINCX;incrementXLDA,X;getpointerinACPIA,0COh;testforendofRAMJRNZRAMCLRI;doagainifnotfinishedNowSetUpTheHardwareI/OPortsPORTABit0=LED-Done(Output,0=ON)Bit1=LBD-Charging(Outp叫0=ON)Bit2=LED-Alert(Outp叫O-ON)Bit3=LED-Battery%(Output,0=ON)Bit4=LED-VoltsDC(Output,0=ON)Bit5=LED-Altatr%(Output,0==ON)Bit6=SerialData(Output,0=ON)Bit7=DisplayClear(Output0=clear)Bit#76543210LDIDDRA,11111111b;SetallbitsasoutputsLDIORA,11000000b;open-drainoutputs0-5;6-7push-pullLDIDRA,1111111lb;Setinitialvaluesto1(off)LDIDRAbuf'1111111lb;storesettingsinshadowRAMPORTB;Bit0=Shiftclock(Output,0->l=Shift);Bit1=Latchclock(Output0->l=Latch);Bit2=0-1OAPWM(Output,0=Off,1=1OA);Bit3=Disableout(Output,1=disabled);Bit4=Remotesense(notused);Bit5=BattVoltage(Input,Analog);Bit6=HighVoltage(Input,Analog);Bit7=10A-60APWM(Output,0=10A,1=60A);Bit#76543210LDIDDRB,1001111lb;bits5&6areinputs,othersareoutputsLDIORB,00101111b;Setpush-pulloutputs*,analoginput;*bit7isopendrainoutputLDIDEB,10111011b;Setpush-pulloutput,inputs=0LDIDRBbuf,1011101lb;storesettingsinshadowRAMPORTC;Bit4=FanControl(Output,0=off,1=ON);Bit5=Typeswitch(Input,0=IN/change);Bit6=Rateswitch(Input,0=IN/change);Bit7=Meterswitch(Input,0=IN/change);Bit#76543210LDIDDRC,0001111lb;bit4isoutput,othersareinputsLDIORC,0001111lb;non-interruptinputs,push-p^lloutputLDIDRC,00001111b;Setinternalpull-upsforbits5-7LDIDRCbuf,0000111lb;storesettingsinshadowRAMTSCRINITLDITSCR,00010i01b;resetTSCRandinhibitinteruptSET4,IOR;enableinteruptsRETICALLInitState;initializetoslow(2A)automode;ThenextthreelinesaretosetthemaximumidletestertimeCALLIniTimeJ;ioitidizetimerj(LDIMINsl,OAh;settimer1for10minutesSETIdle,Flags3;indicatesnobuttonspressedyet;ThenextthreelinessettheunitforTester(notCharger)modeRESChMode,Fiags2;setforTesterModeCALLShowData;initializedisplayINIT一Ol;JPMAIN;debug;*,TestRoutines*;*Thisroutinecheckstheswitchesatpoweruptodeterminewhetherto*;*enteroneofthetestmodes.Thepossibletestmodesandtheswitch*;*combinationsthattriggerthemareasfollows.*MeterRateTypeTestMode*YxNPowerOnSelfTest(POST):LED,slightinsequence*;*NYNManualSlowCharge(1hourmaxforallmanualmode)*;*NNYManualMediumCharge(Fastforboostmodels)*;*NYYManualFastCharge(Fast-Rapidforboostmodels)*;*YxYBurn-InMode:Fast/RapidChargefor60minutes*;*Y_>pressed,N->notpressed,x->either(notchecked)*JRSMeterSw,DRC,NoPOST;SkipaheadifMeterModebuttonnotpressedJRSTypeSw,DRCJPOST;SkiptoPOSTifTypebuttonnotpressedJPTes紐;…otiierwise,skipaheadtoBurn-InsetupNoPOSTJRRRateSw,DRC,TESTl;CheckTypeswitchifRateswitchispressedJRSTypeSw,DRC,NoTest;gotoMAINifnoswitchispressed;SetforManualFastChargeRESHiPwr,Flags2;turnoffhighpowermodeSETRate,Flags;turnonFastLEDSETNoRamp,Flags4;setforFastratew/orampuptoRapidSETNoOff,Flags2;setforfiilllowpower咖de(Fastrate).IFCEQSloRmp;assemblenextlineonlyifdebuggingSETHiJ^wr,Flags2;加rnonhighpowermodeRESNoOff,Flags2;activatePWM(<100%dutycycle).ENDCJPTestMMl;setforManualchargeNoTestJPMAIN;skiptestandgotoMAINTEST1;SetformanualSlowChargeJRRTypeSw,DRC,TEST2;ifTypeswitchispressed,setforFastTest鹏NoOff,Flags2;activateP丽(<100%dutycycle)LDIOFFSET,OffSlow;setOffsetfor2ARESRate,Fags;tumonSlowLEDJPTestMMl;setforManualchargeTes氾I;Setfor60minuteBurn-InSETBuriiI^Flags3;SetforBmn-InmodeTEST2;setforManualRapidChargeSETManual,Flags3;setforManualmodeSETRate,Flags;turnonFastLEDSETHiPwr,Flags2;turnonhighpowerRESNoOff-Fags2;activatePWM(variabledutycycle)RESNoRamp,Flags4;setforramping;JRSBumln,Flags3,TestRap;don'tsetforrampdownifBum-InRESRampUp,Flags3;setforr咖pdownLDIRmpCnt,RCinit;1003-secondintervalsyields2.5minutesLDIOFFSET,O欣ap;setOffsetforRapidChargeCALLSeiRamp;setrampingparametersTestRapJPTestMMlpetforManualchargePOSTCALLResetLEDs;tumo任alltype,rate&StatusLED'sCALLMeterOff;turno任allmetermodeLED'sCALLDigitsOff;turnoff3-digitLEDRESLoPwr,Flags2;makesureoutputwillbeoffCALLSetReg;setbatterytypeforRegularCALLHoldType;showTypeandwaitaFi他secondSETBatType义Flags;turnonDeepCyde&turnoffRegularLEDCALLHoldType;showTypeandwaitaFifthsecondSETBafTypeB,Flags;turnonGel/AGMLEDRESBatTypeA,Flags;turnonGel/AGMLEDCALLHoidType;showTypeandwaitaFifthsecondCALLResetLEDs;turnoffalltype,rate&StatusLED'sSETChMode,Flags2;mustsetflagtoshowrateLED'sRESCr喊Flags;turnoffCrankLEDRESRate,Flags;turnonSlowLEDLDILEDnum,SlowAmps;setdigitalLEDtoshowSlowrateCALLHoldRate;showRateandwaitaFifthsecondSETRate,Flags;turaonFastLEDLDILEDnum,FastAmps;setdigitalLEDtoshowFastrateCALLHoldRate;showRateandwaitaFifthsecondSETHiPwr,Hags2;turnonRapidLEDLDILEDnum,RapAmps;setdigitalLEDtoshowRapidrateCALLHoldRate;showRateandwaitaFifthsecondRESChMode,Flags2;ckarflagtodisableoutputLDILEDnum,CrakAmps;setdigitalLEDtos"wCrankrateCALLShowNum;getdatatoshowtheLEDnumberCALLShowCrank;turnonCrank(Boost)LEDCALLFi他Second;waitoneFifthsecondCALLResetLEDs;turnoffalltype,rate&StatusLED,sCALLShowData;updatedisplaySETMtrUnits,Flags;setfor°/。LEDsON,voltsLEDoffRESMtrScale,Flags;setforAlternator%LEDoffCALLHoldMtrMd;showmetermodeandwaitonefifthsecondRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoff;CALLHoldMtrMd;show迈etermodeandwaitonefifthsecond;SETMtrUnits,Flags;setfor%LEDsON,voltsLEDoff;SETMtrScale,Flags;setforAlternator%LEDONLDIDigiDatl,DigiRevl;setdigitalLEDtoshowCodeRevisionLDIDigiDat2,DigiRev2;setdigitalLEDtoshowCodeRevisionCALLShowData;updatedisplayCALLHoldMtrMd;showmetermodeandwaitonefifthsecondCALLMeterOff;turaoffallmetermodeLED'sCALLAlertON;turnonAlert(Red)LEDCALLFifthSe咖d;waitoneFifthsecondCALLShowChgng;iightChargingLEDCALLFi他Second;waitoneFifthsecondCALLResetLEDs;turaoffalltype,rate&StatusLED'sCALLShowGreen;lightGreenLEDonlyCALLFifthSecond;waitoneFifthsecondCALLResetLEDs;tumoffalltype,rate&StatusLED'sLDILEDnum,5;initializeto5toshow41stPOST2DECLEDnum;thenextnumberwillbe1lessCALLNumData;getdatafor,andshowLEDnumberCALLFifthSecond;waito加fifthsecondLDA-LEDnum;checkforlastnumberJRZPOST3;skipaheadifthereJPPOS丁2"..otherwise,loopback&repeatPOST3ADDIA^20;adding20changes2nddigitLDLEDnum,A;preparetoshownewnumberCALLNumData;getdatafor,andshowLEDnumberCALLFi他Second;waitonefifthsecondLDA,LEDnum;checklatestnumberCPIA,l00;comparetolastnumberJRZPOST4;skipaheliadifthereJPPOST3""otherwise,loopback&repeatPOST4CALLResetLEDs;turnoffalltype,rate&StatusLED'sCALLResetStatus;tumoffallthreestatusLEDsCALLInitState;resettoSlow,TypeAchargemodeRESChMode,Flags2;setforTestermodeJPTEST;r邻eatPOSTifnecessaryTestMMl;SetformanualchargeSETManual,Flags3;setforM咖almodeSETChMode,Flags2;setforChargerMode(outputenabled)RESDisable,DRBbuf;enableoutputLDICurentSS,15;State15isManualcharge.IFCEQSloRmp;assemblenextlineonlyifdebuggingJRSBurnln,Fiags3,TstBILDIOFFSET,HiOff;setOffsetforminimumchargerate;LDIOFFSET,150;setOffsetforminimumchargerate**TEMP**LDITries,SRIM;initializerampintervalmultiplierLDICurentSS,6;State6slowlyrampschargerateLDIRmpCnt,240;,.,andre陽initializeinitervalcounter(2sec)TstBI.ENDCSETStarted,Flags;setFlagsforchargestartedSETLoPwr,Flags2;tellPwrConchargerisonCALLIniTimel;initia〗izeTimerlLDIHRsl,l;setTimerlfor1hour.IFCEQFastBI;assemblenextlineonlyifnotdebuggingLDIMINsl,7;setTimerlfor0hrs,7minsJENDC.IFCEQSloRmp;assemblenextlineonlyifdebuggingJRSBuraln,Flags3,TestMM2LDISECsl,15;setTimerlfor15seconds.ENDCIRRBumln,Flags3,MAIN;skipnext2linesifnotBum-inTestMM2;LDIHRsl,4;setTimerlfor4hours;LDIMINsl,19;setTimerlfor3hrs,19rainsCALLIniTime2;resetTimer2LDIMINs2,1;settimerforcounterinterval(1minute).IFCEQFastBI;assembienextlineonlyifdebuggingLDICCDcnt,7;setBurn-inminutecounterto7.ELSELDICCDcnt,60;setBurn-inminutecounterto60.ENDCBecausetheA/Dvoltageisbeingaveraged,itwouldtakeconsiderable*timetonoticethatabatteryhasbecomedisconnected.Toovercomethis*DELAYtheprogramwillmonitortheinstantaneousvoltageeachtimethru*thelooptodetectthiscondition.Thischeckwillbemadeonlyifthe**unitisinachargingmode.MAINCALLRstWDR;resetwatchdogtimerLDA,CurentSS;getcurrentstateSUBIA,ABORT;checkforabortJRNZMainMore;c。ntinueMainifnotAbortJPMAIN3;don'tcontinueMainifAbortMainMoreJRRManual,Flags3,MainAuto;continueMainifnotManualMode.IFCEQSloRmp;assemblenextlineonlyifdebuggingJRSBuraln,Flags3,MainBIJPSS6;skrwlyra迈pchargerateMainBI,EKDCJPSSI5;otherwise,gotoManualchargeMainAutoJRSCrankWait,Flags,MAINl;don'tcheckswitchesduringCrankwaitCALLCheckSw;checkifswitchisbeingpressedM扁4JRSCrankJFlags,MAINO;skipaheadifduringCrankCALL(etPercent;updatethepercentagereadingCALLUpdateBP;update0/otodisplayCALLGetMeter;updatedisplayJRRIdle,Flags3,MAIN0;skipaheadif加tidleJRRBatt,Flags2,MAIN0;don'tcheckidletimelimitifnobatteryJRSIdleSet,Flags4,MAIN5;dcm'tsetidletimerifalreadysetCALLIniTimel;.,.otherwiseinitializetimer1LDIMINs1,OAh;settimer1for10minutesSETIdleSet,Flags4;Idletimerstarted,setflagM細5JRRMIN,TicFlagl)MAINO"..otherwise,checkidletimelimitRESDisable,DRBbufenableoutputaifteridletimelimitJPMAIN2;...andre-initializeifreachedMAINO;notCra昧checkfor0or1JRSLoPwr,Flags2,MAINl;chargerisON,goto0VcheckJRRLEDchgng,DRAbuf,MAINl;chargerisalmoston'gotoOVcheckJPMAIN3;chargerisOFF,gotoMain3MAINI;Checfcfordisconnectedbattery;CALLGetPercent;updatethepercentagereadingCALLCheckBatt;chsckfordisconnectedbatteryIRSBatyFlags2,MAIN3;skipaheadifconnectedMAIN2;OVdetected,preparetostartoverfromstate0LDIDspPcnt^;initiaiizedisplayPercentto0CALLioitState;initializetoSlowRegularChargemodeMAIN3*SEQUENCESTATEJUMPTABLE**Determinewhatroutinetoexecuteonthispassthroughthetheloop.Only**oneroutineisexecutedeachtimethroughtheloop.*NSSOLDA,CurentSS厕ZNSSlJPSSO;*SSO-BATTERYDETECT*NSS1CPIA,001hIRNZNSS2JPSSI;*SSI-BATTERYDETECTDELAY*NSS2CPIA,002h腿ZNSS3JPSS2;*SS2-AUTOMATICCHARGESTART*NSS3CPIA,003hJKNZNSS4JPSS3;*SS3-BELOW9Volts*NSS4CPIA,004hJKNZNSS5JPSS4;*SS4-BELOW12Volts*NSS5CPIA,005hJKNZNSS6JPSS5;*SS5-NORMALCHARGE*NSS6CPIA,006hJRNZNSS8JPSS6;*SS6-RAMPCHARGERATE**DEBUG*;NSS7;CPIA,007h;JRNZNSS8;JPSS7;*SS7-CHARGECOMPLETE*NOTUSEDNSS8CPIA,0081iJRNZNSS9JPSS8;*SS8-ABORTCHARGE*NSS9CPIA,OO处JRNZNSSllJPSS9;*SS9-DESULFATION*;NSSIO;CPIA,OOAh;JRNZNSSll;JPSSIO;*SSIO-RESTORECHARGE*NSS11CPIA,OOBhJRNZNSS12JPSSll;*SSll-dV/dtMONITOR*NSS12CPIA,OOCh厕ZNSS13JPSS12;*SS12-dl/dtMONITOR*NSS13CPIA,OODhJRNZNSS14JPSS13SS13-ENDCHARGE*NSS14CPIA'OOEhJKNZNSS;i5JPSS14;*SS14-MAINTAIN*NSS15CPIA,OOFh厕ZNSS16JPSS15;*SS15-Manual*NSS16CPIA,010h丽ZNSS17JPSS16;*SS16-CRANK*NSS17CPIA,OllhJKNZNSS18IPSS17;*SS17-CRANK*NSS18CPIA,012hJKNZNSS19JPSS18;*SS18-CRANK*NSS19CPI入013hJKNZNSS20JPSS19;*SS19-CRANK*NSS20CPIA,014hJRNZNSS21JPSS20SS20-CRANK*NSS2LDIWDR,001h;inva〗idsequencestate,reset*ENDOFMAIN**WaitforNMI,whichindicatesendofFFTonperiod,beforemeasuring*batteryvoltage.*ExitMainXMainWAIT;waitforinteruptJKSNMInt,Flags2,XMain;ti證intempt*READBATTERYVOLTAGE**Thisroutineisexecutedatornearzerocross.Thecurrentvoltage**isstoredinCurVoltandthereadingisaddedtoBADhi(twolocations).*BADhiwillcontainarunningaverageofthelast256readings.*BADREADLDA,BADlo;getaveragereadingSUBA,BADhi;subtractonereadingfromtherunningtotalIRNCBADREAD1;nocany,goonDECBADhi;adjusthighorderbitsBADRE細LI>BADlo,A;storenewvalueLDIADCR,0B0h;startA/DconversionLDIADCR,0BOh;doagaintoinsureavalidstartWAIT;iettheinteruptnotifyuswhendataisreadyLDCurVolt,A;savecurrentreadingADDA,BADlo;addintorunningaverageJRNCBADREAD2;nocarry,goonINCBADhi;incrementhighbitsBADREAD2LDBADlo,A;storenewlowbits;LDIORB,OlFh;LDIORB,09Fh繊AVERAGECALCULATION*Forusebythedi/dt^aboutfourtimeseverysecondtheaverageofthe*previous32curvoltreadingsisstoredinFreshBVforcomparisontoa1,*readingtakenoneseverysecond.'DIDTAVGLDA,Temp2;ifTemp2=0thenfirstreadingJRNZDIDTAVG1;skipinitifnot1streadingLDITemp2,020h;initializeTemp2to32DIDTAVG1LDA,FBVTotLo;ADDA,CurVolt;addcurrentvoltagetototal厕CDIDTAVG2;don'tinchighbytsifnocanyINCFBVTotHi;inchighbyteDIDTAVG2IDFBVTotLo,A;updatetotalDECTemp2拜dateTemp2JRZDIDTAVG3;comp加eavgJPDIDTAVGX;ex化toMainDIDTAVG3LDITexnp2,003h;preparetoshift3timesDIDTAVG(SLDA,FBVTotHi;loadhighbyteoftotalintoaccumulatorSLAA;shiftaccumulatorleftLDFBVTo祖A;updatehighbyteoftotalLDA,FBVTotLo;loadlowbyteoftotalintoaccumulatorSLAA;shiftaccumulatorLDFBVTo仏o,A;updatelowbyteoftotal腿CDID丁AVG4;msbwaszero,skipnextlineINCFBVTotHi;DIDTAVG4DECTemp2;decloopcounterJRZDIDTAVG5;ifzero,finishaverageJPDIDTAVG6;notzero,shiftagainDIDTAVG5LDA,FBVTotffi;storeaverageinFreshBVLDFreshBV,ACLRFBVTotHiCLRFBVTotLoDIDTAVGXJPMAIN*Thisiswherethesequencestatesaredefined.Thenumberoi"agiven*sequencestatehasnorelevancetotheorderinwhichitisactually一*executed.Anygivenstatecangivecontroltoanyotherstate.*BATTERYDETECT*Thisisthechargeridlestate.Theprogramremainshereuntilabattery'*isdetected.Dectectionisdeterminedbyfindingapositivevoltage**gnsaterthanonevolt.SSO.IFCDEBUG;ass加blenextlineonlyifdebuggingRESSwOff,SwDown;settocheckTypeandRateswitches.ENDC;LDIPercent,O;setPercentto0CALLShutOff;low&highpower,fan,&crankoff;mindutyCALLShowB^ate;turnonciargerateLED(SloworFast)CALLShowType;tononbatterytypeLED(Reg,D/CorGel)RESSOC,Flags4;clearStartOfChargeflagJRSChMode,Flags2,Ready;continueroutineifinChargerModeCALLCheckBatt;…otherwise,checkiftestershouldshowO'sJPSS0EX1T;".andexitHeadyJRRStarted,Flags,SSOO;skipifoutputhasn'tbeenonRESStarted,Flags;setFlagsforchargenotstartedSS00LDA,FreshBV,'checklatestaveragevoltageJRNZSS0一1,'Isit0(exactly)CALLShowRed;turnonRedLEDuntilbatteryisdetectedJPSSOEXTT;".Yes:mustberev,bat"sostopSSO一lCALLIniTimel;setuptimerLDISECsl,002h;adjustfor2secondsLDITries,005h;5TriesfordebounceSETO,CurentSS;goontoBATTERYDETECTDELAYSS0EX1TJPExilMain*BATTERYDETECTDELAY**Thisstatechecksthatavoltageispresentforthreeseconds.Ifthe**voltagedropsbelow1Vdc,tLetimerisrestartedandthe"try"counter#*isdecremented.Ifafter5Triesthevoltagehasnotbeenabove1Vdc**for3seconds,gobacktobatterydetect.Thisddayhastheeffectof**debouncingtheleadsbeingconnectedtothebattery.SSICALLCheckBatt;checlcforconnectedbatteryJRSBatt,Flags2,SS1—I;yes,ciieckifithasbeentwosecondsJPSS1一2;no,subfr;atrySSl」—CALLShowChgng;tumChargingLEDonJRH2,TicFlagl,SSlEXTT;gocmiftimeisup,o也erwiseexitLDIOWVolt,000h;clearOldVoltbeforeenteringSS2LDITEMPl,000h;clearTempibeforeenteringSS2INCCurentSS;goontostartchargeJPSS1—3;settimerfor2secondsSSI—2,NOTE:Triessetto5inSSODE^Tries;subtractatryJKNZSS1—3;tryagainifnottoomanyTriesDECCurentSS;…otberwise,gobacktoidle(state0)JPSS1EXIT;...andexitroutineSSI—3CAIlIniTimel;resettimerandtryagainLDISBCsl,002h;adjustfor2secondsSSIEXITJPEx編ain;*AUTOMATICCHARGESTART*;*Thisstategetsthebatteryvoltageanddecideshowtocontinuethe;*thecharge.Theinaximuma"owedchargetimeisalsostarted.*^S2;NOTES:OldVoltSETTO0INSSI;TEMPISETTO0ATRESETFASTAVGDECTEMPI;decreaseTempionecount(startsat0);havewecounteddownto0JRZFASTDONE;yes,jumptoFASTDONELDAjTJEMP;nojoadpreviousTEMP油eADDA,CurVolt;addCURVOLT,DidweoverflowthecounterJKNCOVER;no,jumptoOVERINCOldVolt;yes,bumpuptherunningaverageOVERLDTEMP,A;storethelatestvalueinTEMPJPSS2EXIT;exitandgoupdateCurVoltFASTDONELDA)TEMP;loadpreviousTEMPvalueADDA,CurVolt;DidweoverflowthecounteronelasttimeJRNCOVER2;no,jumptoOVER2INCOldVolt;yes,b咖puptherunningaverageonelasttimeOVER2CALLCheckBatt;ChecktoseeifbatterywasremovedduringFastAvgJRSBat"Flags2,SS2一0c;Stillconnected-continueLDICurentSS,O;notconnected-gobacktostate0JPSS2EXIT;...andexitState2SS2—0cLD入OldVolt;getOldVolt(initialbatteryvoltage)LDBADhi3A^initializeBADhitoO)dVoJt;LDA,Percent;getupdated%LDA,DspPcmt;comparetolast^displayedIRNZSS2—GP;if%previouslyshowi^skipaheadCALL(3etPercent;updatePercentforinitialvoltageLDA,Percent;getlatest%LDDspPcnt^A;storelatest0/oinDisplayPercentRESWaitOP,FIags2;setflagtoindicatenotwaitingJPSS2一BP;skipaheadCPIAJ00;dieckforl00o/oJRNZSS2—BP;continueState2ifnotl00%JPSS5—Maint"..otherwise,gotoMaintainSS2—BfCALLShowChgng;turnChargingLEDonCALLIniTimel''initializetimer1LDIMINsl,l;settimer1for1minuteLDISECsl,005h;settimer1for5secondsLDICCDcnt,MaxHrs;setintervalcountertoMaxHrsSETSOC,Flags4;setStartOfChargeflagCALLIniTime2;initializetimer2LDISECs2,0011i;settimerfor1secondLDIMSECs2,MS500;settimerfor500milliseconds(0.5secs)LDIMINs2'006h;settimerfor5minutesand2secondsLDIHRs2,005h;settimerfor4hcmrs,5minutes&2secondsRESHiPwr,Flags2;turnoffhighpowermodeJRSRate,Flags,SS2—0;skipaheadifsetfor10A"..otherwise,setfor2AchargeRESNoOff,Fkgs2;activatePWM(<100%dutycycle)LDIOFFSETjO舰ow;setOffsetfor2AJPSS2一0a;skipaheadandreadvoltageSS2J)lsetfor!0AchargeSETNoOff,Flags2;de-activatePWM(100%dutycycle)LDIOFFSET,HiOff;setOffsetforminimunidu一cycleCALLSetRmpUp;pr邻aretorampfromFasttoRapidSS2—0aLDA,BADhi;getlatestavgbattvoltageCPIA,Volts09;verylowbatteryJRNCSS2—2;加,frynextlimitSS2一1;B^tery<9VU)i"A,003h;yes,service4below9VOLTSSJPSS2一5SS2_2;Battery>9VCPfA,Volts12;lowbatterystateJKNCSS2—4;no,gotoSS5SS2一3;9"\T<Battery<12VLDfA,004h;yes,serviceit,below12VOLTSSJPSS2—5SS2一4;Battery>12VLDfA,005h;normalchargeSSSS2一5LDCurentSS,A;preparetogotothecorrectstate(3,4or5)SETStarted,Flags;setFlagsforchargestartedCALLTurnON;tomoulput,F叫an^ChargbgLEDonSETSettle,FIags3;initialchargevoltagesettlemodeSS2EXITJPExitMain*BELOW9Volts**Batteryisextremelydischargedandmaybebad.Chargeforamaximum'*offiveminutes.Ifvoltagedoesnotcomeabove9Voltsinthistime**period,abortcharge.Otherwise,gotobelow12Volts.*SS3CALLChkRapid;updateRamptimer,ifnecessaryJRSSEC,TicFlag2,SS3—0;contimieifvoltagesettletimeexpiredJPSS3EXTT;…otiier^se,justexitSS3一0RE;Settle,Flags3;clearsettleflagJRRMIN/ncFlag2,SS3—I;clieckiftimehasexpiredLDICurentSS,ABORT7yes,timetoabortJPSS3EXTTSS3一1;not5minsyetCALLBattProg;checkbatteryvoltageforchargeprogressCPI入Volts09;isbatteryupto9VJRCSS3EXIT;contimiestate3if<9VINCCurentSS"..otherwise,gotostate4SS3EXITJPExitMain*BELOW12Volts**Batteryisverylow.Allowamaximumof4hoursforthevoltageto*riseabove12voltsundercharge.Ifvoltagedoesnotcomeup,goto*abortcharge.Otherwisegotonormalcharge.承SS4CALLTumON;turnoutpu"Fan,andChargingLEDonCALLChkRapid;updateRamptimer,ifnecessaryJRSSEC,TicFlag2,SS4—0;continueifvoltagesettletimeexpiredJPSS4EXIT"..otherwise,justexitSS4—0RE^Settle,Flags3;clearsettleflagJRRHR,TicFlag2,SS4一i;checkiftime(4hours)hasexpiredLDICurentSS,ABORf";yes,timetoabortJPSS4EXIT;exitroutineSS4—1CALLBattProg;checkbatteryvoltageforchargeprogressCPIA,Volts12;isbatteryupto12VJRCSS4EXIT;…ifnotJustexitINCCurentSS""otherwise,gotostate5SS4EXITJPExi她in;*NORMALCHARGE*;*Programstayshereuntilthevoltagereaches14.2voltsorthemaximum;*chargetimeisexceded.Ifthevoltagelimitisreachedtheprogram*;*willtransferto:*A.SSB(dV/dt)ifthethebatteryhasbeenchargingmorethan5*,minutesor*;*B.SS9(Desulfation)iftheOCVwaslessthan12.2voltsor*;*C.SS14(Maintain)iftheOCVwasmorethan12>2volts*,*;*Ifthemaximumchargetimeisexcededtheprogramwillabort*,**『S5CALLTuraON;turno鄉ut,Fan,andChargingLEDonCALLChkRapid;updateRamptimer,ifnecessary.IFCDEBUG;assemblenextlineonlyifdebuggingSETSwOff,SwDown;settoignoreTypeandRateswitches.ENDCJRSSEC,TicFlag2,SS5一0;continueifvoltagesettletimeexpiredJPSS5EXIT"..otherwise,justexitSS5—0RE^Settle,Flags3;dearflagCALLBattProg;checkbatteryvoltageforchargeprogressJRRHR,TicF〗agl,SS5一0a;skipnextUneifmaxtimenotexpired;NOTE:CurentSSsettoABORTbyBattProg.ChkProgJPSS5EXIT;exit(andabort)ifmaxtimeexpiredSS5一0aCPI—A,Volts142;checkifupto14.2voltsyetJENCSS5—2;yes,checkif>5minutesJPSS5EXft;otherwise,justreturnSS5一2LDr孤sl,CCDcnt;setTimerlhours(minutessetbyBattPRog)RESHiPwr,Flags2;setforlowpowermodeRESRmpng,Flags3;clearflagbeforemovingonRESRmpInt,Flags3;clearflagbeforemovingonRESSettle,Flags3;ciearflagbeforemovingonJRSMIN,TicFlag2,SS5一3;if>5min,gotodV/dtLDA,OldVolt;otherwise,checkinitialvoltageCPIA,Volts122;initialvoltage<12.2VJRCSS5一5;Yes:thendesulfateJPSS5—Maint;No:gotoMaintainSS5一5U)FcurentSS,009h;batteryissulfatedLDIMaintVolt,Volts16;trytoholdbatteryat16VLDIVref,Volts15;andseeifitdropsto15VCALLIniTime2;LDIHRs2,002h;inlessthan2hoursJPSS5EXIT;SS5—3JRRRate,Flags,SS5—6;checkforFastchargerateLDIOFFSET,MinOf;minFastoffsetvalue(maxcurrent)SS5—6LD"XOFFSET;getOFFSETJLDOdOff,A;storeOFFSETint。OWOifLDICurentSS,00Bh;gotowaitfordv/dttripvoltageLDIPercent,77;setPercentto77CALLIniTime2LDIMINs2,0Dh;setto13minutesfordV/dtLDA,BADhi;getlatestbatteryvoltageLDMaintVolt,A;storeasmaintainvoltagefordi/dtLDITries,004Ii;initializedV/dtfor4Tries(3intervals)JPSS5BXIT;SS5—Maint;gotoMAINTAIN,batteryisalreadychargedLDIPercent,100;setPercentto100LDIMaintVolt,Volts132;setmaintainvoltageto13.2VJRRBatTypeB,Flags,SS5一7;skipaheadifnotGel/AGMLDIMaintVoit,Volte135maintainvoltageto13.5VforGel&AGMSS5—7LDfCurentSS,00Eh;Maintainisstate14(0Ehex)RJESNoOff,Flags2;activatePWM(<100%dutycycle)CALLShutOff;low&highpower,f叫&crankoff;mindutyDECOFFSET;MAXoffeet-1value->mindutycycleSS5EXITJPExitMain*SS6-RAMPCHARGERATE**承*SlowlydecreaseOFFSETfromHiOffdowntoO放aporMinOfftoin-*creaseoutputcurrentfordebugging.Resetwhendone.*SS6.IFCJEQSloRnip;assembleSS6routineonlyifdebuggingCALLShowRate;turnonthe2Aor15ALEDCALLGetMeter;updatedisplayCALLTurnON;turnoutput,Fan,andChargingLEDonJRSSEC,TicFlagl,SS6一0;waitaibwsecondsbeforerampingJPSS6_x;".otherwise,justexitSS6—0""LD;,OFFSET;otherwise,getlatestoffeetJRRiiate,Flags,SS6一2;skipifnotsetforrapidCPIA,OffRap;has一OFFSETbeendecreasedtoOffRapIRZSS6一3;…ifso,donerampingJPSS6一4""otherwise,keeprampingSS6—2一CPIA,MinOff;JKNZSS6_4;continueifnotdonerampingSS6—3JPSS6—1;finishifdonerampingSS6—4DECRrnpCut;decrementintervalcounterJRZSS6一8;updatedisplayifintervalhaselapsedJPSS6—x;.,.otherwise,justexitSS6—8IRSMtrScale,Flags,SS6_6;skipaheadifalreadyshowingOFFSETSETMtrUnits,Flags;serforVoltsLEDoff,batt%LEDonSETMtrScale,Hags;setforAlt%LEDon,batt%LEDoffJPSS6—7SS6—6RE§"MtrScale,Flags;setforAlternator%LEDoffRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffSS6一7DECTries;decrementintervalmultilierJKNZSS6一5;sMpaheadifnotzeroDECOFFSET"..otherwise,increaseOFFSET(reducecurrent)LDITries,SRIM;...andre-initializeintervalmultiplierSS6—5LDIRmpCnt,240;...andreinitializeintervalccmnter(2sec)SS6一xJPExilMain;waitfornextNMISS6一1IPRESET;alldone,resettopowerupstate.ENDCSS7;*SS8-ABORTCHARGE**承;*TurnoffallLED's.BlinkTROUBLELEDathalfsecondinterval.If;*batterybecomesdisconnected,re-initialize.**^S8JRSAlert,Flags2,SS8一0;skipaheadifflagalreadysetCALLResetLBDs;iiirnoffalltype,rate&StatusLED'sCALLIniTime2^initializeTimer2foroutputdischargeLDISECs2,005h;settimerfor5secondsSS8一0SE"FAlert,Flags2;setAlertflagRESCrankJFlags;clearCrankFlagCALLShutOff;low&highpower,f叫&crankoff;mindutyCALLBlinkAIert;blinkAlertLEDCALLMeterOff;TurnoffMeterModeLEDsJRRSEC,TicFlag2,SS8一2;waitforTimer2beforecheckingbatteryJRSBurnln,Fkgs3,SS8二2;don'tcheckforbatteryifBum-InJRSSOC,Flags4,SS8一2一;don'tcheckforbatteryifStartOfChargeCAIXChecliatt;checkforconnectedbatteryJRRBatt,Flags2,SS8—1;ifdisconnected,endabortroutineSS8—2—JP§"S8EXIT;otherwise,justexitSS8一1RE;Alert,Hags2;resetAlertflagJPMAIN2;re-initializeSS8EXITJPExitMain;*SS9-DESULFATION*DesulfationModeisenterediftheinitialbatteryvoltageisless*than12.2voltsandthevoltagereaches140voitswithinfive*;*minutes.*;*承;*Thechargertriestoholdthevoltageat16.0volts,Asthebattery*startstoconduct,thevoltagewillfall.Ifthevoltagereaches14.0*;*inareasonabletimelimit(10hours),wewilltransitiontothe*;*normalchargingsequence(SS5).LFthevoltagedoesn'tfallto14.0;*voltswewilltransitiontotheABORTsequencestate(SS8).*^S9LDIPercent,15;setto150/oCALLBLakChrg;blinkChargingLEDCALLCheckBatt;checkforconnectedbatteryJRSBatt,Flags2,SS9—0;continueroutineifconnectedIPMAIN2;,"otherwise,re-initializeSS9—0CAlLVoltRegJRRSEC,TicFlag2,SS9X;wait1minuteJRRHR^TicFlag2,SS9—1;maximumtimeout(1or2hours)DECCurentSS;AB(JrTstateJPSS9X;doneSS9一1LDA^BADhi;getlatestaveragebatteryvoltageCPA,Vref;arewethereJRCSS9一2;yes:reduceVrefJPSS9X;no:waitanotherminuteSS9_2DE^:Vref;1countis0.0667voltsDECVref;reduceVrefby0.133voltsLDA,Vref;seeifbattisdesulfatedyetCPIA,Volts14;isVref<14.0VoltsIRCSS9一4;…ifso,gotonormalchargeJPSS9一3"..otherwise,tryanotherhourSS9_4LDICurentSS,005h;preparetogotonormalchargeCALLShowChgng;tumChargingLEDon(stopblinking)LDA,Vmax;setMaintVolttoVmaxLDMaintVolt,A;maintainvoltageforstate5SETLoPwr)Flags2;tdlPwrConchargeriscmCALLIniTime2;initializetimer2LDISECs2,002h;settimerfor2seconds(voltagesettletime)JPSS9X;SS9—3CALLIniTime2;resettimerLDIHRs2,001h;setmaxtimefor1hourSS9XJPExitMainSS10,細tMONITOR*:*Thisstateislookingforoneofthreeconditions:*:*1.Maximumtimeisexceded-setforcheckbatteryandturnoffcharger.;*2."NochangeindV/dtfor45minutes-batteryisabout80%charged.**3,MAXvoltageisreached-GOTOdl/dt,*SS11CALLSetON;turncoolingfan&outputon;RESRmpng-Flags3;clearflagbeforemovingonRESSettie,Flags3;clearflagbeforemovingonJRRHRJlcFlagl'SSll一l;Ifnotmaxtimeout,gotoSS11—1LDfCurentSS,ABOHT;otherwise,gotoabortJPSS11XSSll」CAlXShowChgng;〗ightChargingLEDCALLGetBatt;getbatteryvoltageadjustedfordropCPA,Vnaax;isbattvoltage<MAXvoltageJRCSSI1一2;yes:continueloopSETRmp5it,Flags3;no:settoboostduringD/CEndChargeJPSSI1—6;...andpreparetoGOTOdl/dtSS11一2—JRRMIN,TicFlag2'SSlIX;exitifnottimefordv/dttestLDA,PerceDt;getPercentCPI入84;isPercent<85JRNCSSU—3;…ifnot,skipaheadINCPercent"..otherwise,increasePercentSSI1—3LDA,BADhi;getbatteryvoltageSUBIA,2;maximumallowedpositivechangeis2CPA,MaintVolt;testfor卿eriimitchangeJRCSS11—4;lessthan1countup,testdownchangeJPSSI1—7;otherwise,skipaheai&updateMaintVoltSSI1—4—IFCEQSixoReg;assemblenextlineonlyifdebuggingCALLShowGreen;tumonGreenLED.ENDCDECTries;decrementcounterJRZSS11—6;alldone,GOTOdl/dtLDA,Percent;getPercentCPIA,87;isPercent<88IRNCSSI1—5;.,.ifnot,skipaheadINCPercent;".otherwise,increasePercentSSll—5JPS^ll—8;no,reloadtimerSSll—6一INC—CurentSS;GOTOdl/dtnextRESNoOff,Flags2;setfor<100%dutycycle乙DIPercent,8S;setPercentto88-NOTEmustalwaysbeevenJRSRmpInt,Flags3,MntMx;skipaheadifVmaxreachedCALLGetBatt;getbatteryvoltageadjustedfordropLDMaitxtVolt,A;saveBADhiasmaintainvoltageJPSSI1—9^initializeTriesandTimer2fordi/dtMntMxLDA,Vmax;otherwise,setMaintVolttoVmaxLDMaintVolt,A;MaintVoltusedfordi/dtJPSSI1—9;initializeTriesandTimer2fordi/dtSSU—7—;updateMaintVolt,IFCEQShoReg;assemblenextlineonlyifdebuggingCALLShowRed;tumonRedLED.EKDCLDA,BADhi;getcurrentbatteryvoltageLDMaintVolt,A;updateMaintVoltfordV/dt&di/dtSSI1—9LDITries,004h;resetcounter(4matches=3intervals)SS"—8CALLIniTime2^initializetimerLDIMINs2,008ti;...for8minutesSS11XJPExitMain磁MONITOR**Indi/dttheon/offrelayisopenedandclosedtoholdthevoltage**closetothedV/dtvalue.Theintervalbetweeuopejoing幼dclosingthe**relaywillincrease.Thisstateislookingforoneoftwoconditions:**1.Maximumtimeisexceded-setforcheckbatteryandturnoffcharger.**2,Nochangeinon/offrelayfor30minutes-currentstabilizedata**lowvalue'Batteryisabout97%charged.<3otoSSI3(EndCharge)for*承1hour.*SS12CAULSetON;tumcoolingfan&outputonCALLVoltReg;regulatebatteryvoltageatMaintVoltLDA,DspPcnt;getlast%displayedCPI尺100;has%displayedreached100JRZSS12—14;…ifso,turnongreenLEDCALLShowYellowotherwise,turnonyellowLEDJPSS12—15;…andskipahead(leavegreeno均SS12—14—CALLShowDone;turnonchargecompleteLEDSS12J5JKRliR'TicFlagl,SS12一l;maximumtimeoutJRSAlert,FIags2,SS12:0;ff2ndmaxtimeout,gotoSS12—0SETAlerglags2;Iffitmaxtime,setAlertflag;犯dneseftimer;toaltrw4morehoursCALLIniTime2LDIHRsl,004hSSI2—10LDX,MaintVoKSUBIA,007h;LDMaintVolt,AJPSS12EXTT;thenrestartdi/dtSS12一0LDI^urentSS,ABORT;gotoabortRESAlert,Flags2;resetAlertflagforAborttimerJPSS12EXIT;andgetMaintainvoltagethensubtract~0.5V;andupdateMaintainvoltageSS121JRR^IN,TicFkg2,SS12EXIT;timefordl/dttest.IFCEQShoReg;assemblenextlineonlyifdebuggingCALLShowAIt;tumonalternator%LED.ENDCLDA,Percent;getPercentCPIA,IOO;isPercent<100JRNCSS12—2;…if加t,skipaheadINCPercent;",otherwise,increasePercentLDA,Percent;getpercentCPIA,100;Ispercent=100JRZSS12—2;YES,don'tincreaseanymoreINCPercent;No,increaseby2SS12一2LD;,OFFSET;getcurrentOFFSET;INCACP工A,HiOff-;hasOFFSETreachedmaximumJRNCSS12J3;ifso,finishdi/dtDBCA;ensurecanyifequal;DECA;allcwdifferenceof1CP人OidOff;testforlowerlimitchangeJRCSS12一4;o泡etwithin1,finishdi/dtJPSS12jT;offe改toohigh,tryagainSS12—13JPS^"l2一6SS12一4—DECTries;decreraentcounterJRNZSS12一5;AreweckmeJPSS12一6;yes,alldone,cleanupandexitSSI2一5;加,continueLDA,Percent;getPercentCPI义99;isPercent<100JRNCSS12—3;...ifno仁skipaheadINCPercent"..otherwise,increasePercentJPSS〗2—8;reloadtimer<&checkagainlaterSS12—3—LDAeries;getthecurrenttriesCPIA,03;Istrieslessthan3JRNCSS12—11;No,justexitLDIPercenUOO;Yes,show100%anddoneSS12—11JPSSI2—8;rdoadtimer&checkagain2aterSS12—6~INC—CurentSS;GOTOEndCharge(SS13);CALLShowChgng;tumChargingLEDon;LDIPercent,95;setPercentto95CALLIniTime2;initializeTimer2LDIHRs2,001h;chargefor1morehour(EndCharge)LDIMINs2》0Fl1;cliargeforonly15minutes(EndCharge)CALLIniTime1;initializeTimer1LDIHRsl,OOlh;Settochangepercentevery.,'LDIMINsl,003h;ThreeminutesJRRBatTypeA,Flags,SS12—9;skipifnotDeepCycle(Voyager)JKRRmpInt,Flags3,SS12—f;skipifnotusinghigherEndChargevoltageINC孤s2;otherwise,change孤S2from1to2LDIMINsl,00Fii;Settochangepercentevery15minutesLDA,MaintVolt;also,storeMainVoltinAADDIA04h;increaseAby4counts~0.267VLDMaintVolt,A;storeupdatedvalueinMainVoltSS12—9JPS§12EXITSS12一7LDS,OFFSET;setnewbaseo泡etLDOldOff,A;saveiBOldOffLDITries,004h;resetcounter(4matches=3intervals)SS12一8CALLIniTime2;initializeTimer2LDIMINs2,008h;setTimer2foi"8minutesLDA,OFFSET;GetcurrentoffsetCPIA,MinOff;Istheoffset-MinOff腿ZSS12EXIT;NO,justexitRESRmpInt,Flags3;YES,don'tboostvoltageforEndChargeJPSS12—10;Currentnotfalling,reducevoltageby1/2VSS12ExfiJPExi她inENDCHARGE**Chargefordesiredhoursafterdl/dtatdV/dtvoltage.SS13LDIPercent100;settoS>5%LDA,DspPcnt;getlast0/。displayedCPIA,IOO;has%displayedreached100JENZSS13—2;…ifso,turnongreenLEDCALLShowDone;tornonchargecompleteLEDSS13一2CALLSetON;tumcoolingfan&outputonCALLVoltReg;regulatebatteryvoltageatMaintVoltCALLChkHiOff;cliecfcformaxOFFSET(PWMfUllofi)JRNZSS13—3;...ifnot,continueEndChargeJPSS5一Mairrt"..otherwise,gotoMaintainSS13—3—JRRliR,TicFlagl,SS13—1;Ifnottimetochangepercent,gotoSS13—I;INCPercent;increasethepercentageby1CALLIniTimel;resetTi迈erlLDIHRsl,001h;Settochangepercent...LDIMINsl,003h;...everythreeminutesJRRBatTypeA,Flags,SS13_l;skipnextlineifnotDeepCycle(Voyager)LDIMINs1,00Fh;Settochangepercentevery15minutesSS13—1JRRln,TicFlag2,SS13EXIT;exitifEndChargetimenot邻JPSS5一Maint;otherwise,GOTOMAINTAINSS13E55TJPExi她in*MAINTAIN**Batteryhasreachedfoilcharge.Stayhereandmaintainbattery**at13,2voltsuntilbatteryisdisconnected.承*SS14LDIPercent^00;settol00o/oCALLSetLow;setforlowpowermodeSETLoPwr,Flags2;tumou^mtonCALLVoltReg;reguiatebatteryvoltageatMaintVoltLDA,DspPcnt;getlast%displayedCPIA,100;has%displayedreached100JRZSS14—1;…ifso,turnongreenLEDCALLShowYellow".'otherwise,turnonyellowLEDJPSS142;",andskipahead(leavegreenoff)SS14—1—CALLShowDone;turnonchargecompleteLED.IFCEQDEBUG;assemblenextlineonlyifdebuggingRESSwbff,SwDown;settocheckTypeandRateswitches,ENDCSS14一2CAliChkHiOff;checkformaxOFFSET(PWM&11o坊JRZSS14一3;…ifso,shutofffanCPI入HiOff隱4;checkforsustainedoutputJENCSS14—4;…ifnot,leavefanoffCALLFanON"..otherwise,turnfanonJPSS14—4;…andskipaheadSS14一3CAIXFanOff;turacoolingfanoffSS14—4CALLCheckBatt;checkforbatteryJRSBatt,Flags2,SS14EXIT;.,.connected:continueJPMAEST2;".disconnected:startoverfromstate0SS14EXITJPExi她in*SSI5MANUAL**Setoffeetforselectedrate.Novoltagelimit/batterycheck.SS15IRSLoPw,Flags2,SS15一0;poweroffindicatescompletedBum-InJPSS15—2;skiptoendifrslayisopenSS15一0一CAliShowRate;turnonthe2Aor15ALED;NOTE:outputalreadybut丁urnONsavescodespaceCALLTurriON;turno鄉ut,Fan,andChargingLEDonCALLChecld7v;checkfordisconnectedbatteryJRNZSS150K;if17V,thencontinueLDICurentSS,ABORTotherwise,AbortRESM咖al,Flags3;…endManualModeJPSS15EXTT;...andskiprestofState15SS150KJRSBumln,Flags3,SS15BI;skipaheadifBum陽inmodeRESMtrScale,Flags;setforAlternator°/。LEDoffRESMtrUnits,Flags;setforVoltsLEDON,batt0/0LEDoffCALLShowMeter;updatemeterLEDsJPSS15nnp;jumptorampcheckSS15BIJRRMIN5TicFlag2,SS15b;skipaheadifnottimetoupdatecounterDECCCDcnt;decreasedisplaycountby1CALLIniTime2;resetTimer2LDIMIN"s2,1;settimerforcounterinterval(1minute)SS15bLDA-CCDcnt;getlatestcountdownvalueLDLEDnum,A;storeinLEDnumCALLShowNum;displaycountondigitalLEDCALLMeterOff;turaoffallmetermodeLED'sSS15nnpCALL§howData;updatedisplayJRSNoRamp,Plags4,SS15一l;don'trampifNoRampissetCALLChkR邻id;updateRamptimer,ifnecessaryIRRRmpng,Flags3,SS15一l;skipaheadifnotRapid->FasttransitionCALLRampOS;otherwise,graduallyreducedutycycleSS15一1JRR^R,TicHagl,SS15EXIT;continxieifnotmaxmanualchargetimeJRSBurnln,Flags3,SS15—2;skipaheadiffinishedBum-InJPRESET;,.,otherwise^resetSS15一2CAllDigitsOff;turnofif3-digitLEDCALLResetLEDs;tumoffalltype,rate&StatusLED'sCALLShowGreen;lightGreenLEDonlyCALLShutOff;bw&highpower,fan,&crankoff;mindutySS15EXITJPExitMain*BOOSTMODE**FirstsetthechargeroffsetvalueforSlowcharging.Next,wait**forthevoltagetostabilize.Thenwaitforthevoltagetodrop**aboutonevolt.Whenthevoltagedrops,gofoilonfor5seconds.*Afterfivesecondsofcranking,waitfor4minutesandstartover.,SS16.IFCDEBUG;assemblenextlineonlyifdebuggingRESSwOff)SwDown;settocheckTypeandRateswitches.ENDCCALLVoltMtr;setforvoltmeterandupdatedisplayCALLCheckBatt;checkfordisconnectedbatteryJRRBatt-Flags2,SS16—1;skipaheadifnotconnectedJRSSEC,TicFlag2,BaSOK;skipif>2secondssinceBoostselectedJPSS16Exit;if<2seconds,thenstayoffSS16—1CALLTurnOff;bw&highpowerandfanoff,mindutyCALLShowRed;turnonAlertLEDJPSS16Exit;ifbatt<1.6V,thenstayoffBattOKJRSLoPwr,Flags2,SS16—2;skipaheadifalreadyonSETSOC,Flags4;setSt^tOfChargeflagSSI6—2CAliShowCrank;tumONCrankLED&turnAlertLEDoffCALLTumON;turnoutput,Fan,andChargingLEDonCALLMaxLow;setforfoillowerpowermode<formula>formulaseeoriginaldocumentpage41</formula>JRNCSS18EXITSS18」SETLoPwr,Flags2;tumoutputonSETHiPwr,Flags2;turaonhighpowermodeSETNoOff,Fi昭s2;setfor00%dutycycteINCCurentSS;timethecrankingCALLIniTime2;resetTimer2LDISECs2,CrankON;crankforCrankON(8)secondsSS18EXITCALLCheckl7v;dieckfordisconnectedbatteryJRCSS18—X;skipaheadifconnectedJPMAIN2;otherwise,startoverfromstate0SS18一XJPExitMain*CRANKTIMING**AllowcrankingforCrankONsecondsandthengobacktocharging.SS19LDA,SECs2;getremainingcranksecondsLDLEDnum,A;storeinLEDnumCALLMeterNum;showLEDnu迈andturnoffmetermodeLED'sJUSSEC,TicFlag2,SS19—1;iftimeisup,thenendroutineCALLCheckl7v;checkfordisconnectedbatteryJENCSS19—1;stopcrankingifnotconnectedJPSS19EX斤;stillconnected,waitforcranktimerSS19—1INCCurentSS;justwaitfortimetoexpireSETCrankWait,Flags;indicatescrankcool-downtimeCALLTuraON;turnoutput,F叫andChargingLEDonCALLMaxLow;setforMllowerpowermodeCAULIniTime2;resetTimer2LDIMINs2,CrankOff;settimerforofftime(twominutes)CALLIniTimel;resetTimerlLDISECsl,CCDint;settimerforcounterinterval(seconds)LDICCDcnt420;setcrankcooldowncounterto120SS19EXITJPExitMain*INTER-CRANKDELAY**Stayhereuntilthe4minutetimerhasexpiredthengobacktoBOOST:*ifswitchstillengaged,elsegotoSlowauto(default)SS20CAIXFanON;turncoolingfanONIRRSEC,TicFlagl,SS20—0;skipaheadifnottimetoupdatecounterDECCCDcnt;decreasedisplaycountby1CALLIniTimel;resetTimerlLDISECsl,CCDint;settimerforcounterinterval(seconds)SS20—0LDA,CCDcnt;getlatestcountdownvalueLDLEDnum,A;storeinLEDnumCALLMeteiNum;showLEDmmandturnoffmetermodeLED'sCALLVoltReg;regulatebatteryvoltageatMaintVoltRESRmpng,Flags3;clearflagforCheckBattRESSettle,Fiags3;clearflagforCheckBatt顶SMIN,TicFlag2,SS20一l;timeupYes:GoToSS20—1CALLBlinkCrank;No:blink也eCrankLEDJPSS20EXrT;andkeepwaitingSS20—1RES^)rankWait,Flags;resetCrankWaitbitofFlagsLDICurentSS,010h;setstateto16toCrankagainSS20EXITJPExitMain*SUBROUTINESSTARTHERE**Initializestate(Slowcharge,Regularbatt^State0)*InitStateCLRFlags;0isdefaultforallbitsCLRFlags2;0isdefaultforallbitsCLRFlags3;settoindicatenoRapidtoFastchangeCLRTEMPI;initializeCLRCCDcnt^initializeSETGhMode,Flags2;setforGhargerMode(chargermode)LDIOFFSET,HiOff-1;setformi迈imumo啤utcurrentLDISwData^O110111lb;InitializeswitchLEDsfor2入RegLDIV咖x,Volts155;VmaxforHegukrbatteriesLDIVltCnt,001h;initializeVltCntto1LDIYRcnt,001h^initializeVRcntto1LDIPcntL,OOlh;initializePcntLto1LDIPcntH,001ii;initializePciUHto1LDICurentSS,0OOh;setchargerstateto0LDISECsl,SecInit;restartTIMER1secondcounterLDISECs2,SecInit;restartTIMER2secondcounterRET,ResetWatchdogRegister*;*ThisroutinesimiplyresetstheWatchdogregister.RstWDRwas*:*onlytosaveprogramspace(LDIrequire3bytes,CALLrequiresonly2).RstWDRLDIWDR,0FEH;resetwatchdogtimerRET,WaitaFifthSecond*,*Thisroutinecausestheprogramtowaitonefi他secondbywaiting;*for24interrupts.*Fi他Se咖dCALLIniTimelLDIMSJSCsl,MS200;settimerfor1/5secondWFS—1CALLRstWDR;resetwatchdogtimerIRRMSEC,TicFlagl,WFS—1;waituntiltimergoesto0RET一*SetRampUp**Thisroutinesetstheparametersnecessarytorampthedutyupfromthe*fastratetotherapidrate.ItisusedbeforeBurn-InandAutomatic**Rapidcharge.*SetRmpUpLDIRmpCnyiCinitX2;2000.75-secondintervalsyields150secondsSETRampUp,Flags3;setforrampupSetRampLDITEMP,RIinit;180NMIinterruptsyields1.5secondsSETRmpInt^FlagsS;counting1stoftwo180cycleperiodsRESRmpng,Fiags3;setfornotrampingyetRET*CHECKRAPID**Thisroutinedetermineswhethertoreduceorincreasethechargerate*from30Ato10Aorvicaversa,ifnecessary.Itsetstheflagsusedby:承HampOSappropriately-净ChkRapidIRRRate,Flags,ChkRapX;ifnotFastchargerate,thenexitJRSRmpng,Flags3,ChkRapX;ifRmpngalreadyse仁thenexitDECTEM^;otherwise,updateramptimerJRZRmpT皿;updatecountiftimeJPChkRapX"..otherwise,justexitRmpTmrLDITEMP,RIinit;co皿t180morecycles(1.5sec)IRRRmpInt,Fiags3,RmpCtr;skipaheadifjustcounted1sthalfRESRmpInt,Flags3"..otherwise,startcounting2ndMfJPChkRapX;...andexitRmpCtrSETRmpInt,Flags3;counting1stoftwo180cycleperiods.IFCEQShoReg;assembknextlineonlyifdebuggingCALLsiiowAlt;tumonalternator%LED.ENDCDECRmpCiit;checkiftimetorampJRZStartRamp;ifso,startrampingJPChkRapX;…otherwise,justexitStartRampSETRmpng,Flags3;settoindicateRapidtoFasttransitionRESNoOff,Flags2;activatePWM(<100%dutycycle)LDIRmpCntjRCitiit;1003-secondintervalsyields5minutesJRSRampUp,Flags3,StRmpUp;skipaheadifabouttorampupLDIRnipCnt,RCinitX2otherwise,doubleinter-ramptimeStRmpUpSET腿wr,Fiags2;tumonhighpowerCALLShowRate;showRapidLEDcolorChkRapXRET;*RAMPOFFSET*;*Thisroutinechangesthechargeratefrom30Ato10Agraduallyby*;*changingOFFSETfromOffRaptoHiOffatasteadyrate.OFFSETis*raisedlby1every4seconds.Thatchangesthecurrentfrom30Ato10A*;*inabout4minutes.*,*承RampOSJRRRate,Flags,RmpOffX;ifnotFastchargerate,thenexitDECTEMP;…oierwise,decrementcounterJRZHampTime;iscounterdowntozeroJPRmpOffX;ifnot,justexitRampTime"..otherwise,timetoadjustJRSRmpInt,Flags3,RampInt;skipaheadifonlyhalfwaythroughwaitJRSRampUp,Flags3,RmpUp;skipaheadifdecre朋ingOFFSETCALLChkHiOff;checkformaxOFFSET(PWMfoilo坊JRNZRampMore;if加t,skipaheadandcontinuerampingRESRmpng,Flags3;rampingcomplete,clearflagRESHiFw,Fiags2;turnoffhighpowerCALLShowRate;showFastLEf)colorSETNoOff,Flags2;setforftilllowpowerSETRampUp,Flags3;settorampupnexttimeJPRmpOffiC;sgptoendofroutineRampMoreINCOFFSET"..otherwise,reducedutycycle.IFCEQShoReg;assemblenextlineonlyifdebuggingCALLShowRed;turnonRedLED.ENDCSETRmpInt,Flags3;counting1stoftwo180cycleperiodsJPRmp(3ffT;skipaheadandre-initializecounterRmpUpLDA,OFFSET;getOFFSETCPIA,OffRap;isitOffRapYetJRNZRmpAgain;ifno"skipaheadandcontinuerampingRmpDoneRESRmpng,Flags3;rampingcomplete,clearflagRESRampUp,Flags3;settorampdownnexttimeJPRmpOffX;s&ptoendofroutineRmpAgainDBCOFFSET".otherwise,reducedutycycle,IFCE<3ShoReg;assemblenextlineonlyifdebuggingCALLShowGreen;tumonGreenLED.ENDCSETRmpInt,Flags3;counting1stoftwo180cycleperiodsIPRmp6f2;s^ipaheadandTe-initializecoimterRamplntRESRmplnt,Flags3;countinglasttwo180cyclesofintervalRmpOfflLDI丁EMP,RIinit;setcounterfor180cycles(1.5moresec)RmpOffXRET;*SHOWNUMBER*;*ThisroutinedetermineswhatthreedigitstodisplayonthedigitalLED*;*torepresentthenumberstoredinLEDNum,T&ethreedigitswillbe*displayednexttimetheShowDataroutineiscalled.*,氺*ShowNumCLRIndex^initializeLUTIndexto0CALLDigiOff;setregistersforallsegmentsoffLDA,LEDnum;storeLEDnuminaccumulatorCPIA,IO;checkforsingledigitnumberJKNCChkMaxNum;...ifnot^checkformaxnumberJPN"extOOl"..otherwiseskipto3rddigitClikMaxNumCPIA,199;checkforhighestdisplayablenumberJRCCheck100;ifless,checkvalueLDIA,199;…otherwise,displaly199Chec咖OCPIA,100;checkwhehtertoshow咖stsignificant1JHCCheck010;if加t,checkfor10RESDigitl,DigiDat2;otherwise,turnONmostsignificant1SUBIA,100;,.,andsubtract100fro迈accumulatorCheck010CPIA,10;clieckif<:i0JRCCheck001;,..ifso,skipaheadandcheck3rddigitINCIndex;…otherwise,shownexthighervalueSUBIA,10;...andsubtract10fromAcumulatorJPCheckO10;…andcheckfornexthighervalueCheck001LDIDRWR,DigitsOx0.w;lookuptable(LUT)for2nddigitLDIX,Digits0x0.d;initializeLUTLDATemp,A;saveAccumulatorLDA,Index;getindexfromstartofLUTANDIA,03Fh;limittowindowADDAjX;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA(X);storevalueatXintoAAND人DigiDat2;…setbitsin八forseconddigitLDDigiDat2,A;…storeAintoDigiDat2LDA,ATemp;restoreAccumulatortoremainderofLEDnum;CLRIndex;initializeLUTIndexto0NextOOl;CP1A'l;clieckif<l;JRCShoNumOOl;…ifso,skipaheadtoendofroutine;INCIndex;…otherwise,shownexthighervalue;SUBI人l;,.,andsubtract1fromAcumulator;JPNextOOl;…andcheckfornexthighervalue;ShoNumOOlLDIDRWR,Digits00x.w;lookuptable(LUT)for3rddigitLDIX,DigitsOOx.d;initializeLUT;LDA,Index;getindexfromstartofLUTANDIA,03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;stoi"eaddressofvalueinXLDA,(X);storevalueatXintoAAND人,DigiDatl;...setbitsinAforsegmentsLDDigiDatl,A;".storeAintoDigiDatShowNumXRET*GetBatt**ThisroutineadjuststhebatteryvoltagestoredinBADhiforthecable**dropbycallingGetDrop,thenstorestheresultintheaccumulator.*GetBattCALLGetDrop;getapproxbattcablevoltagedropLDA^ADhi;getlatestavgbattvoltageSUBA,Vdrop;adjustforvoltagedropincableRETGETVOLTAGEDROP**Thisroutinedetermineswhatvaluetousefortheoutputcablevoltage**dropbasedon1hevalueofOFFSET,thestateoftheHiPwrandNoOff*flags,andthevaluesintheDropOffsbok-邵table.*GetDrop■LDATemp,A;saveAccumulatorCLRVdrop;setVdropto0CLRIndex''initializeLUTindexto0JRRChMode,Fl昭s2,GDX;leave0ifintestermodeJRRLoPwr,Flags2,GDX;alsoleave0ifoutputisoff.IFCNoDrop;assemblenextlineonlyifdebuggingJGDX;leave0ifinNoDropmode(debugging).ENDCJRRHiPwr,Flags2,VDlow;skipaheadifnothighpowerCALLChkHiOff;checkformaxOFFSET(PWMfUlloff)JRNZGDhi;…ifnot,checkforrate>FastLDIIndex,MaxDrpL"..otherwise,setforrate=FastJPGDXGDhiLDIIndex,MaxDrpH;maxindexforHighPowermodeJPGDLUTVDlowLDIIndex,MaxDrpL;initializeVdroptoMaxDrpLJRRNoOff,Flags2,GDLUT;checktableifnotfUlllowpowerJPGDXotherwise,exitroutineGDLUTLDIDRWRJ)ropOffs.w;bokuptable(LUT)VdropoffsetsLDIX,DropOffs.d;initializeLUTLDA,Index;getindexfro迈startofLUTANDIA,03Fli;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoACPA,OFFSET;isOFFSEThighenoughtodecreaseVdropJKNCGDX;,"ifnot,skipaheadDECIndex"..otherwise,decrementindexJPGDLUT;,..andchecknexttableentryGDXLDA,Index;getVdropLUTindexLDVdrop'A;savenewdropintoVdropLDA,ATemp;restoreAccumulator歴;*GETVOLTDIGITS*;*Thisroutinedetermineswhatthreedigitstochspkyonthedigital;*LEDtorepresentthebatteryvoltage(BADhi).**GetVoltsDECVltCnt;decrementintervalcounterJRZNewVolt;if0,readytoupdatedisplayJPGetVexit;...otherwise,justexitNewVoltLDIVltCntjMS500;re-initializeinitervalcounterCALLDigiOff;setregistersforallsegmentsoffJRRChMode,Flags2,GVT;ifTestermode,useFreshBVCALLGetBatt;getbatteryvoltageadjustedfordropJPGV10GVTLDA,FresKBV;GetlatestaveragebatteryvoltageGV10CLRIndex;initializeLUTIndexto0CPIA'VoltslO;checkfor10VJRCChecklV;ifnotI0VthenskipaheadRESDigitl,DigiDat2;otherwise,turnONmostsignificant1SUBIA,VoIts10;…andsub,tract10VfromaccumulatorChecklVCPIA,Vo謹;checkif>1.OJRCCheck01V;…ifso,skipaheadandcheck3rddigitINCIndex"..otherwise,shownexthighervalueSUBIA,Volts01;',.andsubtract1.0VfromaccumulatorJPChecklV;...andcheckfornexthighervalueCheck01VLDATemp,A;saveAccumulatorLDIDRWR,Digits0x0.w;lookuptable(LUT)for2nddigitLDIX,Digits0x0,d;initializeLUTLDA,Index;getindexfromstartofLUTANDIA,03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAAND人DigiDat2;…setbitsinAforbottomsegmentsLDDigiDat2,A"..storeAintoDigiDat2LDA,ATemp;restoreAccumulatortoremainderofLEDmini;CLRIndex;initializeLUTIndexto0;ChGkPntl;CPIA,l;oheckif<l;JRCsliowVOOI;..,ifso,skipaheadtoendofroutine;INCInd战"..otherwise,shownexthighervalue;SUBIA,1;…andsubtract1fromAcumulator;JPChcUntl;...andcheckfornexthighervalueShowVOOlLDIDRWR^DigitsOVx.w;lookuptable(LUT)for3rdvoltsdigitLDIX,DigitsOVx.d;initializeLUT;LDA,Index;getindexfromstartofLUTANDIA,03Fh;iimittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAANDA,DigiDatl;.,.setbitsinAforbottomsegmentsLDDigiDatl,A;,..storeAintoDigiDatlRESDecimal,DigiDatl;turnONdecimalpointGetVexit;Ge飾XRETVolMeter*;*Thisroutinesetsthedisplaytoshowvolts,thencallsShowMeterand;*ShowDatatoupdatethedisplaywiththecurrentbatteryvoltage.*>承承;*GetMeter举,*ThisroutinecallsShowMeterandShowDatatodisplaythelatest*;*voltageorpercentage(determinedbyMtrScale&]MtrUnits)onthe4;*3-digitLEDdisplay.GetMeteristiielastsectionofVoltMtr.*Vol偷RESMtrScale,Flags;setforAlternator%LEDoffRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffGetMeterCALLShowMeter;update迈eterLEDsCALLShowData;updatedisplayRET*GETPERCENT**Thisroutinedetermineswhatvaluetouseforthepercentageof**chargebeforethechargestatehasreachedthedv/dtstate.The**percentiscalculatedbyreadingthebatteiyvoltage(BADhi)and审performingthefollowingcalculations:**AsTester**1.0V<BADhi<11.6VDC=>Percent-(BADhi/16)+l**11.61V<BADhi<12.歸C=>Percent-(BADhi-175)*5+15*12,80V<BADhi=>Percent-100**AsGharger**iVolt<BADhi<12Volts=>(BADhi/4)+15=Percent**12Volts<BADhi<dv/d—>(^ADhi72)-30-Percent*GetPercentIRSChMode,Flags2,GPchg;skiptoCharging%JPTstrBP"-.otherwise,jumptoBattery%GPchgLDA,CurentSS;getcurrentprogramstateCJrA,l1;haschargingreacheddV/dtJRCCalcPrcnt;…ifnot,calculatepercentageJPGetPctEnd".'otherwise,do加tibingCalcPrcntLDA,Percent;getPercentCPIA,76;checkforhighestcalculated%JRCGPmore;continueifnotthereyetJPGetPctEnd;.,.otherwise,justexitGP依oreJRRHiPwr,FIags2,GPl;coatinueifnotinHighPowermodeJPGetPctEnd""otherwise,justexitGP1CALLGetBatt;getbatteryvoltageadjustedfordropCPIA,Volts12;isthebatteiyvoltagelessthan12VJRNCFormula2;..,No,gotoFornmla2CPIA,Vo讓;Isbattery>1JRNCGPforml;...ifso,skipnextlineJPGPzero;…ifnot,setforzero%GPforaUCALLDhdde4;.,.Yes,usefirstformulaADDIA'15;Addl5and…JPGetPctExit;…storeintoAFonnula2CALLDivide2;Divideby2andSUBIA,30"subtract30JPGetPctExit;skipaheadandfinishroutineTstrBPLDA^FreshBV;getlatest(avg)batteryvoltageCPI人Volts128;Isbattery>12.8VJRCTstrlOO;..,ifnot,skipaheadLDIPercent,100;…otherwise,Percen—100JPGetPctEnd;…andendroutineTstrlOOCPIA,BattMin;Isbattery>BattMinJRNCTstrBPhi;…ifso,jumpaheadCPI入Volts01;Isbattery>1JRNCTstrBPmed;...ifso,jumpaheadGPzeroLDIPercent,0;...otherwisesetPercentto0JPGetPctEnd;…andendroutineTstrBPhiSUBIA,BattMin;subtractminimmnhighvoltageCAIXATimes5;multiplyby5ADDIA-15;addl5JPGetPctExitstoreintoATstrBPmedSUBIA,15;A=battery-15CALLDivide4;A-(batteiy-15)/4CALLDivide4;A-(battery-15)/16INCA;A-(battery-15)/16+lGetPctExitLDPercent,A;storeintoPercent<formula>formulaseeoriginaldocumentpage51</formula>JRSChMode,Flags2,NewPctl;**Temp**CALLDivide2;**Temp**NewPctl;**Temp**LDPcntH,A;re-initialize%intervalcounter;LDIPcntH,PCint;re-initialize%intervalcounterLDA,DspPcnt;getlast%displayedJENZUBP2;skipaheadifnot0%LDA,Percent;getnew%JPUBPfinish;andfinishroutineUBP2CPA,Percent;comparetonewest%JRZUBPexit;ifequal,donothingJRCIncBP;ifless,increasedisplay%by1JRSChMode,Fags2,UBPexit;don'tdecre站e%ifchargingDECA"..otherwise,decrease%by1JPUBPfinish;.,.andfinishIncBPINCA;increasedisplay°/。by1UBPfinishLDDspPcnt,A;storeupdateddisplay%UBPexitRETMeterNum**ThisroutinecallsMeterOffiShowNum^andShowDatatoturnoffthe**displaymodeLED'sanddisplayLEDnumonthe3-digitLEDdisplay,*NumData**ThisroutinecallsShowNumandShowDatatodisplayLEDnumonthe*3-digitLEDdisplay.NumDataisthelastsectionofMeterNunL*MeterNumCALLMeterOff;turnoffallmetermodeLED'sNumDataCALLShowNum;getdatatoshowthenumberCALLShowData;showthenumberRET*SHOWDATA**ThisroutineupdatesthedigitalLEDand6switchLEDscontrolledby:*theserialtoparallelshiftregisters.ItsendsdiebitsofSwData**andDigiDatatotheregistersbitbybitfromLSBtoMSBusing**SerData.Aftereachbitissent,ShflClkistoggledtoshiftthebit**tothenextposition.AfteraU24bitehavebeensent,LtcliClkis**usedtoupdatetheoutputs,whichupdatestheLEDs.*ShowDataCALLRstWDR;resetwatchdogtimerRESClrData,DRAbuf;clearshiftregisterLDA,DRAbuf;updateAccumulatorfrombufferLDDRAjA;updateportfromAccumulatorSETClrData,DRAbuf;preparetoacceptdataLDA,DRAbuf;updateAccumulator5ombufferLDDRAjA;updateportfromAccumulatorLDIBitCnt,008h;initializebit咖nterto8LDIBytCnt,003fi;initiaHziebytecounterto3LDA,DigiDatl;getfirst8bitsofdigitdataGetBitRLCA;sendMSBofAcmnulatortoCanyJRCSetBit;ifCany=lthendatabitis1RESSerData,DRAbuf""otherwisesetSerDatato0JPSendBit;skipaheadtoSendBitSetBitSETSerData,DRAbuf;setSerDatato1SendBitLDDataBuf,A;storeshifteddatafromALDA,DRAbuf;updateAccumulatorfrombufferLDDRA,A;updateportfromAccumulatorRESShfiCl、DRBbuf;setShiftClocklowRESLtchClk,DRBbuf;setLatchClocklowLDA'DRBbuf;updateAccumulatorfrombufferLDDRB-A;updateportfro迈AccuniulatorSETSMCl^DRBbuf;setShiftClockhighLDA,DRBbuf;updateAccumulatorfrombufferLDDRB,A;updateportfromAccumulatorDECBitCnt;updatebitcountJRZNextData;ifallbitssentthenskipaheadLDA^DataBuf;storeshifteddatabackinAJPGetBit;otherwise,getnextbitNextDataDECBytCnt;updatebytecountJRNZNextByte;getnextbyteiscountisnot0JPLatchData;.,.otherwise,donesendingbitsN战氾yteLDIBitCnt,08h;setbitcountfor8morebitsIDA,BytCnt;whiclibyteisnextCPI儿02h;checkfor2ndbyteisnextJRZScndByte;skipaheadifequalLD入SwData;get8bitsofswitchLEDdataJPGetBit;sendbitsofsecondbyteScndByteLDA,DigiDat2;getlast8bitsofdigitdataJPGetBit;sendbitsofsecondbyteLatchDataSETLtchClk,DRBbuf;updatelatchesLDA,DRBbuf;updateAccumulatorfro迈bufferLDDRB,A;updateportfromAccumulatorEJET*ShowMeter**ThisroutinesetsthedigitalLEDtoshoweitherthecurrentvoltage**orlastpercentbasedonFlagsandCurentSS.DuringEnginestart,it**willcountdownsecondsofeitherremainingcranktimeorcooldown*time.*ShowMeterJRRAlert,Flags2,ChkMtr;skipaheadifnotabortmode;CALLMeterOff"..otherwise,turnoffMeterModeLEDsJPSMeXitandexitChkMtr爪SMtrUnits,Flags,GetPrcnt;skipaheadandsetfor%CALLGet"Volts"..otherwise,getvoltsJRSChMode,Flags2,SMl;skipaheadifnotinTestermodeCALLResetStatusotherwise,turnoff3statusLEDsSMIJPSliowMtrX;".andskiptoendorroutineGetPrcntJRRChMode,Flags2,TstMtr;ifintester咖de,get%JPShowPrcnt".'otherwise,skipahead&show%ShowOLDIPercent,O;settoshow0%JPShowPrcnt;andskipaheadTs斷IDA,FreshBV;getlatestBatteryvoltageJRZShowO;if0V,show0%JRSMtrScale,Flags,AltTest;skipaheadifsetforAlt%JPBatfTest"..otherwise,skiptoBattery%AltTestCPIA,AltMin;checkfor<1stLUTvalueJRNCAltMaxT;ifnot,testfor>lastLUTvalueJPShowO"..otherwise,show0%AltMaxTCHA,AltMax;checkfor>lastLUTvalueJRCAltVal;ifnot,skipaheadandcheckLUTLDIPercentjl99"..otherwise,settomaxvalueJPShowPrcntjandskipaheadAkValLDIDR戰,AltLvls.w;LUTforalternator%LDIX,AltLvls,d.;initializeLUTSUBIA,AltMin;diffenceisindexinlookuptableANDIA,03Fii;l.imittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoALDPercent,A;storevalueintoPercentJPShowPrcnt)andskipaheadBattTest;CALLGetPercent;getbatterypercentShowPrcntCALLShowPercent;otherwise,showpercentageCALLShowStatus;tumonappropriatestatusLEDShowMtrXCALLShoMtrMode;turnonappropriatemeterLEDSMeXitCALLRstWDR;resetwatchdogtimerRET*SHOWMETERMODE*;*ThisroutineturnsononeofthemeterunitsLED'sbasedonFlagsand,*Flags2.IftheunitisinTesterMode(ChMode-0),theroutinewill*;*alsolighttheappropriatestatusLEDbasedonthevoltageatthe*;*clamps.*,*氺ShoMtrModeSETLEDvoIt,DRAbuf;tumo任DCVoltageLEDSETLEDprcnt,DRAbuf;tumoffBattery%LEDSETLEDalt,DRAbuf;turnoffAlternator%LEDJRSCrank,Flags,ShowMMX;leaveoffifinCrankmodeShowVoltsJRSMtrUnits,Flags,ShoPrcnt;gotoShoPrcntifset;RESDecimal,DigiDatl;turnONdecimalpoint鹏LEDvolt,DRAbuf;turaonVoltageLEDJPShowMMXShoPrcnt;SETDecimal,DigiDatl;turnoffdecimalpointJRSMtrScale,Flags,SliowAlt;gotoSiiowAltifsetRESLEDprcnt,DRAbuf;turnonBattery%LEDJPShowMMXShowAitRESLEDalt,DRAbuf;turnonAlternator%LEDShowMMXLDA,DRAbuf;updateAccumulatorfrombufferLDDRA,A;updateportfromAccumulatorRET;*HoldMeterModeLED(dependingonmode)*;*ThisroutineturnsontheBattery%,VoltsDC,orAltemator%LEDbased;*onFlags&Flags2andkeepsthatLEDonforon&fifthsecond.*koldMtrMdCALLShoMtrMode;tumonMeterModeLEDCALLFifthsecond;waitonefifthsecondRET*SHOWSTATUS**ThisroutineturnsononeofthethreestatusLED'sbasedonthe*batteryvoltage.Thisroutineisforuseinthetestermode.*ShowStatusJRRChMode,Flags2,TstrStat;checkforTestermodeJPShoStatX;ifnot,skiptoendTstrStatLDA,FreshBV;getlatestBatteryvoltageJRSMtrScale,Flags,TestAlt;skipaheadifsetforAJternatorLDA,DspPcnt;getlast%displayedCPIA,IOO;IsitlOOJRZGrnBatt;...ifso,showgreenLEDCALLResetStatus"..otherwise,turnStatusLED'soffJPShoStatX;...andskiptoendGrnBattCALLShowGreen;turnonGreenLEDJPShoStatX;skiptoend■TestAltCPI厶Vo〗tsl5a;Isalternatoratleast15.07VJKNCRedAlt;...ifso,skipaheadandshowredCPIA,Volts138;isalternatoratleast13.80VJRGHedAlt;…ifnot,skipaheadandshowredCPI夂Voltsl4;Isalternator<14,0VJRCYelAlt;..,ifso,skipaheadandshowyellowCPIA,Volts149;isalternatoratleast14.87VJKNCYelAlt;…ifso,skipaheadandshowyellowCALLShowGreenotherwiseturnonGreenLEDJPShoStatX;..,andskiptoendRedAltCALLShowRed;tononRedLEDJPShoStatX;skiptoendYelAltCAIXResetStatus;turnStatusLED'soff;CALLShowChgng;turnonyellowLED;JPShoStatX;,..andskiptoendShoStatXRET;*METEROFF*;*ThisroutineturnsoffthethreemetermodeLED's.*,**.承承承:(::l:承:ls:i::l:承承:l:4:承承Hs承承氺:l:承承:l:;l:承承承sl::l;承:l::l:承4:承:i:承:):承:i::l:Hssl:承承:l:;l:牵承:l::H承豕>|:*::|::|:乘承*承承:|:承*:<:承4:4:承:|:沐承承*MeterOffSETLEDvolt,DRAbuf''turnoffDCVoltageLEDSETLEDprcntJDRAbuf;tumoffBattery%LEDSETLEDalt,DRAbuf;turnoffAlternator°/。LEDLDA,DRAbuf;updateportAfrombufferLDDRAARET;*DigiOff*;*Thisroutinesettheregisterstoturnoffthethree-digitLED.碎**,承承氺承承承丰申承jj:**********^***承承:(!承承承伞承***氺承)|!*********举*丰%=承水承:1:承4:承承*-*!(!**承尔**bigiOffLDIDigiDatl,DigiOffa;tumoff8of16digitalsegmentsLDIDigiDat2,DigiOffb;turnoffother8of16digitalsegmentsRET,*DIGITSOFF*,*Thisroutineturnsoffthethree-digitLED.*DigitsOffCALLDigiOff;setregistersforallsegmentsoffCALLShowData;updatedisplayRET*DIGITSON**ThisroutineturnsONallsegmentsofthethree-digitLED.DigitsONLDIDigiDatl,DigiONa;turnON8of16digitalsegmentsLDIDigiDat2,DigiONb;turnONother8ofl6digitalsegmentsCALLShowData;updatedisplayRET*SHOWPERCENT**ThisroutineturnsONtheBattery%LED.ShowPercentSETMtrUnits,Flags;setFlagsfor%(notvolts)RESMtrScale'F〗ags;setFlagsforbatt(notalt;CALLShoMtrMode;turnonappropriateindicator(%)CALLUpdateBP;update%todisplayJRRWa加P,Flags2,SPl;skipaheadifnotwaitingfrom0LDIDigiDatl,Dashesl"..otherwise,showdasheswhilewaitingLDIDigiDat2,Dashes2;…otherwise,showdasheswhilewaitingJPShowPxSP1LDAjDspPcnt;getPercentvaluetodisplayXRRMtrScale,Flags,SP2;don'tuseDisplay%forAlternator%LDA,Percent;...useactualPercentfordisplay.IFCEQShoOff;assemblenextlineonlyifdebuggingJRRChMode,Flags2,SP2;skipahead**DEBUG**LDA^OFFSET;diplayOFFSET**DEBUG**;JRSRmpng,FIags3,SF2;**DEBUG**;LDA,RmpCnt;displayRampCount**DEBUG**.ENDCSP2LDLEDnum,A;…andstoreitinAccumulatorCALLShowNum;setdigitalLEDforLEDnumSETDec;imal,DigiDatl;tumOFFdecimalpointShowPx;CALLShowData;updatedisplayRET*RESETLEDS**ThisroutineturnsofftheType,Rate,andStatusLED'sResetLEDsCALLResetStatus;tumoffallthreestatusLEDsCIrLEDsLDISwData,SwsOff;turnoffTypeandRateLED隨s;CALLShowData;updatedisplayRET*ResetStatus**ThisroutineturnsofftheLED'sintheStatusarea.ResetStatusSETLEDchgng,DRAbuf;turnoffChargingLEDSETLEDdone,DRAbuf;tumoffChargedLEDSETLEDalert,DRAbuf;tumoffFault(red)LEDLDA,DRAbuf;updateAccumulatoriro迈bufferLDDRA,A;updateportBfromAccumulatorRETBLINKChargingLED**ThisroutineblinkstheChargingLEDatarateofoncepersecondBlnkChrgLDAJMSECsI;getMSECscountCPIA,MS500;testfor>1/2secJRNCBlinkChl;ifso,skipaheadCALLResetStatus"..otherwise,turnoffstatusLEDsJPBliukChX;...andexitroutineBtbkChlCALLShowChgng;TurnonChargingLEDBlinkChXRET*ShowCharging**ThisroutineturnstheChargingLEDonandtherestoff.ShowChgngCALLResetStatus;turnoffallStatusLBDsShowYellowRESLEDchgng,DRAbuf;tumONChargingLEDLDA,DRAbuf;updateAccumulatorfrombufferLDDRA,A;updateportAfromAccumulatorRET*BLINKAlertLED**ThisroutineblinkstheAlertLEDatarateofoncepersecond.BlinkAiertLDA,MSECsl;getMSECscountCPIA,MS500;testfor1/2sec厕CBlnkAlrt;ifso,skipaheadCALLResetLEDsotherwise,turnoffallLEDsJRSBumln,Flags3,BBI;skipaheadif加tBum-InCALLDigitsON;...tutnonalldigitalLEDsegmentsJPBAeXit;,..andexitroutineBBI58CALLNumData;getdatafor,andshowLEDnumberJPBAeXit;...旭dexitroutineBlnkAlrtCALLAlertON;TumonAlertLEDCALLDigitsOff;Turnoff3-digitLEDBAeXitRET;*AlertLEDON*;*ThisroutineturnsontheAlert(red)LEDandturnstheothermeter;*LEDsoff.NOTE:itdoesnotaffecttheRateandTypeLEDs.*XlertONCALLMeterOff;TuraoffMeterModeLEDsShowRedCALLResetStatus;TurnoffStatusLEDsRESLEDalertJDRAbuf;T咖onAlertLEDLDA,DRAbuf;witefrombuffertoportBLDDRAARET*ShowDoneLED**ThisroutineturnsontheDone(green)LEDandturnsalltheotter*LEDsoff.NOTE:itturnsofftheRateandTypeLEDs.*ShowDoneCALLResetLBDs;TurnoffallLEDsLDISwData,SwsO任;setType&RateLED'soff;CALLSh。wData;updatedisplayCALLShoWType;showBatteryType&updatedisplayShowG銜nCALLResetStatus;turnoffallthreestatusLEDsRESLEDdone,DRAbuf;T咖onDoneLEDLDA,DRAbuf;updateAccumulatorfrombufferLDDRA,A;updateportAfro迈AccumulatorKET;*BLINKCrankLED*;*ThisroutineblinkstheCrankLEDatarateofoncepersecond.BlinkCrankLDA,MSECs2;getMSECscountCPIA,MS500;testfor>1/2sec厕CBlinkES;ifso,skipahead;CALLResetLEDs"..otherwise,turnoffallLEDsSETLEDboost,SwDataotherwise,turnoffCrankLEDJPBCeXit"..andexitroutineBlinkESCALLShowCrank;turaonCrankLEDBCeXit;CALLShowChgng;lightChargingLEDRET*ShowCraok**ThisroutineturnstheEngineStart(Crank/Boost)LEDonandturns:*theTypeandotherRateLEDsoff.*ShowCrank;CALLResetLEDs;turnoffallLEDsCALLClrLEDs;turnoffallRate&TypeLEDsRESLEDboost,SwData;turnONCrankLEDCALLShowData;updatedisplayRET*SetSlow**ThisroutinesetsthechargerfortheSlowratebysettingtheappro-:*priateflags.*,SetSiowRESCr喊Flags;tumoffCrankLEDRESRate,Flags;turaonSlowLEDRESNoOff,Flags2;activatePWM(<100%dutycycle)RESHiPwr,Flags2;turnoffhighpowermodeLDIOFFSET,OffSlow;setOffsetfor2ARETMaxLow**Thisroutinesetsthechargerforthemaximumlowpowerrate(=Fast):*bysettingOFFSETandtheappropriateflags.*%SstLow承*Thisroutinesetsthechargerforthelowpowermodebysettingthe**appropriateflags.SetLowisactuallypartofMaxLow*MaxLowLDIOFFSET,MinOff;setOffsetforhighestlowpower(1OA)SetLowRESNoOff'Flags2;activatePWM(<100%dutycycle)RESHiPwr,Flags2;tunioffliiglipowermodeRET*ShowChargeRateLED(dependingonmode)**ThisroutineturnsontheSloworFastLED,basedonFlags.ShowRateJRSChMode,Flags2,ShowSlow;skipaheadifnotTesterSETLBDfast,SwData"..otherwise,turnoffFastLEDSETLEDslow,SwDataalso,turnoffSlowLEDJPShoRateXShowSlowJRSRate,FIags,SliowFast;gotoShowFastifsetRESLEDskrw,SwData;turn。nSlowLEDSETLEDfast,SwData;tumoffFastLEDJPShoRateXShowFastSETLEDslow,SwData;turnoffSlowLEDJRSHiPwr,Flags2,ShowRap;gotoShowRapifHighPowerRESLEDfest,SwData;tumonFastLEDSETLEDrap'SwData;turnoffRapidLEDJPShoRateXShowRapRESLEDrap,SwData;tumonRapidLEDSETLEDfast,SwData;tumoffFastLEDShoRateXSETLEDboost,SwData;turnoffBoostLED;CALLSkwData;updatedisplayRET*SetReg**ThisroutinesetsthechargerfortheRegularbatterytypebyreset-*tingtheDeepCycleandAGM/Gelflags.*SelRegRESBafTypeA,Flags;turnonRegularLEDRESBatTypeB,Flags;tarnoffGel/AGMLEDRET*ShowChargeTypeLED(dependingonmode)**ThisroutineturnsoneithertheRegular,DeepCycle,orGel/AGMLED*basedonFlags.Thero咖ealsosetsVmaxtomatch*ShowTypeSETLEDreg,SwData;setRegularLEDtooffSETLEDdeep,SwData;setDeepCycleLEDtooffSETLEDgel,SwData;setGel/AGMLEDtooffJRRBatTypeB,Flags,ShowT2;skipaheadifnotGel/AGMRESLEDgel'SwData;turnonGel/AGMLEDLDIVmax,Volts144;Vmax-14.4VforGel/AGMMODEJPShoTypeXShowT2JRSBatTypeA,Flags,ShowT3;gotoShowT3ifsetRESLEDreg'SwData;turnonRegularLEDLDIVmax,Volts155;Vmax=15.5VforRegularMODEJPShoTypeXShowT3RESLEDdeep,SwData;tumonDeepCycleLEDLDIVmax,Volts16;Vmax=16VforDeepCyclebatteryShoTypeX;CALLShowData;updatedisplayRET*HoldChargeTypeLED(dependingonmode)**ThisroutineturnsontheRegular,DeepCycle,orGel/AGMLEDbasedon:*FlagsandkeepsitonforoneFif^isecond,*HoldTypeCALLShowType;tumonBatteryTypeLEDCALLShowData;updatedisplayCALLFifthSecond;waitoneFifthsecondRET*HoldChargeRateLED(dependingonmode)**ThisroutineturnsontheSlow,Fast,or6VLEDbasedonFlagsand*keepsitonforoneFifthsecond,*CALLShowNum;shownominalrate(amps)ondigitalLEDCALLShowRate;turnonChargeRateLEDCALLShowData;updatedisplayCALLFi池Second;waitoneFifthsecondRET*CheckHighO迅et**ThisroutineisusedtocheckwhetherthelatestOFFSETisequaltothe**maximumvalue,HiOff.WhenOFFSET=HiOff,thechargerateisFastin*highpowermodeand0inlowerpowermode.*LDA,OFFSET;getcurrentOFFSETCPIA,HiOff;hasOFFSETreachedmaxinram(outputoff)RET*ClieckOV**Thisroutinechecksthelatestrunningaverageofthebatteryvoltage*andsetstheCarrybitifit,slessthanVoltsO+1DACcount.This**routineisusedtocheckwhetherabatteryisconnected.*Chec跳LDA,FreshBV;testlatestaveragevoltageCPIA,VoltsO+l;checkifhigherthanzeroRET*Checkl7v**Thisroutinechecksthelatestrunningaverageofthebatteryvoltage*andsetstheCarrybitifit'slessthanMaxVolts.Thisroutineis**usedtocheckwhetherabatteryisconnected.*Check:17vLDA,FreshBV;testlatestaveragevoltage;LDA,BADhi;testaveragevoltage<formula>formulaseeoriginaldocumentpage63</formula>ChkProgJRRMIN,TicFlagl,ChkProgX;exitifnottimetocheckforprogressChkProgOJKRSOC,Flags4,ChkProgl;skipaheadifnotStartOfChargeRESSOC,Flags4;…otherwise,dearSOCflagCALLLiiTiinei;initiaiizeTimerlLDIMINsl,5;,"setTimerlfor5minutesCLRLastBatt;clearLasfflatt(ensurepass1sttest)JPChkProgX;...and欧itChkProglLDA,BADhi;getlatestbatteryreading;SUBI入2;s"tracttwocounts**temp**SUBIA,l;subtmctonecountCPA,LastBatt;checkforincreaseJRCChkProgA;settoabortifnoincreaseLDA,BADhi;setAbacktoBADhiLDLastBatt,A;updateLasfflattCALLIniTimel;initializeTimerl.IFCNEFastCP;assemblenextlineonlyifnotdebuggingLDIMINs1,CPint;setTimerlfor60minutes.ELSE;asse迈blenextlineonlyifdebuggingLDIMINsl,3;setTimerlfor3mins.ENDCDECCCDcnt;updateintervalco\mtJRNZChkProgX;justexitifnotzeroSETHR,TicFlagl;ifzero,setfortimeexpiredChkProgALDICurentSS,ABORT;settostartAbortmodeChkProgXRET*BatteryProgress**ThisroutineisusedtoensurethatChkProgandCheckBattarecalled**onlywhenthechargerateisabouttorampuporisn'tsettorampat**all.Thaty,thebatteryvoltageusedtocheckchargingprogress**won'tbeaffectedbythehighercurrent.BattProgworksbychecking**RmpCnttomakesureit'slessthan5.Ifthestartofchargeflag(SOC)**isset,BattProgdoesnotcheckRmpCnt.*BattProgJRRRxnpng,Flags3,BtPrg0;skipaheadifnotRapid->FasttransitionCALLRa迈pOS;otherwise,graduallyreducedutycycleBtPrgOCLRA;setAto0toensure<(9,12,or14.2V)JEHw,Flags2,BtPrgl;skipaheadifnothighpowermodeJPBtPrgX;…otherwise,justexitBtPrglIRSSOC,Flags4,BtPrg2;skipaheadifStartOfChargeLDA,RmpCnt;getRampintervalcounter;NOTE:RmpCntwillbe0ifnotsettorampatallCPIA,5;isitalmosttimetorampupJRNCBtPrgX;ifnot,thenexitBtPrg2CALLChkProg;checkforchargingprogressCALLGetBatt;getbatteryvoltageadjustedfordropBtPrgXRET*CheckDip**CheckDipcomparesthelatest32sample(l/4second)averagebattery举*voltage,FreshBV,tothemaintainvoltageusedbyVoltReg'MaintVolt.**IfFreshBVismorethan0.5VbelowtheMaintVolt,theCheckDipchecks>*thedutycycle.IfOFFSETisbetweenOffSlowandHiOff,thenthe**chargecurrentismorethan0butlessthantheSlowrate(usually2A),**fnthatcase>thebatterywasprobablydisconnected,CheckDipraises**thechargeratetoSlowbysettingOFFSETtoOfiSlow.CheckDipalso**re-initializestheVoltRegintervalcounter,VRcnt,sothatVoltReg**won,tadjustOFFSETagainforanothersecond.Ifthebatteryreally**wasdisconnected,theoutputwillshootto17VandCheckBattwill**indicatenobattery'Ifthereisabatteryconnected,thentheoutput**neededaboosttoraisethevoltage,*;*NOTES:*;*CheckDipisonlycalledbyVoltReg,sotheoutputmustbeon,*;*VoltRegisonlycalledwhenthechargerisnotinhighpowermode.*;*IfOFFSETifHiOff-1orgreater,thentheoutputiszero.*CheckDipLDA,FreshBV;getlatestbatteryvoltageADDIA,Volts005;add1/2voltCPA,MaintVblt;comparewithsetvalue+1IRCChkDpl;ifFreshBV<MaintVolt-0.5V,continueJPChkDipX;.,.otherwise,exitroutineChtDpJLDA,OFFSET;getOFFSETCP1A,OffSkrw;checkforrate>SlowJRNCChkDp2;ifrate<Slow,thencontinueJPChkDipX"..otherwise,exitroutineChkDp2CPIA,HiOff-1;testifou中utisoffJRNCC!M)ipX;ifso,justexitLDIO鹏ET,OfSlcw"..otherwise,setforSlowrateLDIVRcnt,MSINIT;re-(nitializeinitervalcounter(1sec)ChkDipXRET*CHECKSWITCHES**Qieckifswitchisengagedandchangemodesifappropriate.*CheckSwJRRCrankWait,Fags,ChkStart;checkswitchesifnot(hiringCrankwaitJPChkSwKET;don'tcheckswitchesifduringCrankwaitChkStartJRRCrank,Flags,ChkMeter;checkmetermodeifnotduringBoostJPChkRate;skipmetermodeswitchduringBoostChkMeterIRRMeterSw,DRC,MeterDown;Ifswitchisbeingpressed,skipaheadRESMeterSw,SwDown;setforMeterswitchnotpressed(up)JPChkRate;Meterswitchnotpressed》soexitClieckSwMeterDownRESIdle,Flags3;setfornotidleJRRMeterSw,SwDown,ChngMeter;Ifswitchwasreleased,thencheckitJPChkRate;Otherwise,skipaheadChngMeter;changeMeterI^odeSETMeterSw,SwDown;setformodeswitchpressed(down)JRRMtrScalejFlags,ChkPrcnt;ifnotsetforAlt,thensldpaheadRESMtrScale,Flags;setforAlt0/o,sochangetoBatt%;CLRDspPcnt;preparetoshownew%(notadjustold%)JPChkRateChkPrcntJRRMtrUnits,Flags,ChkAlt;ifsetforvolts,thenskipaheadRESMtrUnits,Flags;setforBatt%,sochangetovoltsJPChkRateChkAltSETMtrUniteJF〗ags;setforvolte,sochang^to%;.IFCNEShoOff;assemblenextlineonlyifnotdebugging;JRSChMode,Flags2,ChkRate;don'tsetforAltifcharging;,ENDC.IFCShoOff;assemblenextlineonlyifdebuggingSETMtrScale,Flags;setforbatt,sochangetoaltRESWaitOP,Flags2;settostopwaitingforbattery%.ENDC;CLRDspPcnt;preparetoshownew%(notadjustold%)ChkRateCALLShoMtrMode;Meterunitsaresetbeforerate.IFCEQDEBUG;assemblenextlineonlyifdebuggingJRRSwOff,SwDowi^SkpSw;skipRateandTypeswithifSwOffissetJPChkSwRET;Otherwise,justexitSkpSw.ENDCJRRRateSw,DRC,RateDown;Ifswitchisbeingpressed,skipaheadRESRateSw,SwDown;setforRateswitchnotpressed(up)JPCKkfType;Rateswitch加tpressed,socheckTypeRateDownRESMe,Flags3;setfornotidleJRRRateSw,SwDown,ClingRate;Ifswitchwasreleased,thencheckitJPChkType;Othenvise,skipaheadtoTypeSwitchChngRate;changeChargeRateSETRateSw,SwDown;setformodeswitchpressed(down)JRSChMode,Flags2,ChkCM;skipaheadifalreadyChargermodeSETCrank,Flags"..otherwisetemporarilysetCrankflagRESDisable,DRBbuf;enabieoutputafterRateispressedJRRMtrScale,Flags,ChkCM;skipaheadifnotsetforAlt%;CLRDspPcnt".otherwise,don'tuseAlt%forchargeRESMtrScale,Flags;setforBatt%(notAlt%)whennottesterChkCMSETChMode,Flags2;setforCharger(nottester)ModeJRRCrank,Fiags,ChkSlow;ifnotsetforCrank,checkforSlowRESCrank,Flags;clearCrankbitofFlagsRESRate,Flags;wasCrankssosetforSlowJPModeChange;gotoendofCheckSwChkSlow;ifsetforSlow,thensettoFastJRSRate,Flags,ChkES;IfnotSlow,thenmustbeFastSETRate,Flags;setChargerateforFastJPModeChange;gotoendofCheckSwChkES;wassetto&ast,sosetforCrankRESRate,Flags;setFlagsforSlowSETCranfcjFlags;setChargerateforcrank(Boost);SETChMode,Flags2;SetChargertostoptestermode;RESMtrScale,Flags;setforBatt%(notAlt%)whennottesterCALLSetReg;setbatterytypeforRegular;RESDisable,DRBbuf;enableoutput;RESLoPw,Flags2;turaoffoutputCALLTurnOff;low&highpowerandfanoff,mindutyCALLShowCrank;turnONCrankLEDLDICurentSS,CrankSS;setChargestatetoCrankCALLIniTime2;resettimer2LDISECs2,003h;setTimer2for3secondsJPChkSwRETChkType;ifGel/AGM,thensetforRegularIRRTypeSw,DRC,TypeDown;IfSwitchisbeingpressed-skipaheadRESTypeSw,SwDown;setforTypeswitchnotpressed(up)JPCbkSwRET;Typeswitchnotpressed,soexitCheckSwTypeDowaRESIdle,Fags3;setfornotidleJERTypeSw,SwDown,ChngType;IfSwitchwasreleased,thencheckitJPChkSwRET;Otherwise,justexitChngType;changeBatteryTypeSETTypeSw,S"wDown;setformodeswitchpressed(down);SETChMode,Fl吗s2;setforChargerMode;RESMtrScale,Flags;setforBatt%(notAlt%)whennottester;RESDisable,DRBbuf;enableoutputafterTypeispressedJRRBatTypeB,Flags,ChkBT2;IfnotsetforGel/AGM,checlcforRegularCALLSetReg;setbatterytypeforRegularJPTypeChange;gotoendofCheckSwChkBT2;ifRegular,thensetforDeepCycleJRSBatTypeA,Flags,ChkBT3;IfnotsetforRegular,mustbeDeepCyckSETBatTypeA,Flags;setbatterytypeforDeepCycleRESBatTypeB,Flags;setchargemodeforautomaticJPTypeChange;gotoendofCheckSwChkBT3;咖stbeDeepCycle,sosetforGel/AGMSETBatTypeB,Flags;setchargemodeforGel/AGMRESBatTypeA,Flags;setbatterytypeforRegularTypeChangeI^BSCrankjFlags;setchargeratefornon-BoostCALLShowType;tunionbatteryTypeLEDModeChangeRESCrank^Flags;clearCrankbitofFlagsLDICurentSS,OOOh;restartchargingChkSwRETRET;*ThisroutineturnsthecoolingfanON.FanONiscalledduringoneof*;*thefollowingconditions:*;*I.Startofcharge(endofState2)*;*2,Startofboost(State16)*;*3.IfOFFSET<ffiOff-3inMaintain(State14)*;*4.ManualMode(State15)**5.States4,5,11,12,and13***:*Thefanwon'tbeturnedonifFreshBV<9V*FanONLDATemp,A;saveAccumulatorLDA,FreshBV;Getlatest1/4secondaveragevoltageCPlA,Volts09;checkfor9.0VJRCFanONx;leavefanaloneif<9.0vLDI入OOOl0000b;updateAccumulatorfrombufferLDDRC,A;updateportfromAccumulatorFanONxLD入ATemp;restoreAccumulatorRET;*FANOff*;*Thisroutineturnsthecoolingfanoff.FanOffiscalledduringoneof;*thefollowingconditions:*;*1.Beforestartofcharge(State0)*,2.StartofAbort(State8)*;*3.BeforestartofMaintain(State14)*;*4.IfOFFSET=HiOffinMaintain(State14)*;*5.Ifbatteryvoltagedropsbelow8.867V*FanOff;LDATe迈p,A;saveAccumulator;LDIA,00000000b;updateAccumulatorfrombuffer;LDDRC,A;updateportfromAccumulator;LDA,ATemp;restoreAccumulatorCLRDRCRET;*ShutOff*;*Thisroutinesetsthechargerfornooulputbyturaingofftheoutput',*FETs'turningoffthefan,settingthePWMforminimumdutycycle,(HiOFF),andsettingitfornon-boostmode.*■**:*T咖Off*;*Thisroutinesetsthechargerfornoou中utbyturningofftheoutput*,*FETs,turningoffthefan,andsettingt£ePWMformioi迈腿duty*;*cycle(HiQFF).TumOffisactuallypartofShutOff.*ShutOffRESCrank^FIags;setchargeratefornon-Boost<table>tableseeoriginaldocumentpage69</column></row><table>clocksiDECMSECs2;decrementmillisecondcounterJRZDOMSECs2JPCLOCEXITDOMSBCs2LDIA,MSINIT;restartmillisecondcounter;LDMSECs2,A;SETMSEC,TicFlag2;setmillisecflagDECSECs2;decrementsecondcounterJRZDO—MINs2JPCLOCEXITDO—MINs2SE亍SEC,TicFkg2;setsecondexpiredflagLDISECs2,Sednit;restartsecondcounterDECMINs2;decrementminutecounterJRZDO—HRs2;checkforoverflowjpclo5exitDO—孤s2SE亍MIN,TicFlag2;setminuteexpiredflagLDIMINs2,MINTNIT;restartminutecounterDECHRs2;decrementhourcounter腿ZCLOCEXIT;clieckforoverflowSET孤,TicFlag2;sethourexpiredflagCLOCEXITRETINITIALIZETIMERl*Subroutinetoinitializetimer1IniTimelLDIMSECsl,MSINITLDISECsl,SecInitLDIMINsl,MININITCLRHRslCLRTicFlaglRETINrnALIZETIMER2*SubroutinetoinitializeTimer2IniTime2LDIMSECs2,MSINITLDISECs2,SecInitLDIMINs2,MININITCLRHRs2CLRTicFlag2RET*DIVIDEBY2**SubroutinetodividethenumberinAby2.Theremainder,ifany**willbeavailableinthecanybituponreturn.*;dividebytwobyshiftingleft8times;tocmghCARRYbitDIVIDEBY4*'SubroutinetodividethenumberinAby4.Divide4SLAA;dividebytwobyshiftingleft7timesRLCA;throughCARRYbitRLCARLCARLCARLCARLCAANDIA,01111111b;dropMSBRET*ATimes5**Subroutinetomultiplytheaccumulator(A)by5.**Atimes5迈ultplies入by4byshiftinglefttwicethenaddingthe*originalvalueofA:(A*4)+A=A*5*ATimes5LDATemp,A;ATemp=A_ADDA,A;A=A+A=A*2ADDA,A;A=A+A=ATemp*4ADD夂ATemp;A=A+ATemp+ATemp*5RET*VOLTAGEREGULATION**ThissubroutinewilladjustthevalueofOFFSEToncepersecondto**controlthecurrentandmaintainthevoltagedeterminedbyMaintVoit.;Vo欣eg.IFCEQShoReg;asse迈blenextlineonlyifdebuggingLDA,OFFSET;getlatestOFFSETLDTEMP1,A;storelatestOFFSETinTEMP1.ENDCCALLCheckDip;checkfordipinbattvoltageDECWent;decrementintervalcounterIRZVReg0;Yes:也entimetoadjustJdAAAAAAAAl,ss虹虹虹虹虹虹虹sJPVRegEXIT;No:thennottimetoadjustVReg_0;adjustoffsetLDIVRcnt,MSINIT;re-initializeinitervalcounter(Isec)CALLGetDrop;getcabledropLDA,FreshBV;getbatteryvoltageSUBAVdrop;adjustAforcabledropDECA;adjustAforcomparisonCPA,MaintVolt;comparewithsetvalue+1JRCVReg—1;notgreaterthan,testiflessthanLDA,OFFSET;greaterth叫getphasedelayvalueINCA;CPIA,HiOff+l;testifathighlimitJENCVReg—3;atthelimit,don'tchangeOFFSETVReg—4LDOlFSET,A;updateOFFSETVReg—3JPV^6gEXrr;doneforthispassVReg—1CPAJvlaintVolt;comparewithsetvalueJRNCVRegEXIT;notlessthan,justexitLD入OFFSFT;lessthan,getphasedelayvalueDECA;CPI入MinOff;testifatlowlimitJRNCVRe^4;notatthelimit,updateOFFSETVRegEXIT;thenextsectionlightsLED'sfordebugging.IPSEQShoReg;assemblenextlinesonlyifdebuggingLDA,OFFSET;getnewoffsetCPA,TEMP1;compareittopreviousvalueJRZ^hlegYel;turnonyellowLEDifnochangeJRCVRegRed;tumonredLEDifdecreasedCALLShowGreen;turnonGreenLEDotherwiseJPVRegDone;..,andexitroutineVRegRedCALLShowRed;tumonRedLEDJPVRegDone;...andexitroutineVRegYelLDA,CurentSS;checkcurrentstateCPIA-9;indesulphationmodeJRZVRegDone;.,.ifso,exitroutineCALLShowChgng;…otherwise,turnonChargingLEDVRegDo加.EKDCRETTIMERINTERRUPTHANDLER*ThisroutineturnstheFETsonifthepowerflagsarenon-zeroand*inhibitsthetimer.'PwrConLDATemp,A;saveAregisterIRS3LoPw,Flags2,PCon;skipaheadifchargerisonPCo汪RESPWMlo,DRBbuf"..otherwise,shutoffoutputSETFWMhi,DRBbuf;…shutoffhighpowerJPPwrExit;notcharging,leaveFETsoffPConLDA,OFFSET;otherwise,checkOFFSETJRSHiPwr,Flags2,PCHP;skipaheadifinhighpowermodeJRSNoOff,Flags2,PConO;alsoskipaheadiffoillowpowerCPIA,HiO任;hasOFFSETreachedthemaxJRCPConO;ifnot,turnFETsonJPPCoff"..otherwise,shutoffoutputPCHPJRSNoOff,Flags2,PwrC2;skipaheadiffoilhighpowerCPIA,HiOff;hasOFFSETreachedthemaxIRCPwrC2;ifnot,turnonhighpowerSETPWMhi,DRBbuf"..otherwise,shutoffhighpowerJPFConO;...butturnonlowpowerPwrC2RESPWMhi,DRBbuf;0atPWMhisetsP丽tomaxpowerPConO;setforfoillowpowerSETPWMlo,DRBbuf;1atPWMloturnsoutputFETsonPwrExitLDA,DRBbuf;updateportfro迈bufferLDDRB,A;sendtohardwareLDITSCR^00010101b;resetTSCRandinhibitinteruptCALLRstWDR;resetwatchdogtimerLDIAfULLTIME;TCRisreloadedherefor1fiillcycleLDTCR^A;settitner(ontime)forFULLTIMELDITSCR,01011101b:'reloadprescaler幼dstarttimerSETNMTnt,Flags2;tellExitMainthiswastimerinteruptPCexitLDA,ATemp;restoreAregisterRETIA/DINTERRUPTHANDLER*ThisistheAtoDinterruptserviceroutine.Theonlythingitdoesis*:cleartheinterruptbitandwakestheprocessorupfromitswaitmode,*ADINTKES7,ADCRLDA,ADRRETI*NON-MASKABLEINTERRUPTHANDLER**ThisistheNMIinterruptroutine.TheNMIisgeneratedonthefalling**edgeoftheflillwaverectifiedAClinevoltage.Aninterruptis**generated120timespersecond,onceevery8.333ms.AftereachNMI,**thisroutineperformsthefollowingsteps.**i.Resetthewatchdogtimerandsave&eregisters.**2.TurnofftheFETs(unlessOFFSET-0andLoPwroO).**3.SettheinterrupttimeraccordingtoOFFSET.**4.ResetNMIntsoExitMainknowsit'sanNMI(nottimerint).**5.Updatetheclocks.**6.Restoretheregisters.**Ifturnedoff,theFETswillremainoffforaperioddeterminedby*;*OFFSET.TheTimerwfflthentriggeraninterruptwhichtellsPwrCon;*toturntheFETsbackonifnecessary.*,*承(T一TIMERCALLRstWDR;resetwatchdogtimerLDATemp,A;saveAregisterLDA,X;getXregisterLDXTEMP,A;saveXregisterJRSLoPwr,Flags2,IT—LP;skipaheadiflowpowerisonIT—OFF—r!sPWMlo,DRBbuf"..otherwise,shutoffoutputSETPWMhi,DRBbuf;...shutoffhighpowerJPIT一NoTmr;...andjumptoendofroutineIT—LP-J^"SHiPwr,Flags2,IT—HP;skipaheadifHighpowermodeSETPWMhi,DRBbuf""..otherwise,shutoffPWMhiJRSNoOff,Flags2,IT_FLP;skipaheadifnoofftimeLDA,OEFSET;...oSerwise,getlatestoffsetCPIA,MinOfFH;isitatmin(nearlyfoilon);CPIAMinOff;**temp**JENCIT—MIN;ifnot,continueandshutoffJPIT—FLP;otitierwise,leaveONandskipaheadR^SP窗lo,DRBbuf"..otherwise,shutoffoutputJPSetOff;...andjumptoendofroutineIT—HPJ^"SNoOff,Flags2,IT—FHP;skipaheadifnoofftimeSETPWMhi"RBbuf"..otherwise,shutoffPWMhiSetOffCALLC腿iOff;clieckformaxOFFSET(P額Mlo均JRNCIT—ChkHP;ifso,checkforHighPowermodeJPIT—OS"..otherwise,skipahead&setoffsetIT—Ch^HPJ^SHiPwr,Flags2,IT—FLP;ifHighPower&HiOff,setforfoilLPJPIT—OFF"..otherwise,shutoffoutputIT—Fl61;FullHighPower(Boost)rSsPWMhi,DRBbuf;turnonhighpowerPWMSETP駕lo,DRBbuf;加moutputFETsonJPIT—NoTmr;skipaheadandshutoffTIMERIT—FlS;FullLowPower(Fast)S豆TP觀lo,DRBbuf;tumoutputFETsonSETPWMhi,DRBbuf;...shutoffhighpowerIT—NoTmrL5lTSCR,00010101b;resetTSCRandinhibitTIMERinteruptJPIT一TMRIJ5TC民A;loadthecounterwithcurrentof&etLDITSCR,01011101b;reloadprescaler(32)andstarttimerIT一TMRL5A,DRBbuf;updateportfrombufferLDDRB,A;sendtohardwareRESNMInt,Flags2;tellExitMainthiswasNMIinteruptCALLCLOCKS;updateclocksLDAXTEMP;restoreregistersLDX,ALDA,ATempRETI*ROMDATAWINDOWforTHIRDVOLTSLEDDIGIT**Thefollowingbitpatternsareusedtodisplaytheindicatednumbersas:*thethird(leastsignificant)digitofthevoltagedisplay.*.block16-$%16DigitsOVx;patternsforDigiDatl-Digit1(LSD)&decimalpoint■byte00010010b;dispky一Ofor00h,byte011〗1110b;dispky二lfor01h.byte01111110b;display_1for02h.byte00110001b;display—2for03h.byte00111000b;display—3for04h.byte00111000b;display^3for05h.byte01011100b;display^^4for06h.byteIOOllOOOb;display二5for07h■byte10011000b;display二5for08h■byte10010000b;display二6for09h.byte00111110b;display二7forOAh,byte00111110b;display—7forOBhbyte00010000b;display二8forOCh.byte00011000b;display二9forODh.byte00011000b;display一9forOEh*ROMDATAWINDOWforTHIRDLEDDIGIT**Thefollowingbitpatternsareusedtodisplaytheindicatednumbers:*thethird(leastsignificant)digitontheLED..block16-$%16Digits00xpatternsforDigiDatl-Digit1(LSD)&decimalpoint,byte00010010bjbitpatterntodisplay一0byte0111111Ob;bitpatterntodisplay一1.byte00110001b;bitpatterntodisplay—2,byte00111000b;bitpatterntodisplay—3,byte01011100b;bitpatterntodisplay__4,byte10011000b;bitpatterntodisplay—5■byte10010000b;bitpatterntodisplay一6,byte0011111Ob;bitpatterntodisplay一7,byte00010000b;bitpatterntodisplay—8,byte00011000b;bitpatterntodisplay一9*ROMDATAWINDOWforSECONDLEDDIGIT**Tliefollowingbitpatternsareusedtodisplaytheindicatednumbersas:*thesecond(middlesignificant)digitontheLED.*.block16掘6Digits0x0;patternsforDigiDat2-Digit2(middledigit)andMS1byte00000101b;bitpatterntodisplay_0_byte11001111b;bitpatterntodisplay二l二byte0010001lb;bitpatterntodisplay二2二.bytelOOOOOllb;Wtpatterntodisplay=3二byte11001001b;bitpatterntodisplay二4二.byte10010001b;bitpatterntodisplay二5—byte00010001b;bitpatterntodisplay:6二.byte1100011lb;bitpatterntodisplay_7—byte00000001b;bitpatterntodisplay=8二.byte10000001b;bitpatterntodisplay二9—*ROMDATAWINDOWforOulputCableVoltageDrop**ThefollowingvaluesaretheOFFSETvaluesatwhichVdropisadjusted.*ThevalueofOFFSETisaroughindicationoftheoutputcurrent,which**isdirectlyrelatedtothevoltagedropintheoutputcable.*.block16-$%16DropOffs;OFFSETVdropPowerCurrentbyte0FFh;00Low>0.0A■byte005h;01Low>12A(Maxlowpower)Low>12ALow>12ALow>12ALow>12AHigh>12A(Minhighpower)High>15AHigh>17AHigh>22A.byte005h;02.byte005h;03byte005h;04byte005h;05.byte0FFhj06byte0A6h;07.byte0A2h;08.byte0柳;09byte095h;OAHigh>25A.byte08Fh;0BHigh>27A.byte08Bh;0CHigh>29A.byte087h;0DHigh>30A.byte082h;0EHigh>32A;,byte07Fh;OFHigh>33A(Maxhighpower);.byte070h;0EHigh>30.3A;.byte069h;OFHigh>32.4A*ROMDATAWINDOWforAlternatorChargeinPercent**ThefollowingvaluesarethePercentvaluesforthealternatorvoltages**listedbelow.Thesenumbersareonlyusedwhenthechargerisin**Testermode.Voltageslowerthanthefirstentryaredisplayedas0%**charged.Voltagesabovethelastentryaredisplayedas199%charged..block32-$%32AltLvs;%VolteHex.byte013.53CBred.byte12;13.60CC|byte25;13.67CD|.byte38;13.73CEred.byte50;13.80CFyellow,byte62;13.87DO|.byte75;13.93Dlyellow.byte85;14.00D2green.byte92;14.07D3|.byte97;14.13D4|.byte100;14.20D51.byte100;14.27D6|.byte100;14.33D71.byte100;14.40D8|.byteWO;R47D9jbyte100;14.53DA|.byte100;14.60DBj,bytel03;14.67DCj.byte110;14.73DD1byte120;14.80DEgreen,byte130;14.87DFyellowbyte140;14.93EO|.byte150;15.00Elyellow.byte160;15.07E2red.byte170;15.13E3|.byte80;15.20E4i.byte190;15.27E5j.byte196;15.33E6red.byte199;15.40E7redInterruptvectors.orgOFFOhADCJPADINTTIMERJPPwConINT2NOPRETInmijprr一t應Rrstjpreset-1000-P8.asm:ChecksumRawCode:76C48W他Info:748A5COPYRIGHT2003SCHUMACHERELECTRIC*AIXRIGHTSRESERVED*WRITTENBY*THOMASF.JOHNSON**SchumacherHighFrequencyAutoCharger/Starter*ThiscodeisfortheSGS-THOMPSONmicro-controlerPartnumberST62T15/ST62E15/ST62T25/ST62E25*.title"lOOOOAVer.0.66"丄INESIZE131..vers"ST6225".ro咖ize4.W一ONDEilrG.SET1;1ShoOff.SET1;1-ShoReg.SET;1>normal,0->IgnoreTypeandRateswitchesafterSS5normal,0->ShowOFF§ETAlt%modeduringcharging—,■normal,0->FlashLED'stoindicateup/downchangeFastCP.SET1;'1->normal,0->3minChkProgintervalinsteadof60minDefinetheporthardwarelocations*Attimes,the.defstatementisfollowedbyavalueand"!m".The!m:*isusedbythesimulator/emulatorfordebugging.Thissymboltellsthe*equipmentwhatregisterstheuserwantstomonitorduringdebuging.X.def80h!mY.def81hV.def82hW.def83h;Indexregister;Indexregister;Shortdirectregister;ShortdirectregisterA.defOffh!迈;AccumulatorDRA,defOcOh!mDRB.defOclh!mDRC.def0c2hi)DRA.def0c4hDDRB.def0c5hDDRC.def0c6hORA.defOcchORB.defOcdhORC.defOceh)Portadataregister;Portbdataregister;Portcdataregister;Portadirectionregister;Portbdirectionregister;Portcdirectionregister;Portaoptionregister;Portboptionregister;PortcoptionregisterADR,defOdOh!迈ADCR,defOdlhi>SC.def0d2hTCR,def0d3h!mTSCR,def0d4hV/DR.def0d8hik)R.def0c8h!mDRWR.def0c9h;A/Ddataregister;A/Dcontrolregister;Timerprescalerregister;Timercounterregister;Timerstatuscontrolregister;WatchdogregisterjInterruptoptionregister;Dataramwindowregister*Thesearetheramequatesusedbythebatterycharger,DRAbuf.def084h;shadowramforportAdataregisterDRBbuf.def085h;shadowramforportBdataregisterDRCbuf,def086h;shadowramforportCdataregisterATemp.def087h;AccumulatortemporarystorageXTEMP,def088h;XregistertemporarystorageMSECsl.def0柳;storagefor8.333咖tics-countof120=1secSECsl,def08Ah;storagefortimerlsecondsMINsl.def0犯h;storagefortimerlminutesHRsl.def08Ch;storagefortimerlhoursTicFlagl,def08Dh;overflowflagsforSECsl,MINsl,andhoursMSECs2.def08Eh;millisecondonecounterSECs2.def08Fh;storagefortimer2secondsMINs2.def090h;storagefortimer2minutesHRs2.def091h;storagefortimer2hoursTicFlag2.def092h;overflowflagsforsecsl,MINs2,andhours1Tries.def093h;usedbybatterydetectroutinesTEMP.def094h;scratchpadareaTEMPI,def095h;scratchpadareaTemp2,def096h;countusedforFreshBVCurVoh.def097h;currentbatteryvoltageMaintVolt.def098h;storageforMAINTAINvoltagelevelOldVolt.def099h;previousbatteryvoltage,usedfordv/dtCCDcnt.def09Ah;displaycountdownduringcrankcooldownOldOff.def09Bh;oldvalueofOFFSETusedindl/dtBADlo,def09Ch;lowbitsbatteryvoltageaverageBADhi.def09Dh;hibitsbatteryvoltageaverageV咖x,def09Eh;maximumbatteryvoltage(perBatteryType)Vref,def09Fh;refvoltagefordesulfationOFFSET.def0A0h;storageforphasedelayvalueFreshBV.defOAlh;avgbattvoltusedfordi/dtrefFBVTotLo,def0A2h;lowbyteoftotalusedforFreshBVFBVTo但i'drf0A3h;higtibyteoftotalusedfoTFreshBVCurentSS.def0A4h;storescurrentchargerstateFlags.def0A5h;chargerconfigurationstates;bit0(BatTypeA):(0forReg,forD/C);bit1(BatTypeB):(0forNorm,1forAGM/GEL);Ut2(Rate):(0forSlow,1forFast);bit3(Crank):1ifinBoostmode;bit4(CrankWait):1duringE/Scooldown;bit5(Started):1ifchargingstarted;bit6(MtrUnits):(0forVolts,1for%);bit7(MtrScale):(0forBaA1forAlt^Flags2.def0A6h;storesthefollowingFlags;6it0(Batt):1ifbatteryconnected;bit1(Rapid):1ifsetforRapidchargerate;bit2Oat6V):1ifsetfor6Vbattery;bit3(Relay):1ifoutputrelayisclosed;bit4(NMInt):1ifNMIinterrupt^0ifTimer;bit5,ChMode):1ifinChargerMode;bit6(Wa"0P):1ifwaitingfor%tochangefrom0;bit7(Alert):1indicatesAlertconditionFlags3.def0A7h;storesthefollowingFlags;bit0(Rropng):1duringHapid->Fasttransition;bit1(Settle):1duringvoltagesettletime;bit2(Rjcaplnt):1during1sthalfofeachRampintervaljbit3(idle):1untilabuttonispressed;bit4(RampUp):0->rampingdown,i->rampingup;bit5(NxtCnt):1->1stsecondofcount;bit6(Maimal):1ifinManualMode;bit7(Burnln):1ifinBurn-inModeSwDown.def0入8h;Indicatesstateofswitches(l->pressed);bit3(SOC):1ifatstartofcharge(1st5s);bk4《SwOff):IwhenigoringType&Rateswitch(debug);bit5-Typeswitch;bit6-Rateswitch;bit7=MeterswitchDigiDat2.def0A9h;datafor8of16segmentsofdigitalLED(0->ON,l->off);bit0=digit3segmentsB&C;bit1=digit2segmentF;Wt2-digit2segmentG;bit3=digit2segmentA;bit4-digit2segmentB;bit5=digit2segmentC;bit6-digit2segmentD;bit7-digit2segmentEDigiDatl.def0AAh;datafor8of16segmentsofdigitalLED(0->ON,1->off);bit0=digit1segmentC;bit1=digit1segmentG;bit2-digit1segmentD;bit3-digit1segmentE;bit4=digit2decimalpoint;bit5-digit1segmentF;bit6=digitIsegmentA;bit7=digit1segmentBSwData.defOABh;dataforthe3Rateand3TypeLBDs(0->ON,l->o坊;bit0-6VbatterytypeLED;bit1=RegbatterytypeLED;bit2-D/Cbatteryt^peLED;bit3=AGMbatteiytypeLED;bit4=40AchargerateLED;bit5=15AchargerateLED;bit6=I00AchargerateLED;bit7=2AchargerateLEDBitCnt.defOACh;IndexofbitsenttodisplayBytCnt,defOADh;IndexofwordsenttodisplayDataBuf.defOAEh;TempstorageforDatabitsVltCnt.defOAFh;CounterforvoltagedisplayintervalLastBatt.def0B0h;storesbatteryreadingusedtomonitorprogressRmpCnt.defOBlh;countsrampintervalsuntilnextrampLEf)num.def0B2h;storesnumbertobeshownondigitalLBDPercent.def0B3h;storespercenttobeshownondigitalLEDIndex.def0B4h;usedforlookuptableaccessVdrop,def0B5h;estimateofvoltagedropinoutputcableYRcnt,def0B6h;CounterforvoltageregulationintervalPcntL.def0B7h;NMIcounterforpercentdisplayupdatePcntH.def0B8h;IntervalcounterforpercentdisplayupdateDspPcnt.def0B9h;storageforlastpercentdisplayedFlags4.def0BAh;storcsthefollowingFlags;bit0(IdleSet):1if10minuteIdletimerwasstarted;bit1(MinOut):1whenminrateisneededforVoltReg;bit2(RlySw):1toosoontoswitchrelay;bit3(RlyC〗s):1ifrelaywasclosed;bit4〖VRlmt5:1ifVoltReglimitreached;bk5(HiPwrj:1ifchargerate>Fast;bit6(Hi6V):1ifbattery>8,5V;bit7(IPSlo):1ifinternalpowersupply<18VCurIPS.def0BBh;storageforcurrentinternalpowersupplyvoltageIPSref.def0BCh;storageforoldinternalpowersupplyvoltageORJBbuf.def0BDh;shadowRAMforORBregister;free.def0BEh;fi:ee;free.def0BFh;free;OBFh=lastRAMlocation:Thesearetheconstantsusedbythebatterycharger.Vo謹l.equOOIh;0.067VOLTSVo謹2.equ003h;0.2VOLTSVolts004.equ006h;0.4VOLTSVoits005.equ008h;0.5VOLTSVolts006,equ009h;0.6VOLTSVolts0.equOOAh;0,7VOLTSVolts008.equOOCh;0.8VOLTS<formula>formulaseeoriginaldocumentpage82</formula><formula>formulaseeoriginaldocumentpage83</formula>MeterSw.equ007h;Meterswitch-PORTCSOC.equ003h;bitinSwDown:1duringStartOfCharge(1st5sec)SwOff.equ004h;bitinSwDown:1fordisabledType&RateswitchesBatTypeA.equOOOh;bitinFlagsforbatterytype:0-Reg,1=D/CBatTypeB.equOOlh;bitinFlagsforbatterytype:1=AGM/GelCellRate.equ002h;bitinFlagsforchargerate:0=Slow,1-FastCrank'equ003h;bitinFlagsthatindicatesenginestartCrankWait'equ004h;bitinFlagsthatindicatescooldownbetweencranksStarted,equ005h;bitinFlagsthatindicateschargestartedMtrUnits.equ006h;bitinFlagsformeterunits:0-volts,1=%MtrScale.equ007h;bitinFlagsformeterscale:0=batt,1=altmtrBatt.equOOOh;bitinFlags2:1ifbatteryisconnectedRapid.equOOlh;bitinFlags2:1ifchargerateisRapidBat6V.equ002h;bitinFlags2:1ifbatterytypeis6VRelay,equ003h;bitinFlags2:1ifoutputreiayisclosedNMInt.叫u004h;bitinFlags2:1ifNMIinterrupt,0ifTimerChMode.equ005h;bitinFlags2:1ifinChargermode(notTester)WaitOP.equ006h;bitinHags2:1ifbattery>10VAlert.equ007h;bitinFlags2:1indicatestroubleRmpng.equOOOh;bitinFlags3:1duringRapid->FasttransitionSettle.equOOlh;bitinFlags3:1duringvoltagesettletimeRmplnt.equ002h;bitinFlags3:1during1sthalfeachRampintervalIdle,equ003h;bitinFlags3:IuntilabuttonispressedRampUp,equ004h;bitinFlags3:0->rampingdown^1->rampingupNxtCnt.equ005h;bitinFlags3:0duringlasthalfofCCDcntintervalManual.equ006h;bitinFlags3:1duringManualmodesBurnln.equ007h;bitinFlags3:1duringBurn-InmodeIdleSet.equOOOh;bitinFlags4:1if10minuteIdletimerwasstartedMinOut.equOOlh;bitinFlags4:IwhenminrateisneededforVoltRegRlySw.equ002h;bitinFlags4:1whentoosoontoswitchrelayRiyCls.equ003h;bitinFlags4:1whenrelaywasclosedVRlmt,equ004h;bitinFlags4:1ifVoltReglimitreachedHiPwr.equ005h;bitinFlags4:1ifchargerate>FastHi6V.equ006h;bitinFlags4:1ifbattery>8.5VEPSlo.equ007h;bitinFlags4:1ifinternalpowersupply<18VCrankOff.equ120;crankofftimeinseconds(120)CrankON.equ005h;crankontimeinseconds(5)CCDint,equOOlh;crankcooldowndisplaycounterinterval(seconds)CrankSS,equ010h;crankSSisstate16=10hexDecimal,equ004h;bitinDigiDatlfordecimalpointDigitl.equ000h;bitinDigiDat2formostsignificant1SwsOff.equ1111111lb;bitpatternforallswitchesoffDigiOffa.equ11111111b;bitpatternforallsegementsoffDigiOffb.equ11111111b;bitpatternforallsegementsoffDigiONa.equOOOOOOOOb;bitpatternforallsegementsONDigiONb,equOOOOOOOOb;bitpatternforallsegementsONDashesl,equ11111101b;bitpatterntodisplay—-Dashes2.equ11111011b;bitpatterntodisplay—-—DigiRevl.叫u00010000b;bitpatterntodisplaf二8,DigiRev2.equ01100001b;bitpatterntodisplay]^—;.org0880h;forST6210/5.org0100h;forST6220/25RESETCALLRstWDR;resetwatchdogtimerRAMCLRLDIX,084h;pointXto1stRAMLocationRAMCLR1CLRA;clearALD(X),A;storeAatlocationpointedtobyXINCX;incrementXLDA,X,'getpointerinACPIA,0C0h;testforendofRAMJRNZRAMCLR1;doagainifnotfinishedNowSetUpTheHardwareI/OPortsPORTA;Bit0=LED-Done(Output,0=ON);Bitl=LED-Charging(Output,0=ON);Bit2=LED-Alert(Output,0=ON);Bit3=LED-Battery%(Output0=ON);Bit4=LED-VoltsDC(Output,0=ON);Bit5=LED-Altmtr%(Output0=ON);Bit6=SerialData(Output0=ON);Bit7=DisplayClear(Output,0=clear);B诚76543210LDIDDRA,11111111b;SetallbitsasoutputsLDIORA,1lOOOOOOb;open-drainoutputs0-5;6-7push-pullLDIDRA,1111111lb;Setinitialvaluesto1(o坊LDIDRAtmf,l1111111b;storesettingsinshadowRAMPORTB;Bit0=Shiftclock(Output,0->I=Shift);Bit1=Latchclock(Output,0->l=Latch);Bit2=Relaycontrol(Output50=open,l=closed);Bit3=Disableout(Output,l=disabled);Bit4=SCRcontrol(Output,0=Off,l=ON);Bit5=BattVoltage(J[nput,Analog);Bit6=IritVoltage(Input,Analog);Bit7=0A-100APWM(Output,0=0A,1=100A);Bi睹76543210LDIDDRB,1001111lb;bits5&6areinputs,othersareoutputsLDIORB,00111111b;Setpush-pulloutputs*,analoginput;*bit7isopendrainoutputLDIORBbuf,OO11111lb;storesettingsinshadowRAMLDIDRB,11101011b;Setpush-pulloutput-inputs-0LDIDRBbuf,l110101lb;storesettingsinshadowRAMPORTC;Bit4=FanControl(Ouput,0-off,1-ON);Bit5=Typeswitch讧nput,0=IN/daange);Bit6=Rateswitch(Input,0=IN/change);Bit7=Meterswitch(Input,0=IN/change);Bit#76543210LDIDDRC,00011111b;bit4isoutput,othersareinputsLDIORC,00011111b;non-interruptinputs,push-pulloutputLDIDRC,00001111b;Setinternalpull-upsforbits5-7LDIDRCbuf,0000111lb;storesettingsinshadowRAMTSCRINITLDITSCR^00010101b;resetTSCRandinhibitinteruptSET4,IOR;enableinteruptsRETICALLInitState;initializetoslow(2A)automode;ThenextthreelinesaretosetthemaximumidletestertimeCALLIniTimel;initializetimer1LDIMINsl,0Ah;settimer1for10minutesSETIdle,Flags3;indicatesnobuttonspressedyet;ThenextthreelinessettheunitforTester(notCharger)modeRESCfaMode,Flags2;setforTesterModeCALLShowDatainitializedisplayINIT一Ol;JP]^AIN;debugTestRoutines*:Thisroutinecheckstheswitchesatpoweruptodeterminewhetherto:enteroneofthetestmodes.Thepossibletestmodesandtheswitch*:combinationsthattriggerthemareasfollows.*:MeterRateTypeTestMode*:YxNPowerOnSelfTest(POST):LED'slightinsequence*:NYNManualSlowCharge(1hourmaxforallmanualmode)申:NNYManualMediumCharge(Fastforboostmodels)*:NYYManualFastCharge(Fast-Rapidforboostmodels)*UBurn-InMode:Past/RapidChargefor199minutes*:Y->pressed,N->notpressed,x->either(notchecked)*TESTJRSMeterSw,DRC,NoPOST;SkipaheadifdisplaymodebuttonnotpressedJRSTypeSw,DRC,POST;SkiptoPOSTifTypebuttonnotpressedJPTestBI".'otherwise'skipaheadtoBum-InsetupNoPOSTCALLFi他Second;waito加fi池secondJRRRateSw,DRC,TESTl;CheckTypeswitchifRateswitchispressedJRSTypeSw,DRC,NoTest;gotoMAINifnoswitchispressed;SetforManualFastChargeSETRate,Flags;turaonFastLED,turnoffSlowLEDRESRapid,Flags2;turnoffRapidLEDCALLSetFast;settorampfromOffSafetoOffFastJPTestMMl;setforManualchargeNbTestJPMAIN;skiptestandgotoMAINTEST1;SetformanualSlowChargeJRRTypeSw,DRC,TEST2;ifTypeswitchispressed,setforFastTestLDIOFFSET,OffSlow;setOffsetfor2ACALLSetSlow;setforSlowRateJPTestMMl;setforManualchargeTestBI;Setfor60minuteBurn-InSETBumln,Flags3;SetforBurn-InmodeCALLSetFast;settorampfromOffSafetoOffFastCALLSetRmpUp;preparetorampfromFasttoRapidTEST2;setforManualRapidCh卿SETRapid,Flags2;turaonRapidLEDSETRate,Flags;setfornon-SlowrateCALLSetSafe;setOFFSETforOffSafe(5A)whenrelayclosesJRSBurnln,Flags3,TestRap;don'tsetforrampdownifBurn-InLDIVRcnt,OffSafe-OffRap;rampfromOffSafetoO孤apLDIRmpCnt,RCinit;1000.75-secondintervalsyields75seesRESHampUp,Flags3;setforrampdownCAIXSetRamp;setrampingparametersTestRapJPTestMMl;setforManualchargePOSTCALLResetLEDs;turaoffalltype,rate&StatusLED'sCALLModeO任;turnoffalldisplaymodeLED'sCALLDigitsOff;tumoff3-digitLEDRESRlyCls,Flags4;makesureoutputrelay"willbeopenCALLSetl2V;setforRegular,12VbatteryCALLHoldType;showTypeandwaitafifthsecondSETBatTypeA,Flags;tumonDeepCycle&turno任RegularLEDCALLHoldType;showTypeandwaitafifthsecondSETBatTypeB,Flags;turnonGel/AGMLEDRESBatTypeA,Flags;turnoffDeepCycleLEDCALLHoidType;showTypeandwaitafifthsecondRESBatTypeB,Fiags;turnoffGel/AGMLEDSETBat6V,FIags2;tumON6VLEDCALLHoldType;showTypeandwaitafifthsecondCALLResetLEDs;turaoffalltype,rate&StatusLED'sRESBat6V,Flags2;setfor12Vbattery(not6V)SETChMode,Flags2;咖stsetflagtoshowrateLED'sRESCrank^FIags;turnoffCrankLEDCALLSetSlow;setforSlowRateLDILED加m,SlowAmps;setdigitalLEDtoshowSlowrateCALLHoldRate;showRateandwaitafifthsecondSETRate,Flags;tumonFastLEDLDILEDrmm,FastAmps;setdigitalLEDtoshowFastrateCAIXHoldRate;showRateandwaitafifthsecondSETRapid,Flags2;turnonRapidLEDLDILEDrmm,RapAmps;setdigitalLEDtoshowRapidrateCALLHoidRate;showRateandwaitafifthsecondRESChMode,Flags2;clearflagtodisableoutputLDILEDtmm,CrnkAmps;setdigitalLEDtosiiowCrankrateCALLShowNum;getdatatosiiowtheLEDnumberCALLShowCrank;turnonCrank(Boost)LEDCALLFifthSecond;waitonefifthsecondCALLRese仏EDs;turnoffalltype,rate&StatusLED'sCALLShowData;updatedisplaySETMtrUnits,Flags;setfor%LEDsON,voltsLEDoffRESMtrScale,Fkgs;setforAlternator%LEDoffLDIDigiDatl,DigiRevl;setdigitalLEDtoshowCodeRevisionLDIDigiDat2,DigiRev2;setdigitalLEDtoshowCodeRevisionCAL3LShoMdData;updatedisplayCALLHoldMtrMd;showdisplaymodeandwaiternefifthsecondRESMtrUhits,Hags;setforVoltsLEDON,batt%LEDoffCALLHoldMtrMd;showdisplaymodeandwaitonefifthsecondSETMtrUnits,Flags;setfor%LEDsON,voltsLEDoffSETMtrScale,Flags;setforAlternator%LEDONCALLHoldMtrMd;showdisplaymodeandwakonefifthsecondCALLModeOif;tumoffdisp〗aymodeLED,sCALLAlertON;turnonAbrt(Red)LEDCALLFifthSecond(waitonefiithsecondCALLShowChgng;lightChargingLEDCALLFifthSecond;waitonefi他secondCALLResetLEDs;turnoffalltype,rate&StatusLED'sCALLShowGreen;lightGreenLEDonlyCALLFifthSecond;waitone五池secondCALLResetLEDs;turnoffalltype,rate&StatusLED'sLDILEDnum,5;initiaHzeto5toshow41stPOST2DECLEDrnmi;thenextnumberwillbe1lessCALLHoldNum;showLED加叫wait200mS,andloadintoA;CALLNumData;getdatafor,andshowLEDnumber;CALLFifthSecond;waitonefi他second;LDA,LEDnum;checkforlastnumberJRN2;POST2;loopbackandrepeatifnotthere;JRZPOST3;skipaheadifthere;JPPOST2;.otherwise,loopback&repeatPOST3ADDIA,20;adding20changes2nddigitLDLEDxmm,A;pr邻aretoshownewnumberCALLHoldNum;showLEDnum,wait200ruS,andloadintoA;CALLNumData;getdatafor,andshowLEDnumber;CALLFifthSecond;waitonefifthsecond;LDA,LEDnum;checklatestnumberCPIA,IOO;comparetolastnumberJKNZPOST3;loopbackandrepeatifnotthere;JRZPOST4;skipaheadifthere(JPPOST3;…otherwise,loopback&repeat;POST4CALLResetLEDs;turaoffalltype,rate&StatusLED'sCALLInitState;resettoSlow,TypeAchargemodeRESChMode,Flags2;setforTestermodeJPTEST;repeatPOSTifnecessaryTestMM1;Setformanua〗chargeSETManual,Flags3;setforManualmodeSETChMode,Flags2;setforChargerMode(outputenabled)RESDisable,DRBtmf;enabkoutputLDICurentSS,15;State15isManualchargeSETStarted,Flags;setFlagsforchargestartedSETRlyCls,Flags4;closeoutputrelayJKRRate,Flags,TstSlow;skipaheadifsetforSlowrateCALLFifthSecond;waitonefifthsecondCALLFstRmp;rampfromOffSafetoOffFastorOfERapTstSlowCALLIniTime1;initializeTimerlLDIHRsl,1;setTimerlforIhour;LDIMINsl,5;setTimerlfor5minutes"DEBUG**,IFCNEShoOff;assemblenextlineonlyifnotdebuggingJRRBurnln,Flags3,MAIN;skipnext2linesifnotBurn-in.ENDCTestMM2CALLIniTime2;resetTimer2,IFCNEShoOff;assembknextlineonlyifnotdebuggingLDIMINs2,1;settimerforcounterinterval(1minute).ENDCLDICCDcnt,60;setBum-inminutecounterto60BecausetheA/Dvoltageisbeingaveraged,itwouldtakeconsiderable*;*timetonoticethatabatteryhas"comedisconnected.Toovercomethis*DELAYtheprogramwillmonitortheinstantaneousvoltageeachtimethru*thelooptodetectthiscondition.Thischeckwillbemadeonlyifthe**unitisinachargingmode.*MAINCALLRstWDR;resetwatchdogtimerLDA^CurentSS;getcurrentstateCPIA:ABORT;checkforabortIRNZMainMore;continueMainifnotAbortJPMAIN3;don言tcontinueMainifAbortMainMoreJRRMal,Flags3,MainMan;contimieMainifnotManualModeJPSSI5;otherwise,gotoManualchargeMainManJRSCrankWait,Flags,MAINl;don'tclieckswitchesduringCrankwaitCALXCheckSw;clieckifswitchisbeingpressedMAIN4JRSIPSlo,Flags4,MainlPS;don'tcheckforCrankifcheckingIPSIRSCrank,Flags,MAIN0;skipaheadifduringCrankMainIPSJRSCrank,Flags,MainlPS2;don'tupdate%ifCrank&checkingIPSCALLGetPercent;updatethepercentagereadingCALLUpdateBP;update%todisplayMainlPS2CALLGetMeter;updatedisplayJRRIdle,Flags3,MAIN0;skipaheadifnotidleJRRBatt,Flags2,MAIN0;don'tcheckidletimelimitifnobatteryJRSIdleSet,Flags4,MAIN5;don'tsetidletimerifalreadysetCALLIniTimel[..otherwiseinitializetimer1LDIMNs1,0Ah;settimer1for10minutesSETIdleSet,Flags4;Idletimerstarted,setflagMMN5JRRMIN,TicFlagl,MAINO"..otherwise,checkidletimelimitRESDisable,DRBbuf;...e加bleoutputafteridletimelimitJPMAIN2;…andre-initializeifreachedMAINO;notCrankjcheckfor0or1JRSRlyCls,Flags4,M細l;chargerisON,goto0VcheckJRSLEDchgng,DRAbuf,MAIN3;chargernotalmoston,skip0Vcheck;JRRLEDchgng,DRAbuf,MAINl;chargerisalmostoil)goto0Vcheck;JPMAIN3;chargerisOFF,gotoMain3MAIN1;CheckfordisconnectedbatteryCALLCheckBatt;checkfordisconnectedbattery顶SBatt,Hags2,M扁3;skipaheadifconnectedMAIN2;0Vdetected,preparetostartoverfromstate0LDIDspPcnt,O^initializedisplayPercentto0CALLInitState;initializetoSlowRegularChargemodeMAIN3*SEQUENCESTATEJUMPTABLE**Determinewhatroutinetoexecuteonthispassthroughthetheloop.Only**oneroutineisexecutedeachtimethroughtheloop.*NSS0LDACurentSSJKNZNSS1JPSSO;*SSO-BATTERYDETECT*NSS1CPIA,001hIRNZNSS2JPSSI;*SSI-BATTERYDETECTDELAY*NSS2CPIA,002hJENZNSS3JPSS2;*SS2-AUTOMATICCHARGESTART*NSS3CPIA,003hJKNZNSS4JPSS3;*SS3-BELOW9Volts*NSS4CPIA,004h扁ZNSS5JPSS4;*SS4-BELOW12Volts*NSS5CPIA,005hIRNZNSS7JPSS5;*SS5-NORMALCHARGE*:NSS6CPIA,006hJRNZNSS7JPSS6;*SS6-dv/dtMONITOR*NOTUSEDNSS7CPIA,007hIRNZNSS8JPSS7;*SS7-waitforgoodBPSNSS8CPIA,008hJRNZNSS9JPSS8;*SS8-ABORTCHARGE*NSS9CPI入009hJRNZNSSll(JPSS9;*-DESULFATION*;NSSIO;CPIA,OOAh;JRNZNSSll;JPSSIO;*SSIO-RESTORECHARGE*NSS11CPIA,OOBhIRNZNSS12JPSSll;*SSll-dV/dtMONITOR*NSS12CPIA,OOChJRNZNSS13JPSS12;*SS12-纖MONITOR*NSS13CPIA,OODhIRNZNSS14JPSS13;*SS13-ENDCHARGE*NSS14CPIA,OOEh腿ZNSS15JPSS14;*SS14-MAINTAIN*NSS15CPIA,OOFh厕ZNSS16JPSS15;*SS15-Manual*NSS16CPIA,010h扁ZNSS17JPSS16;*SS16-CRANK*NSS17CPIA,OllhJKNZNSS18JPSS17;*SS17-CRANK*NSS18CPIA,012hJKNZNSS19JPSS18;*SSI8-CRANK*NSS19CPIA,013hJKNZNSS20JPSS19;*SS19-CRANK*NSS20CPIA,014hJRNZNSS21JPSS20;*SS20-CRANK*NSS21LDIWDR,001h;invalidsequencestate,reset*ENDOFM扁**WaitforNMI,whichindicatesendofFETonperiod,beforemeasuring*batteryvoltage.*ExitMainXMainWAIT;waitforinteruptJRSNMInt,Flags2'XMaii1;timerinterupt^READBATTERYVOLTAGE**Thisroutineisexecutedatornearzerocross.Thecurrentvoltage**isstoredinCurVoltandthereadingisaddedtoBADhi(twolocations),*BADhiwillcontainarunningaverageofthelast256readings.*BADREADLDAjBADlo;getaveragereadingSUBA,BADhi;subtractonereadingfromtherunningtotalJENCBADREAD1;nocany,goonDECBADhi;adjusthighorderbitsBADREAD1LDBADlo,A;storenewvalueLDIADCR,OBOli;startA/DconversionLDIADCR,0B0h;doagaintoinsureavalidstartWAIT;lettheinteruptnotifyuswhendataisreadyLDCurVolt,A;savecurrentreadingADDAjBAblo;addintorunningaverageJENCBADREAD2;nocarry,goonINCBADhi;incremeiLthighbitsBADREAD2LDBADlo,A;storenewlowbits;LDIORB,OlFh;LDIORB,09Fh*疆AVERAGECALCULATION**Forusebythedi/dt,aboutfourtimeseverysecondtheaverageofthe:*previous32curvoltreadingsisstoredinFreshBVforcomparisontoa:*readingtakenonceeverysecond.DIDTAVGLDA,Temp2;ifTemp2-0thenfirstreadingJKNZDIDTAVG1;skipinitifnot1streadingLDITemp2,020h;initializeTemp2to32DIDTAVG1LDA,FBVTotLo;ADDA,CurV"oIt;addcurrentvoltagetototalJUNCDIDTAVG2;don'tinchighbytsifnocarryINCFBVTotHihighbyteDIDTAVG2LDFBVTotLo,A;updatetotalDECTemp2;updateTemp2JRZDIDTAVG3;computeavgJPDIDTAVGX;exittoMainDIDTAVG3LDITemp2,003h;preparetoshift3timesDIDTAVG6LDA,FBVTotHi;loadhighbyteoftotalintoaccumulatorSLAA;shiftaccumulatorleilLDFBVTotHi,A;updatehighbyteoftotalLDA,FBVTotLo;loadlowbyteoftotalintoaccumulatorSLAA;shiftaccumulatorLDFBVTotLo,A;updatelowbyteoftotalIRNCDBDTAVG4;msbwaszero,skipnextlineINCFBVTo卸;DIDTAVG4DECTemp2;decloopcounterJRZDIDTAVG5;ifzero,finishaverageJPDIDTAVG6;notzero,shiftagainDIDTAVG5LDA,FBVTo沮i;storeaverageinFreshBVLDFres雨,ACLRFBVTotHiCLRFBVTotLoJRS7,FreshBV,DA7;skipaheadif>8.5VRES迈6V,Flags4;clearHi6VflagJPDIDTAVGX;andskiptoendofroutineDA7SETHi6Vflags4;setHi6VflagDIDTAVGXJPMAIN*Thisiswherethesequencestatesaredefined.Thenumberofagiven*sequencestatehas加relevancetotheorderinwhichitisactually4*executed.Anygivenstatecangivecontroltoanyotherstate.*BATTERYDETECT.**Thisisthechargeridlestate.Theprogramremainshereuntilabattery'*isdetected.Dectectionisdeterminedfindingapositivevoltage**greaterthanonevoltSSORESCrank,Flags;clearCrankbitofFlagsCALLShowRate;turnonchargerateLED(SloworFast)CALLShowType;tunionbatterytypeLED(Reg,D/CorGel)CALLShutOff;openrelayandsettoHiOFFLDIOFFSET,OffSafe;setOFFSETtoOfiSafeRESSOC,SwDown;dearStartOfChargeflagJRSChMode,Flags2,Ready;continueroutineifinChargerModeCALLCheckBattotherwise,checkwhethertoshowO'sJPSSOEXIT;...andexitReadyJKRStartedflags,SSOO;skipifoutputhasn'tbeenonRESStarted,Flags;setFlagsforchargenotstartedSS00LDA,FreshBV;checklatestaveragevoltageJRNZSS0一1;Isit0(exactly)CALLShowRed;tumonRe&LEDuntilbatteryisdetectedJPSSOEXIT;…Yes:mustberev.batt,sostopSSO一lCALLIniTimel;setuptimerLDISECsl,002h;adjustfor2secondsLDITries,005h;5Triesfordebo咖eSETO,CurentSS;goontoBATTERYDETECTDELAYSSOEXITJPExitMainBATTERYDETECTDELAY**Thisstatechecksthatavoltageispresentforthreeseconds.Ifthe**voltagedropsbelow1Vdc,lietimerisrestartedandthe"try"counter51*isdecremented.Ifafter5TriesthevoltagehasnotbeenaboveiVdc**for3seconds,gobacktobatterydetect.Thisdelayhastheeffectof**debouncingtheleadsbeingconnectedtothebattery,*SSICALLCheckBatt;checkforconnectedbatteryJRRBatt,Flags2,SSl一2;subtractatryifnotcomiectedJRSBatt,Flags2,SS1—1;yes,checkifithasbeentwosecondsJPSS1—2;no,subtractatrySSl一l—CALLShowChgng;turaChargingLEDonJRR2,TicFlagl,SSlEXIT;gooniftimeisup,otherwiseexitLDIOldVolt,OOOh;clearOldVoltbeforeenteringSS2LDITEMPl,OOOli;clearTempibeforeenteringSS2;LDIIPSref,000h;clearIPSrefbeforeenteringSS2INCCurcntSS;goontostartchargeJPSS1—3;settimerfor2secondsSSI—2—;NOTE:Triessetto5inSSODECTries;subtractatryJRKZSS1—3;tryagainifnottoomanyTriesDECCurentSS"..otherwise,gobacktoidle(state0)JPSS1EXIT;...andexitroutineSSI—3CALLIniTimel;resettimerandtiyagainLDISECsl,002h;adjustfor2secondsSS1EXITJPExitMain*AUTOMATICCHARGESTART**Thisstategetsthebatteryvoltageanddecideshowtocontinuethe:*thecharge.Themaxitnumallowedchargetimeisalsostarted,SS2NOTES:OldVoltSETTO0訓SlIPSrefSETTOOINSSITEMPISETTOOATRESETFASTAVGDECTEMPI;decreaseTempionecount(startsat0);havewecounteddownto0JRZFASTDONE;yes,jumptoFASTDONELDA,TEMP;loadpreviousTEMPvalueADDA,CurVolt;addCURVOLT,DidweoverflowthecounterJRNCOVER;叫ju迈ptoOVERINC01dVot;yes,bumpuptherunningaverageOVERIDTEMP,A;storethelatestvalueinTEMPJPSS2EXIT;exitandgoupdateCurVoltFASTDONEUDA,TEMP;loadpreviousTEMPvalueADDA,CurVolt;Did"weoverflowthecounteronelasttime厕COVER2;加,jumptoOVER2INCOldVolt;yes,bumpuptherunningaverageonelasttimeOVER2CALLCheckBatt;ChecktoseeifbatterywasremovedduringFastAvgJRSBatt,Fhgs2>SS2—Ob;Stillconnected-continueLDICurentSS,O;notconnected-gobacktostate0JPSS2EXIT;,..andexitState2SS2—ObLD^,01dVo〗t;getOldVolt(initialbatteiyvoltage)LDBADhi,A;initiaiizeBADMtoOldVolt;LDA,Percent;getupdated%LDA,Dsp!Pent;comparetolast%displayedJRNZSS2一GP;if%previouslysho取skipaheadCALLGetPercent;updatePercentforinitialvoltageLDAjPercent;getlatest%LDDspPcntjA;storelatest%inDisplayPercentRESWaitOP,Flags2;setflagtoindicatenotwaitingJPSS2—BP;skipaheadSS2一GfCPIA,IOO;checkforl00%JRNZSS2—BP;continueState2ifnot100%JPSS5一Maint"..otherwise,gotoMainteinSS2—LDICCDcnt'MaxHrs;setintervalcountertoMaxHrsSETSOC,SwDown;setStartOfChargeflagRESHiPwr,Flags4;clearhighpowerflagJRSRate,lags,SS2Fast;skipaheadifnotsetforSlowotherwise,setforSlowchargerateLDIOEFSET,Offilow;setOffsetfor2AJRRBat6V,Flags2,SS2Sk);skipifnotsetfor6VmodeLDIOFFSET,Off6Sk);…otherwise,adjustOFFSETSS2SloJPSS2一0a;sldpaheadandreadvoltageSS2Fast;setforFastchargerateCALLSefFast;settorampfromOffSafetoOfEFastJRRBat6V,Flags2,SS2Fst;skipifnotsetfor6VmodeLDIVRcntsOffSafe-Off6Fst"..otherwise,adjustOFFSETrampSS2FstJRRRapid,FIags2'SS2—0a;don'tsettorampupifnotRapidrate;JRSRapid,Flags2,SSikap;skipaheadifrateisRapid;JPSS2一0a;skipaheadandreadvoltage;SS2Rap;setforRapidchargerateCALLSetRmpUp;preparetorampfromFasttoRapidSS2—0aCALLShowChgng;turnChargingLEDonCALLChrgTmr;initializechargingtimer(Timer2)SETPSlo,Flags4;initializeflagforcheckingEPSLDIIPSref,OOOli;dearIPSrefbeforeenteringSS7LDITEMP1,0舰;iuitializeTEMPIforState7LDICurentSS,7;preparetogototheIPSwaitstate(7)JPExitMain;exitandgotoIPSwaitstateSS2IPSCALLAdjVolt;adjustvoltageforcabledrop(&6Vscale)CHA,Volts09;verylowbatteryJKNCSS2—2;no,trynextlimitSS2一1;B^texy<9VLDfA,003h;yes,serviceit,below9VOLTSSINCMINs2;allow6minsinsteadof5forstate3INCMINs2;allow7minsinsteadof6forstate3JPSS2—5SS2—2,Battery>9VCPIA,Voltsl2;lowbatteiystateJRNCSS2一4;no,gotoSS5SS2一3;9V<Battery<12VLDfA,004h;yes,serviceit>below12VOLTSSJPSS2一5SS2—4"JBattery>12V;JR^Alert^〗ags2,SS2EXIT;don'tstartchargeifAlertsett>yDouble6VLDIA,005h;noimalchargeSSSS2—5LDCuxentSS,A;preparetogotothecorrectstate(3,4or5)SETStarted,Flags;setFlagsforchargestartedCALLIniTimel;initiaizetimer11DIMINsl,l;settimer1for1minuteLDISECsl,0051i;s改timer1for5secondsSETRlyCls,Flags4;closeoutputrelayJRRRate,!Flags,SS2—6;skipaheadifsetforSlowrateCALLFstRmp;ra^ipfromOffiafetoO舒astorOff6FstSS2一6RESMinOutJFlags4;setfor>minimunio啤utRESVRlmt,Flags4;setfornotatVoltReglimit;NOTE:relayalreadyclosed,butTurnONsavescodespaceCALLTuni01^;turnFanandChargingLEDcm&closerelaySETSettle,Flags3;initialchargevoltagesettlemodeSS2EXITJPExi她in*BELOW9Volts**Batteryisextremelydischargedandmaybebad.Chargeforamaxi迈uni'举ofsevenminutes.Ifvoltagedoes加tcomeabove9Voltsinthistime**period,abortcharge.Otherwise,gotobdow〗2Volts.*SS3CALLChkRapid;updateRamptimer,ifnecessaryJRRSEC,TicFIag2,SS3EXIT;exitifvoltagesettietimenotexpiredJRSSEC,TicFlag2,SS3J);continueifvoltagesettletimeexpiredJPSS3EXTT;…othervi^se,justexit:SS3一0RESSsttle,Flags3;dearsettleflagJRRMlN,TicFlag2,SS3」;checkiftimehasexpiredCALLSetAbort;yes,timetoabortJFSS3EXITSS3」;not7minsyetCALLBattProg;checkbatteryvoltageforchargeprogressCPIA,Vots09;isbatteryupto9VJRCSS3EXIT;continuestate3if<9VINCCurentSS"..otherwise,gotostate4SS3TEXITJPExitMain*BELOW12Volts**Batteiyisveiylow,Allowamaxhrm迈of4hoursforthevoltageto*riseabove12voltscharge.Ifvoltagedoesnotcomeup,goto*abortcharge.Otherwisegotonormalcharge.*SS4CALL丁urnON;turaFanandChargingLEDon&;closerelayCALLChkRapid;updateRamptimer,ifnecessaryJRRSEC,TicFlag2,SS4EXIT;exitifvoltagesettletimenotexpiredJRSSEC,TicFlag2,SS4一0;contiimeifvoltagesettletimeexpiredJPSS4EXTT;."othen^se,justexitSS4—0RESSettle,Flags3otherwise,clearsettleflagJRRHR,TicFlag2,SS4—1;checkiftime(4hours)hasexpiredCALLSetAbort;yes,timetoabortJPSS4EXIT;exitroutineSS4一1CALLBattProg;checkbatteryvoltageforchargeprogressCPIA,Volts12;isbattery邻to12VJRCSS4EXIT;...ifnot,justexitINCCurentSS"..otherwise,gotostate5SS4EXITJPExitMain*NORMALCHARGE**Programstayshereuntilthevoltagereaches14.2voltsorthemaximum:*chargetimeisexceded.Ifthevoltagelimitisreachedtheprogram**willtransferto:**A.SSB(dV/dt)ifthethebatteryhasbeenchargingmorethan5**minutesor**B,SS9(Desulfation)iftheOCVwaslessthan12.2voltsor**C.SS14(Maintain)iftheOCV邻asmorethan12,2volts**Ifthem紅iinunichargetimeisexcededtheprogramwiUabort*SS5CALLTurnON;turnFanandChargingLEDon&closerelayCALLChkRapid;updateRamptimer,ifnecessaryJRRSEC,TicFlag2,SS5EXIT;exitifvoltagesettletimenotexpired;JRSSEC,TicFlag2,SS5—0;continueifvoltagesettletimeexpired;JPSS5EXTT;…otherv^se,justexit;SS5一0RESSettle,Flags3;…otherwise,clearsettleflagCALLBattProg;ohedkbatteryvoltageforchargeprogressJRRHR,TicFlagl,SS5_0a;skipnextlineifmaxtimenotexpired;NOTE:CurentSSsettoABORTbyBattProg.ChkProgSS5xJPSS5EXIT;exit(andabort)ifmaxtimeexpiredSS5—0aIRSRate,Flags,SS5一Ob;changedeltaifskwrateCPIA,Voltsl42+l"jcheckifover14.2voltsyetJPSS5」SS5一0b—CPIA,Voltsl42+3;checkifover14.2voltsyetSS5—1JR(SS5x;exitifnotover14.2volts;JKNCSS5一2;yes,checkif:>5minutes;JPSS5EXTT;otherwise,justreturn;SS5—2LDA,CCDcnt;getCCDcnt(setbyBattPRogWminutes)LDHRsl,A;setTimerlhourstoCCDcntRESHiPwr,Flags4;setforlowpowermodeRESRmpng,Flags3;clearflag"foremovingonRESRmpInt,Flags3;clearflagbeforemovingon;RESSettle,Flags3;clearflagbeforemovingonJRSMIN,TicFlag2,SS5—3;if>5min^gotod豫LDA,OldVolt;otherwise,checkinitialvoltageCALLDouble6V;doubleBatteryvoltageifsetfor6VCPIA,Volts122;initialvoltage<12.2VJRCSS5一5;Yes:thendesulfateJPSS5j5aint;No:gotoMaintainSS5一5一LE)fCurentSS30091i;batteryissulfatedLDIMaintVolt,VoIts16;trytoholdbatteryat16VLDIVref,Volts15;andseeifitdropsto15VCALLIniTime2;LDIHRs2,002h;inlessthan2hoursJPSS5EXIT;SS5一3LDA,OFFSET;getOFFSETLDOldOff,A;storeOFFSETintoOldOffLDICurentSS,00Bh;gotowaitfordv/dttripvoltageLDIPercent,77;setPercentto77CALLIniTime2LDIMINs2,0Dh;setto13minutesfordV/dtLDA,BADhi;getlatestbatteryvoltageSUBIA,4;preventmatch@1stdV/dtcheckLDMaintVo〖t,A;storeasmaintainvoltagefordi/dtLDITries,004h;initializedV/dtfor4Tries(3intervals)JPSS5EXIT;SS5—Maint;gotoMAINTAIN,batteryisalreadychargedCALLSetlOOp;setPercentto100LDIMaintVolt,Volts132;setmaintainvoltageto13.2V;CALLFanOff;turacoolingfanoffJRRBatTypeB,Flags,SS5一7;skipaheadifnotGel/AGMLDIMaintVolt,Volts135;「etmaintainvoltageto13,5VforGel&AGMSS5一7LDrCurentSS,OOEli;Maintainisstate14(0Ehex)CALLSetSlow;setforSlowRateLDIOFFSET,HiOff-l;MAXoffsetvalue->mindutycycleCALLIniTimel;startrelaycontroltimerLDISECsl,255;setfor255secondsSETRlySw,Flags4;setrecentchangeflag;LDISECs1,1;setfor1second;LDIMSECsl,2;setfor2NMIinterupteSS5EXITJPExitMainSS6;*SS7-WAITFORINTERNALPOWERSUPPLY***;*InState7,thechargerleavestheoutputoffandturnsthefanon.*;*Iftheinternalpowersupplyvoltageisnothighenoughafter5*;*minutes,thecliargerwillproceedtotheendofState2.*■*承『S7CALLFaoON;tumcoolingfanonXRRMIN,TicFlag2,SS7—1;skipaheadif5minuteperiodhasnotexpiredRESIPSlo;Flags4;clea7flagJRSCranl^Flags,SS7一5;setOFFSETtoOffSaferifCrankJRSRate,Flags,SS7一5";setOFFSETtoOfiSaferifnotSlowCALLSetSafe;set一OFFSETforOffSafe(~5A)whenrelayclosesSS7—0;LDIQirentSS,2;preparetoreturntoState2CALLChrgTmr;initializechargingtimer(Timer2)JPSS2IPS;beginchargingSS7一4LDfOFFSET,OfiSafer;setOffsetfor~10ALDIVHcnt,OfiSafer-O证ast;adjustOFFSETramp.JPSS7—0SS7一5LDfOFFSET,OffSafer;setOffsetfor~10ALDIVRcnt'OffSafer-OffCrank;adjustOFFSETrampJPSSI6—3;retamtostateWSS7一1—;C^LLShowRed"DEBUG**JRSBat6V,Flags2,SS7—6;don'tcheckIPSin6VmodeDECTEMP1;updatecounterJRZSS7—2;sMpaheadifzero(timetocheck)CALLR^adlPS;getIPSvoltage;CALLCheckiPS;checkforminimumLDA,CurIPS;storelatestreadinginACPIA,MinIPS;comparewithminimumJRCSS7—7;skipaheadiftoolowINCIPSref"..otherwise,incrementIPSrefSS7一7JPSS7x;exitandwaitfornextreadingSS7一2一LDA,IPSref;check"average"ofreadingsCPIA,250;okayof250/255werehighenoughJRCSS7—3;ifnothighenough,clearandstartnewavg欲一6RE5lPSio,Flags4"..otherwise,clearflagJRRCra昧Flags,SS7一0;re加rntostate2if加tcrankJPSS16—2;...otherwise,returntostate16SS7—3—(X5iPSref;clearIPSrefLDITEMPl,OFFh;initiafeeTEMPIfornext"average"SS7一xJP豆xi她in*SS8-ABORTCHARGE****TurnoffallLED's.BlinkTROUBLELEDathalfsecondinterval.If—*batterybecomesdisconnected,re-inrtiaKze.*SS8SETAlert,Flags2;setAlertflagCALLSJmtOff;openrelay,turnofffan,andsettoHiOFFCAIXBlinkAlert;blinkAlertLEDCALLModeOff;TurnoffdisplaymodeLEDsJRSBurnln,Flags3,SS8X;don'tcheckforbatteryifBum-InJRSSOC,SwDown,SS8X;don'tcheckforbatteryifStartOfChargeCALLCheckBatt;checkforconnectedbatteryJRSBatt,Flags2,SS8XJRRBattjFlags2,SS8—1;ifdisconnected,endabortroutineSS8一2一JP§"S8EXIT;otherwise,justexitSS8一1RE§Alert,Fiags2;resetAlertflagSS8rstJPMAIN2;re-initia!izeSS8X;SS8EXTTJPExi飾in*SS9-DESULFAT画**DesulfationModeisenterediftheinitialbatteryvoltageisless**than12.2voltsandthevoltagereaches14.0voitswithinfive**迈inutes.*承**Thechargertriestoholdthevoltageat16.0volts.Asthebattery**startstoconduct,thevohagewil!fsLJfthevo)tagereaches14.0**inareasonabletimelimit(it)hours),wewilltransitiontothe**normalchargingsequence(SS5).Ifthevoltagedoesn'tfallto14.0*voltswewilltransitiontotlieABORTsequencestate(SS8).*SS9DDIPercent,15;setto15%CALLBlnkChrg;blinkChargingLEDCALLCheckBatt;checkforconnectedbatteryJRKBatt'Flags2,SS8rst;re-initializeif加tco:mected;JRSBatt,Flags2,SS9一0;coutiimeroutineifconnected;JPMAIN2;...otherwise,re-initialize;SS9一0CAflVo股eg;tiytoholdbattat16(or8)volts,**BP**'LDA,OFFSET;cheokoutputlevelCPIA,OffSbw;isoutput>slowrateJRNCSS9一5;.,加useoutputsetbyVo欣egLDIOFFSET,O滔low;...yes:limitoutputtoSlowrateSS9—5JRRSEC,TicFlag2,SS9X;wait1minuteJRRHR,TicFlag2,SS9一l;maximumtimeout(Ior2hours)DECCurentSS;AB6kTstateSS9exitJPSS9X;doneSS9_1CALLAdjVolt;adjustvoltageforcabledrop(&6Vscale)CPA,Vref;arewethere應CSS9exit;ifnot,thenexit;JRCSS9一2;yes:reduceVref;JPSS9X;no:waitanotherminute;SS9一2DE(5"Vrsf;1countis0.0667voltsDECVref^reduceVrefby0.133vcfeLDA,Vref;seeifbattisdesulfatedyetCPIA,Volts14;isVref<14.0Volts;JRNCSS9_3JRCSS9_4;...ifso,gotonormalchargeJPSS9—3;...otherwise,tryanotherhourSS9一4—LDICurentSS,0051i;preparetogotonormalcharge;CAIXShowChgng;turnChargingLEDon(stopblinking)LDA,Vmax;setMaintVolttoVmaxLDMaintVolt,A;maintainvoltageforstate5SETRlyCls,Fkgs4;closeoutputrelayCALLIniTi迈e2;initiaizetimer2LDISECs2,002h;settimerfor2seconds(voltagesettletime)JPSS9XjSS9一3CALLIniTime2;resettimerLDIHRs2,001h;setmaxtimefor1hourSS9XJPExilMainSSI0d職MONITOR*TMsstateislookingforoneofthreeconditions:*1.Maximumtimeisexceded-setforcheckbatteryandturnoffcharger,*2.NochangeindV/dtfor45minutes-batteryisabout80%charged.*;*3.MAXvoltageisreached-GOTOdl/dt.*SS11CALLSetON;tumcoolingfanon&closeoulputrelay;RESRmpng,Flags3;clearflagbeforemovingon<formula>formulaseeoriginaldocumentpage102</formula>SS11一9LDITries,004h;resetcounter(4matches-3intervals)SS1I一8CALLIniTime2;initializetimerLDIMINs2,009h;…for9minutesSS11XJPExitMain;*磁MONITOR*;*Indi/dttheon/offrelayisopenedandclosedtoholdthevoltage*;*closetothedV/dtvalue.T£eintervalbetweenopeningandclosingthe*;*relaywillincrease.Thisstateislookingforoneoftwoconditions:*;*1,Maximumtimeisexceded-setforcheckbatteryandturnoffcharger.;*2.Nochangeinon/offrelayfor30minutes-currentstabilizedata*;*lowvalue.Batteryisabout97%charged.GotoSS13(EndCharge)for*,1hour-*^S12;CALLSetON;tumcoolingfancm&closeoutputrelayCALLVoltReg;regulatebatteryvoltageatMaintVoltLDAjDspPcnt;getlast%displayedCPI乂100;has°/。displayedreached100IRZSS12—14;…ifso,turnongreenLEDCALLShowYellow"..otherwise,turnonyellowLEDJPSS12一15;..,andskipahead(leavegreenoff)SS12—14—CALLShowDone;turaonchargecompleteLEDSS12—15JRE/5lVricFlagl,SS12」;maximumtimeoutJRSAlert,Flags2,SS12一0;If2ndmaxtimeout,gotoSS12一0SETAkrt,Flags2;If1stmaxtime,setAlertflagCALLIniTimel;andresettimerLDIHRsl,004h;toalow4morehoursSS12」0LDA,MaintVolt;andgetMaintainvokageSUBIA,007h;thensubtract0.5VLDMaintVolt,A;andupdateMaintainvoltageJPSS12EXIT;thenrestartdi/dtSSI2—0CALLSetAbort;gotoabortRESAlert,Flags2;resetAlertflagforAborttimerJPSS12EXITSS12—1JRSSlinOut,FIags4'SS12—2;don'twaitifatminimumoutputJRRMIN,TicFlag2,SS12ixiT;timefordl/dttest.IFCEQSMReg;assembknextlineonlyifdebuggingCALLShowAlt;turnonalternator%LED,ENDCLDA,Percent;getPercentCPIA3100;isPercent<100腦CSS12—2;,..ifnot,skipaheadINCPercent"..otherwise,increasePercentLDA,Percent;getpercentCPIA,IOO;Ispercent=100JRZSS12—2;YES,don'tincreaseanymoreINCPercent;No,increaseby2SS12_2LDX,OFFSBT;getcurrentOFFSET;INCACPIA,ffiOff-l;hasOFFSETreachedmaximumJRNCSS12—5;ifso,finishdi/dtDECA;ensurecarryifequal;DECA;allowdifferenceof1CPA,OldOff;testforlowerlimitchangeJRCSS12—4;o跑etwitMn"finish織JPSS12jf;o飽ettoohigh,tryagainSS12—5一JPS§"l2—6SS12—4DECTries;decr加entcounterJRZSS12一5;ifO,thenpr邻areforEndCharge(SSI3)j腿ZSSi^一5jArewedo加?;JPSS12_6;yes,alldone,cleanupandexit邻12一5jno,continueLDA,Percent;getPercentCPIA'99;isPercent<100JRNCSS12—3;...ifnot,skipaheadINCPercentotherwise,increasePercentJPSS12一8;reloadtimer&checkagainlaterSS12—3一LDA,Tries;getthecurrenttriesCPIA,03;Istrieslessthan3JKNCSS12—11;No,justexitCALLSetldbp;Yes,show100%anddoneSS12—11JPSS12—8;reloadtimer&checkagainlaterSS12—6—INC一CurentSS;GOTOEndCharge(SS13)CALLIniTime2;initializetimerLDIHRs2,00lh;chargefor1morehour(EndCharge)LDIMINs2,00Fh;chargeforonly15minutes(EndCharge)JRRBatTypeA,Flags,SS12一9;skipifnotDeepCycle(Voyager)JRRRrapInt,Flags3,SS12—f;skipifnotusinghigherEndChargevoltageINCHRs2;otherwise,cWgeHRS2from1to2LDA,MaintVolt;also,storeMaintVoltinAADDIA,04h;increaseAby4counts~0.267VLDMaintVolt,A;storeupdatedvalueinMaintVoltSSI2—9JPS&2EXITSS12一7LDS,OFFSET;setnewbaseoffsetLDOldOff,A;saveinOldOffLDITries,004h;resetcounter(4matches=3intervals)SS12—8CAliIniThne2;initializeTimer2LDIMINs2,009h;setTimer2for9minutesLDA,OFFSET;GetcurrentoffsetCPIA,OffFast;Istheoffset=O征astJRNZSS12EXIT;NO,justexit咖RmpInt,Hags3;YES,don'tboostvoltageforEndChargeJPSS12一I0;Current加tfailing,reducevoltagebyI/2VSS12EXfiJPExitMain;*ENDCHARGE*;*Chargefordesiredhoursafterdl/dtatdV/dtvoltage.*CALLSetl00p;setPercentto!00LDA'DspPcnt;getlast%displayedCPIA,IOO;has0/。displayedreached100JRNZSS13—2;..,ifso,tonongreenLEDCALLShowDone;turncmchargecompleteLEDSSI3一2;CALLSetON;tumcoolingfanon&closeoulputrelayCALLVoltReg;regulatebatteryvoltageatMaintVoltJRSVRl边t,lags4,SS13—1''finislinotifVoltReglimitreached;JRRVRlmt,Flags4,SSl51o;continueifVoltReglimitnotreached;JPSS5一Maint"..otherwise,finishnow;SSI3一0一JRRJi^TicF〗ag2,SS13EXIT;exitif1hourtimenotupSS13一1JPS"§5—Maint"..otherwise,GOTOMAINTAINSS13E5tJPExitMain*MAINTAIN**Batteryhasreachedfoilcharge.Stayhereandmaintainbattery*at13.2voltsuntilbatteryisdisconnected.*SS14CALLSet00p;setPercentto1DOCALLVoltReg;regulatebatteryvoltageatMaintVoltLDA,DspPcnt;getlast%displayedCPIA,100;has%displayedreached100JRZSS14一1;…ifso,turnongreenLEDCALLShowYelWotherwise,turnonyellowLEDJPSS14—2;...andskipahead(Jeavegreenoff)SS14—1—CALLShowDone;turnonchargecompleteLEDSSI4—2LDA,OFFSET;CheckwhethertoopenorcloserelayCPIA,扭O任;Isitminimum(nearlyoff)JRCSSI4一2A;...ifnot,closere]ayandtamonfanJPSS14—3;...andopenrelaySS14一2^T;closerelayCALLFanONotherwise,closerelay&turnfanon.IFCEQDEBUG''assemblenextlineonlyifdebuggingCALLShowRed;tumonRedLED.ENDCSETReby,Flags2;preparetodoseoutputrelayJRSRlyCls,Flags4,SS14一4;skipaheadofalreadyclosedJRRRlySw,Flags4,SS14—5;checkiftoosoontoswitchJRRSEC,TicFlagl,SS14—4;skipaheadiftoosoontoswitchSETRlyCls,Flags4;settoindicaterelaynowclosedLDIOFFSET,HiOff隱l;setforminimumdutycycleJPSSI4—3a;an(iskipaheadSS14—3;openrelayRESRday,Flags2""otherwise,openoutputrelayJRRRlyCis,Flags4,SS14—4;skipaheadifrelayalreadyopenJERRlySw,Flags4,SS14一5;checkiftoosoontoswitchJRRSEC,TicFlagl,SS14二4;skipaheadiftoosoontoswitchCALLShutOff;openrelay,turnofffan,andsettoHiOFFSS14一3aRESlllySw,Flags4;allowIT—Timer&PwrCont。switchrelaySS14—4一CALLCheckBatt;clieckforbatteryJRSBatt,Flags2,SS14EXIT;…co皿ected:continueJPMAIN2"..disconnected:startoverfi:onistate0SS14—5CALLIniTimel;startrelayintervaltimerLDISECsl,Rlylnt;settimertoRIyIntseesSETRlySw,Flags4;setrecentchangeflagSS14EXITJPExi她in;*SS15MANUAL*;*Setoffsetforselectedrate.Novoltagelimil/batterycheck.*^S15JRRRlyCls,Fiags4,SS15一2;ifrelayopen,thenBurn-Incomplete;JRSRlyCls'Flags4,SS15一O;openrelayindicatescompletedBum-In;JPSS15—2;skiptoendifrefayisopen;SS15一0—CAL[ShowRate;turaonthe2A,15A,or40ALED;NOTE:relayalreadyclosed,butTumONsavescodespaceCALLTurnON;turnFanandChargingLEDon&closerelayCALLCheckl7v;checkfordisconnectedbatteryIRNZSS150K;if17V,thencontinueCALLSetAbort"..otherwise,AbortRESManual,Flags3;…endManualModeJPSS15EXIT;..,andskiprestofState15SS150KJUSBumln,Flags3,SS15BI;skipaheadifBum-in迈odeRESMtrScale-Flags;setforAlternator%LEDoffRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffCALLShowMeter;updatemeterLEDsJPSS15nnp;jumptorampcheckSS15BIIRRMESf,TicFlag2,SS15b;skipaheadifnottimetoupdatecounterDECCCDcnt;decreasedisplaycountby1CALLMTime2;resetTimer2LDIMTNfs2,1;settimerforcounterinterval(1minute)SS15bLDA,CCDcnt;getlatestcountdownvalueLDLED加m,A;storeinLEDnumCALLShowNum;displaycountondigitalLEDCALLModeOff;tumoffalldisplaymodeLED'sSS15卿CALL亩howData;updatedisplayJRRRapid,Flags2,SS15_I;don'trampifRapidisnotsetCALL6hkRapid;updateRamptimer,ifnecessaryJRRRmpng,Fiags3力S15-l;skipaheaiifnotRapid<->FasttransitionCALLRampQS;othenvise,graduaJ〗ychangedutycydeSS15一1JRRllR,TicFlagl,SS15EXIT;contimieifnotmaxmanualchargetimeJRSBurnln,Flags3,SS15—2;skipaheadiffinishedBuxn-IiiJPRESET"..otherwise,resetSS15一2CAlXDigitsOff;turaoff3-digitLEDCALLResetLEDs;tonoffalltype,rate&StatusLED'sCALLShowGreen;lightGreenLEDonlyCALLTumOff;openrelayandsetformindutycycleSS15EXITJPExitMaiii;*BOOSTMODE*;*FirstsetthechargeroffsetvalueforSlowcharging.Next,wait*;*forthevoltagetostabilize.Thenwaitforthevoltagetodrop*;*aboutonevolt.Whenthevoltagedrops,gofixllonfor5seconds.:;*Afterfivesecondsofcranking,waitfor4minutesandstartover.*CALLVoltMtr;setforvoltmeterandupdatedisplayCALLCheckBatt;checkfordisconnectedbatteryJRRBatt^Flags2,SS16」;skipaheadifnotconnectedJRSSEC,TicFlag2'Baik)K;skipif>2secondssinceBoostselectedJPSS16Exit;if<2seconds,thenstayoffSS16—1CALLTumOff;openrelayandsetformindutycycleLDIOFFSET,OffSafe;setOFFSETtoOffSafeCALLShowRed"..otherwise,turnonAlertLEDJPSS16Exit;ifbatt<1.6V,thenstayoffBattOKCALLShowCrank;tumONCrankLED&turnAlertLEDoffJRSRlyCls,Flags4,SS16一3;skipaheadifrelayalreadyclosedJPSS2—0a;…otherwise,preparetocheckIPS(SS7)SSI6—2—CALLSetSafe;setOFFSETforOffSafe(5A)whenrelayclosesLDIVRcnt,OffSafe-OffCrank;OFFSETdeltafromSafetoCrankSSI6—3CALLTurnON;tumFanandChargingLEDon&closerelaySETStarted,Flags;setHagsforchargestartedCALLIniTime2;resettimer2LDIMSECs2,MS200;setTimer2for200msLDICurentSS,17;settonextstate(17)SS16ExitIPExitMain;gotoendofloop*DELAY織VOLTREADING*SS17JRSMSEC,TicFlag2,SS17—1;Is200msupIPSS17EXIT;no,justreSirnSS17—1CALLGetMeter;updatedisplayCALLCheckl7v;checkfordisconnectedbatteryJRCSSI7—2;skipaheadifconnectedJPMAIN2;otherwise,startoverSS17—2SUBIA>010h;adjustforaonevoltdropLDOldVolt,A;saveitCALLFstRmp;rampoutputfro迈5Ato20ALDIMaintVolt,Voltsl42;trytoholdbatteryat14.2VINCCurentSS;waitforcrankCALLIniTime2;initializeTimer2LDIMINs2,10;setTimer2for10minutesLDIVRcnt,OffCrank-MinOff;OFFSETdeltafromSafetoCrankSS17EXITJPExitMain*WATTFORCRANK*SS18JRSMIN,TicFlag2,SS18rst;re-initializeafter10minutesHIRMTN,TicFlag2,SS18—0;waitforcrankupto10minutesJPMAIN2;thenstartre-initializeSSI8—0CALLFanON;加mcoolingfanONCALLGetMeter;updatedisplayCALLVoltReg;regulatebatteryvoltageatMaintVoltLDA,FreshBV;getcurrentreaiingSUBIA'010h;adjustforaonevoltdropCPA,OldVolt;hasvoltageincreasedJRCSSI8—2;ifnot,thenskipaheadLDOldV(St,A;updateOldVoltJPSSi8—X;andexitroutineSS18—2—LDA,FreshBV;getcurrentreadingCPA,OldVolt;1Vdropindicatescracking腦CSS服XTTCALLFstRmp;rampoutputfrom20Atoalmost100AINCCurentSS;tiniethecrankingCALLIniTime2;resetTimer2LDISECs2,CrankON;crankforCrankON(5)secondsSS18EXITCALLCheckl7v;checkfordisconnectedbatteryJRCSS18—X;skipaheadifconnectedSS18rstJPMAIN2;otherwise,startoverfromstate0ssi8—;xJPExitMain;*CRANKTIMING*AllowcrankingforCrankONsecondsandthengobacktocharging,*SS19LDA,SECs2;getremainingoranksecondsLDLEDnum,A;storeinLEDnumCALLMeterNum;showLEDnumandturnoffdisplaymodeLED'sJRSSEC,TicFlag2,SS19一l;iftimeis叫thenendroutineCALLCheckl7v;checkfordisconnectedbatteryJRNCSS19一1;stopcrankingif加tconnectedJPSS19EXS1;stiUconnected,waitforcranktimerSS19—1INCCurentSS;justwaitfortimetoexpireLDIOFFSET,OffCrank;setOffeetfor20ASETCrankW我Flags;indicatescrankcool-downtimeCALLTuniQN,'tuniFanandChargingLEDon&closerelayCALLIniTimel;resetTimerlLDISECsl,CCDint;settimerforcounterinterval(seconds)LDICCDcnt,CrankOff;setcrankcooldowncounterto120SS19EXITJPExitMain;*INTER-CRANKDELAY*;*Stayhereuntilthe4minutetimerhasexpiredlhengobacktoBOOST;*ifswitchstillengaged,elsegotoSlowauto(default)*CALLFanON;tumcoolingfanONJRRSEC,TicFlagl,SS20—0;skipaheadifnottimetoupdatecounterDECCCDcnt;decreasedisplaycountby1IRNZSS20—1;finishstate20ifcountdownto0RESCrank^ait,Flags;resetCrankWaitbitofFlagsLDICurentSS,O10h;setstateto!6toCrankagainSETSEC,TicHag2;tellState16thatE/SalreadyruniiingJPSS20EXIT;andexitState20SS20—1CALLIniTime1;resetTimer1LDISECsl,CCDint;settimerforcounterinterval(seconds)SS20一0LD八,CCDcnt;getlatestcountdownvalueLDLEDnum,A;storeinLEDnumCAULMeterNum;showLEDnumaadturnoffdisplaymodeLED'sCALLVoltReg;regulatebatteryvoltageatMaintVoltRESRmpng,Flags3;clearflagforCheckBattRESSettle,Flags3;clearflagforCheckBattCALLBIinkCrank;blinktheCrankLEDSS20EXITJPExitMain;*SUBROUTINESSTARTH鹏*;*Initializestate(Slowcharge,Regularbatt,State0)*威tateCLUFlags;0isdefaultforallbitsCLRFlags2;0isdefaultforallbitsCLRFlags3;settoindicatenoRapidtoFastchangeCLRTEMPI;initializeCLRCCDcnt;i函lizeSETChMode,Plags2;setforChargerMode(chargermode)LDIOFFSET,HiOff;setformimimumdutycycleLDISwData,O1101111b;InitializeswitchLEDsfor2A,RegLDIVmax,Volts155;VmaxforRegularbatteriesLDIVltCnt-001ii;initializeVltCntto1LDIVRcnt,001h;initiaHzeVRcntto1LDIPcntL,001h^initializePcntLto1LDIPcntH,001h;initializePcn沮to1LDICurentSS,OOOli;setchargerstateto0LDISECsl,SecInit;restartTDVffiRJsecondcounterLDISECs2,SecInit;restartTMER2secondcounterRET*Reset"WatchdogRegister**ThisroutinesimiplyresetstheWatchdogregister.RstWDRwas**onlytosaveprogramspace(LDIrequire3bytes,CALLrequiresonly2).RstWDRLDIWDR,0FEh;resetwatchdogtimerRET*SetAbortState**ThisroutinesimiplysetsCurentSStoABORTsothatthecodewillgo;*totheAbortstateafterthenextNMI.SetAbortwaswrittenonlyto**saveprogramspace(LDIrequire3bytes,CALLrequiresonly2).*SetAbortLDICurentSS,ABORT;setcurrentstatetoAbortRET*Set100Percent**ThisroutinesiraiplysetsPercentto100.SetlOOpwaswrittenonlyto**saveprogramspace(LDIrequire3bytes,CALLrequiresonly2).*SetlOOpLDIPercent,100;setPercentto100RETClearPercent承:ThisroutinesimiplysetsPercentandDspPcntto0.ClrPcntwas*:"writtenonlytosaveprogramspace(CLkrequire3bytes,CALLrequires;only2),SetOpisthesecondhalfofClrPcnt'*Set0Percent*ThisroutinesimiplysetsPercentto0.SetOpwaswittenonlyto*saveprogramspace(LDIrequire3bytes,(3aLLrequiresonly2),*ClrPcntCLRDspPcnt;setDisplayPercentto0SetOpLDIPercent,O;setPercentto0RET*UpdatePortA**ThisroutineupdatesPortAwiththecontentsoftheDRAbuffer.*UpdatePA"waswrittenonlytosaveprogramspace,*UpdatePALDA,DRAbuf;updateAccumulatorfrombufferLDDRA,A;updateportfromAccumulatorRET*UpdatePortB**ThisroutineupdatesPortBwiththecontentsoftheDRBbuffer.*UpdatePBwaswrittenonlytosaveprogramspace.*UpdatePBIDA,DRBbuf;updateAccumulatorfrombufferLDDRB,A;updateportfromAccumulatorRET*UpdatePortBOptions**ThisroutineupdatesthePortBoptionswiththecontentsoftheORB*buffer.UpdateORBwaswrittenonlytosaveprogramspace,*UpdateORBLDA,ORBbuf;updateAccumulatorfrombufferLDORB,A;updateoptionsregisterfromAccumulatorRET;*SetFast*:ThisroutinesetsOFFSETtoOffiafeandsetsVRcnttorampfrom*:OfiSafetoOffFast.SefFastsavesprogramspacesinceDDIrequire3*:bytesandCALLrequiresonly2,*SetSafe*:ThisroutinesimiplysetsOFFSETtoOfESafeandwaswrittenonlyto*saveprogramspace(LDIrequire3bytes,CALLrequiresonly2).*GetMeteristhelastsectionofVoItMtr,承SetFastLDIVRcmt,OffSafe隱OffFast;rampfromOffSafetoO邸astSetSafeLDIOFFSET,OffSafe;setO鹏ETtoOffSafeCALLFi他Second;wait1/5secondbeforeclosingrelayRETInitializeChargeTimer*ChrgTmrCALLIniTime2;initializetimer2LDISBCs2,0021i;settimerfor2secondsLDIMINs2,0061i;settimerfor5minutesand2secondsLDIHRs2,005h;settimerfor4hours,5minutes&2secondsRET*WaitaFifthSecond**Thisroutinecausestheprogramtowaitonefifthsecondbywaiting*for24inteirupte,FifthSecondCALLIniTime1LDIMSECsl'MSlOO;settimerfor1/10secondWFS—1CALLRstWDR;reset"watchdogtimerJRRMSEC,TicFlagl,WFS—1;wdtuntiltimergoesto0RET*READINTERNALPOWERSUPPLYVOLTAGE*,Thisroutinereadsthecurrentinternalpowersupplyvoltageby*l*temporarilychangingtheA/DfromP^5toPB6.ThereadingissavedinIPSA2D.*ReadIPS;disab〗ePB5A/DconnectionRES4,ADCR;disableA/DconvertorRESBattA2D,ORBbuf;SetbatteryvoltagetodigitalinputinbufferCALLUpdateORB;updatePortBopticmsfrombuffer;establishPB6A/DconnectionSETEPSA2D,ORBbuf;Setint.PSvoltagetoanaloginputinbufferCALLUpdateORB;updatePortBoptionsfrombufferSET4,ADCH;A/DccmvertornowswitchedbackON;activateA/DconversionLDIADCR,0B0h;startA/DconversionLDIADCR^0B0h;doagaintoinsureavalidstartWAIT;lettheinteruptnotifyuswhendataisreadyLDCurIPS,A;savecurrentreading;disablePB6A/DconnectionRES4,ADCR;disableA/DconvertorRESIPSA2D,ORBbuf;Setint.PSvoltagetodigitalinputinbufferCALLUpdateORB;updatePortBoptionsfrombuffer(establishPB5A/DconnectionSETBattA2D,ORBbuf;SetbatteryvoltagetoanaloginputinbufferCALLUpdateORB;updatePort6optionsfrombufferSET4,ADCR;A/D咖vertornowswitchedbackONRET;*CHECKINTERNALPOWERSUPPLYVOLTAGE*;*Thiscomparesthecurrentinternalpowersupplyvoltagetotheminimuni;*safelevel.ItsetstheIPSloflagaccordinglyandincrementsIPSref*;*ifthevoltageishighenough.IPSrefcanusedtotakeseveral*;*readingsanddiscardafewtoallowforbadreadingswithoutgettingan*,*actualaverageofthereadings.*;CheckiPS;LDA,CurIPS;storelatestreadinginA;CPIA,MinIPS;comparewithminimum;JRCCMIPSx;skipaheadiftoolow;INCIPSref;...otherwise,incrementIPSref;ChkIPSx;RET*FastHamp**ThisroutineisusedtorampthedutyupfromSafeOfftoSafeOff-VRcnt.:*OFFSETisdecreasedbyonewitheachNMI(120persecond).*FstRmpDECOFFSET;increasedutycycleDECVRc加;updateOFFSETchangecounterIRZFstRmpX;finishloopifcounte产OLDA^CurentSS;checkcurrentStateCPIA,18;isitState18(rampingtoMlon)JKNZFstRmpES;skipaheadifnotDECOFFSET"..otherwise,increasedutycycleagainDECVRcnt;...andupdatecounteragainJRZFstRmpX;finishloopifcounter=0FstRmpESWAIT"'.otherwise,waitfor1interruptJPFstRmp;...andthenchangeOFFSETagainFstRmpXIDIVRcnt,001h;re-initializeVRcnttoiRETSetRampUp**Thisroutinesetstheparametersnecessarytorampthedutyupjfromthe'*fastratetotherapidrate.ItisusedbeforeBurn-InandAutomatic**Rapidcharge.*SetRmpUpLDIRmpGat3RCinitX2;2000.75-secondintervalsyields150secondsSETRampUp,Flags3;setforrampupSetRampLDITEMP,RIinit;180NMIinterruptsyields3L5secondsSETRmpInt,Flags3;counting1stoftwo180cycleperiodsRESRmpng,Fags3;setfornotrampingyetRET*CHECKRAPID**Thisroutinedetermineswhethertoreduceorincreasethechargerate*fromRapidtoFastorvicaversa,ifnecessary.Itsetstheflags**usedbyRampOSappropriately,*ChkRapidJRRRapi4Flags2'ChkRapX;ifnotRapidchargerate,thenexitJRSRmpng,Flags3,ClikRapX;ifRmpngalreadyset,thenexitDECTEM]P;otherwise,updateramptimerIRNZChekRapX;exitifnottimetoupdatecount;JRZRmpTmr;updatecountiftime;JPChkRapX;…otherwise,justexit;RmpTmrLDITEMP,RIinit;count180證ecycles(1.5sec)JRRRjnpInt^Flags3,RmpCtr;skipaheadifjustcounted1sthalfRESRmpInt,Flags3;...otherwise,startcounting2ndhalfChekRapXJPChkRapX;...andexitRmpCtrSETRmp!nt,Flags3;counting1stoftwo180cycleperiods.IFCEQShoReg;assemblenextiineonlyifdebuggingCALLSh。wAlt;turnonalternator%LED,ENDCDECRmpCnt;checkiftimetorampJRKZChl^RapX;exitifnottimetoramp;JRZStartRamp;ifso,startramping;JPChkRapX"..otherwise,justexit;StartRampSETRmpng,Fiags3;settoindicateRapidtoFasttransitionIDIRmpCnt,RCinit;1003-secondintervalsyields5minutesJRSRampUp,Flags3,StRmpUp;skipaheadifabouttorampupLDIRmpCnt,RCinitX2;...otherwise,doubleinter-ramptimeStRmpUpSETHiPwr,Flags4;setflagsfor>FastrateChkRapXRET;*RAMPOFFSET*ThisroutinechangesthechargeratebetweenFastandRapipdgradually*;*bychangingOFFSETbetweenOffFastandO服apatasteadyrate.OFFSET*;*israisedby1every4seconds.Thatchangesthecurrentfrom30Ato10A*;*inabout4minutes.****RampOSJRRRapid,Flags2,RmpOfK;ifnotRapidchargerate,thenexitDECTJ^MP"..otherwise,decrementcounterJRZRampTime;iscounterdowntozeroJPRmpOfEX;ifnot,justexitRampTime"..otherwise,timetoadjustJRSRmpInt,Fiags3,RampInt;skipaheadifonlyhalfwaythroughwaitLDA,OFFSHT;getOFFSETJRSRampUp,Flags3,RnipUp;skipaheadifdecreasingOFFSETJRRBat6V,Flags2,RmpDwn6;skipaheadifnotsetfor6VCPIA,Off6Fst"..otherwise,checkforOfKFstJPJRmpDwn12;…andskipaheadRmpDwn6CPIA,OffFast;isOFFSET-OffFastyetRmpDwnl2JRNZRampMore;ifnot^skipaheadandcontinuerampingRESRmpng,Flags3;rampingcomplete,clearflagRESHiPwr,Flags4;setfornotHiPwrSETRampUp,Flags3;settorampupnexttimeJPRmpOffX;skiptoendofroutineRampMoreINCOFFSET;…otherwise,reducedutycycle.IFCEQShoReg;assemblenextlineonlyifdebuggingCALLShowRed;turnonRedLED.ENDCSETRmpIntjFlags3;coutiting1stoftwo180cycleperiodsJPRmp(3ffl;skipaheadandre-initializecounterJRRBat6V,Flags2,RmpUp6;skipaheadifnotsetfor6VCPIA,Off6Rap;…otherwise,checkforOff6RapJPRmpUpl2;…andskipaheadRmpUp6CPIA,O舰ap;isitOffRapYetRmpUpl2JR^TZRmpAgain;ifnot,skipaheadandcontinuerampingRmpDoneRESRmfmg,Flags3;rampingcomplete,clearflagRESRamptjp,Flags3;settorampdownnexttimeJPRmpOfDC;skiptoendofroutineRmpAgainDECOFFSET"..otherwise,reducedutycycle.IFCEQShoReg;assemblenextlineonlyifdebuggingCALLShowGreen;turnonGreenLED.ENDCSETRmpInt,Flags3;counting1stoftwo180cycleperiodsJPRmpOffI;slcipaheadandre-initializecounterRamplntRESRmpInt,Flags3;countinglasttwo180cyclesofintervalRmpOfflLDITEMP,RIinit;setcounterfor180cycles(1,5moresec)RmpOfKRET*SHOWNUMBER**ThisroutinedetermineswhatthreedigitstodisplayonthedigitalLED:*torepresentthenumberstoredinLEDNum,Thethreedigitswillbe**displayednexttimetheShowDataroutineiscalled,*ShowNumOLRIndex;initializeLUTIndexto0CALLDigiOff;setregistersforallsegmentsoffLDAjLEDnuin;storeLEDnuminaccumulatorCPIA,10;checkforsingledigitnumberIRNCChkMaxNum;,"ifnot,checkformaxnumberJPNextOOl".otherwiseskipto3rddigitChkMaxNumCPI入199;checkforhighestdisplayablenumberJRCCheck100;ifless,checkvalueLDIA,199;…otherwise,displaly199Check100CPIA,IOO;checkwhehtertoshowmostsignificantIJRCCheck010;if加t,checkfor10RESDigit1,DigiDat2;otherwise,turnONmostsignificant1SUBIA,IOO;…andsubtract100fromaccumulatorCheck010CPIA,IO;checkif<10JRCCheck001;…ifso,skipaheadandcheck3rddigitINCIndex"..otherwise,shownexthighervalueSUBIAjl0;...andsubtract10fromAcumulatorJPCheckOl0;,..andcheckfornexthighervalueCheckOOlLDIDRWR,DigiteOxO.w;lookuptable(LUT)for2nddigitLDIX,DigitsOxO.d^initializeLUTLDATemp,A;saveAccumulatorLDA,Index;getindexfromstartofLUTANDIAj03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAANDA,DigiDat2;…setbitsinAforseconddigitLDDigiDat2,A;…storcAintoDigiDat2LDA,ATemp;restoreAccumulatortoremainderofLEDnumNextOOlLDIDRWR,Digits00x.w;lookuptable(LUT)for3rddigitLDIX,Digits00x.d;initializeLUTANDIA,03Fh;limittowindowADDA,X;addbaseaddressoftableX,A;storeaddressofvalueinXLDAj(X);storevalueatXintoAAND人DigiDatl;…setbitsinAfors邻mentsLDDigiDad,A;…storeAintoDigiDat2ShowNumXRET*GetBatt'**ThisroutineadjuststhebatteryvoltagestoredinBADhiforthecable:*dropbycalHngGfetDrop,thenstorestheresultintheaccumulator.*GetBattCALLGetDrop;getapproxbattcablevoltagedropLDA,BADhi;getlatestavgbattvoltageSUBA,Vdrop;adjustforvoltagedropincableRETDouble6V*'Thisroutinedoublestheaccumulator,A,iftheBat6Vflagisset.This*:routineiscalledbeforetheaccumulatoriscomparedtooneofthe*:constantsoriginallyassignedfor12vbatteries.*承:NOTE:IftheHi6Vflagisset,thentheaccumulatorissettoMaxVolts:insteadofdoubled.*Doubk6VJHRBat6V,Flags2,D6VX;don'tdoubleifnotsetfor6VJRRHi6V,Flags4,D6V;doubleif6VBatt<8,5VLDI入MaxVolts"..otherwise,setAtoMaxVoltsJFD6VX;…andskiptoendofroutineD6VSLAA;doubleAD6VX'RET*ADJUSTVOLTAGE**ThisroutineadjuststhebatteryvoltagestoredinBADhifortitlecable:*dropbycallingGetDrop,anddoublestheresultifsetfor6Vbattery,:AdjVoltCALLGetBatt;getbatteryvoltageadjustedfordropCALLDouble6V;doubleBatteryvoltageifsetfor6VRET*ADJUSTAVERAGE**ThisroutineadjuststhebatteryvoltagestoredinFreshBVforthecable**dropbycallingGetDrop,anddoublestheresultifsetfor6Vbattery.*AdjAvgCALLGetDrop;getapproxbattcablevoltagedropLDA,FreshBV;getlatest(avg)batteryvoltageSUBA,Vdrop;adjustforvoltagedropincableCALLDouble6V;doubleBatteryvoltageifsetfor6VRET*GETVOLTAGEDROP**Thisroutinedetermineswhatvaluetousefortheoutputcablevoltage:*dropbasedozithevalueofOFFSET,thestateoftheoutputrelay,and*thevaluesintheDropOffslook-uptable.*GetDropLDATemp,A;saveAecunmlatorCLRVdrop;setVdropto0CLRIndex;initializeLUTindexto0IRRRlyCls'Flags4,GDX;leave0ifoutputisoffLDIIntiex,MaxDrop;maxindexforHighPowermodeGDLUTLDIDRWR,DropOffs,w;lookuptable(LUT)VdropoffsetsLDIX,DropOffs.d;initializeLUTLDA,Index;getindexfromstartofLUTANDIA,03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoACPA,OFFSET;isOFFSEThighenoughtodecreaseVdropJRNCGDX;...ifnot,skipaheadDECIndex"..otherwise,decrementindexJPGDLUT;,..andchecknexttableentryGDXLDAlndex;getVdropLUTindexLDVdrop,A;savenewdropintoVdropLDA,ATemp;restoreAccumulatorRET*GETVOLTDIGITS**Thisroutinedetermineswhatthreedigitstodisplayonthedigital*LEDtorepresentthebatteryvoltage(BADhi),GetVoltsDECVltCnt;decrementintervalcounterJRZNewVolt;if0,readytoupdatedisplayJPGetVexit"..otherwise,justexitNewVoltLDIVltCnyviS500;re-initializeintervalcounterChMode,Flags2,GVT;ifTestermode,useFreshBVCALLGetBatt;getbatteryvoltageadjustedfordropJPGV10GVTLDA,FreshBV;GetlatestaveragebatteryvoltageGV10CALLDigiOff;setregistersforallsegmentsoffCLRIndex;initializeLUTInd汰to0CPIA,VoltslO;checkfor雨JRCChecklV;ifnot10VthenskipaheadRESDigitl,DigiDat2;otherwise,turnONmostsignificant1SUBIA,VoltslO;…andsubtract10VfromaccumulatorChecklVCPIA,VoltsO1;checkif>1,OVJRCCheck01V;…ifso,skipaheadandcheck3rddigitINCIndex".'otherwise,shownexthighervalueSUBIA,VoltsOl;...andsubtract1.OVfromaccumulatorJPChecklV3'...andcheckfornexthighervalueCheckOlVLDATemp,A;saveAccumulatorLDIDRWR,DigitsOx0.w;lookuptable(LUT)for2nddigitLDIX,DigitsOx0.d;initializeLUTLDA,Index;getindexfromstartofLUTAM)IA^03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAANDA,DigiDat2;…setbitsinAforbottomsegmentsLDDigiDat2,A;…storeAintoDigiDat2LDA,入Temp;restoreAccumulatortoremainderofLEDnumShowVOOlLDIDRWR,DigitsOVx.w;lookuptable(LUT)for3rdvoltsdigitLDIX,DigitsOVx.d;initializeLUTANDIA,03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAANDA,DigiDatl;.,.setbitsinAforbottomsegmentsLDDigi)atl,A;■..storeAintoDigiDatlRESDecimal,DigiDatl;tumONdecimalpointGetVexitRET*Vol緣ter*,*Thisroutinesetsthedisplaytoshowvolts,thencallsShowMeterand*ShowDatatoupdatethedisplaywiththecurrentbatteryvoltage.**承*GetMeter**ThisroutinecallsShowMeterandShowDatatodisplaythelatest*,*voltageorpercentage(dete''"edbyMtrScale&MtrUnits)onthe对*3-digitLEf)display.GetMeieristhelastsectionofVoltMtr,*VoltMtrRESMtrScale,Flags;setforAlternator%LEDoffRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffGetMeterCALLShowData;updatedisplayRET;*GETPERCENT*;*Thisroutinedetermineswhatvaluetouseforthepercentageof*;*chargebeforethechargestatehasreachedthedv/dtstate.The*;*percentiscalculatedbyreadingthebatteryvoltage(BADhi)and*performingthefollowingcalculations:*AsTester*1.0V<BADhi<11,6VDCPercent-(BADhi/16)+1*;*n.61V<BADhi<12.8VDC==>Percent=(BADhi-175)*5+15*12.80V<BADhi=>Percent-100*,AsCharger承;*lVolt<BADhi<12Volts=>(BADhi/4)+15-Percent*;*12Volts<BADhi<dv/dt=>(BADhi/2)-30-Percent*GetPercentJRRChMode,Flags2,TstrBP;jumptoTester%notcharging;JRSChMode,Flags2,GPchg;skiptoCharging%ifchargbg;JPTstrBPotherwise,jumptoTester%jGPchgLDA,CurentSS;getcurrentprogramstateCPI人11;haschargingreacheddV/dtJRCCalcPrcnt;…ifnot,calculatepercentageGPendJPGetPctEnd"..otherwise,donothingCalcPrcntLDA,Percent;getPercentCPI乂76;checkforhighestcalculated%JRNCGPend;exitifalreadythere;JRCGPmore;continueifnotthereyet;JPGetPctEnd"..otherwise,justexit;GPmoreIRSHiPwr,Flags4,GPend;exitifinHighPowermode;JRRHiPwr,Flags4,GPl;contimieifnotinHighPowermode;JPGetPctEnd"..otherwiseJustexit;GPlCALLAdjVolt;adjustvoltageforcabledrop(&6Vscale)CPIA^Vo!tei2;isthebatteryvoltagelessthan12VJRNCFormula;...No,gotoForamla2CPIA,Volts01;Isbattery>1JRNCGPformlso,skipnextlineJPGPzero;...ifnot,setforzero%GPformiCALLDivide4;,.,Yes,usefirstformulaADDIA,15;Addl5and…JPGetPctE)dt;…storeintoAFormula2CALLDivide2;Divideby2andSUBIA,30""subtract30JPGetPctExit;skipaheadandfinishroutineTstrBPLDA,FreshBV;getlatest(avg)batteryvoltageCALLDouble6V;doubleBatteryvoltageifsetfor6VCPI入Voltsl28;Isbattery>12,WIRCTstrlOO;.,.ifnot,skipaheadCALLSetlOOp;,..otherwise,Percent^lOOJPGetPctEndandendroutineTs仕lOOCPIA,BattMin;Isbattery>BattMinJRNCTstrBPhi;…ifso,jumpaheadCPIA,Vo薩;Isbattery>1JRNCTstrBPmed;..,ifso,jumpaheadGPzeroCALLSetOp;...otherwisesetPercentto0JPGetPctEnd;…andendroutineTstrBPhiSUBIA,BattMin;subtractminimumhighvoltageCALLATimes5;nmltiplyby5ADDI入15;addl5JPGetPctExitstoreintoATstrBPmedSUBIA,15;A-battery-15CALLDivide4;A=(battery-l5)/4CALLDivide4;A-(battery-15)/l6INCA;A=(battery-15)/16+lGetPctExitLDPercent,A;storeintoPercentGetPctEndRET*UPDATEBATTERYPERCENT**Thisroutinecontrolshowthebatterypercentagedisplayedisupdated.**UpdateBPensuresthatundernormalcircumstances,thebattery%dis隱**playedisupdatedaccordingtothefollowingtworules.**1.ilie%displayeddoesn'tchangebymorethan1%atatime**2.The0/odisplayedisnotupdatedtwicein<PCintseconds**Thereareafewexceptions,**1The7odisplayedcanjumpupmorethan1ifitwas0**2.Theo/odisplayedwilldropto0immediatelyfordisconnectedbatt**3.The0/odisplayedcanchangebymorethan1ifthescale**changes****Scalereferstothe%scale,whicliiseitherbatteryoralternator*UpdateBPLDA,Percent;checkwhether%is0JRNZUBPO;,..ifno仁waitforupdateintervalJPUBPfinish;...otherwisefinishroutineUBPOLDA,DspPcnt;getlast%displayedJRZUBP00;continueifO%JPUBP1;skipaheadifnot0%UBP00JRSMtrScale,Flags,UBPl;aisoskipaheadifAlternator%JRSWaitOP,Flags2,UBPz;skipaheadifWaitOPflagalreadysetSETWaitOP,Flags2otherwise,setflagtowaitCALLIniTime2;initializeTimer2IX)ISECs2,3;setTimer2for3secondsJRRChMode,Flags2,UBPz;skipaheadifintest改modeLDISECs2)5;setTinier2for5secondsinchargermodeUBPzJRRSEC,TicF〗ag2,UBPx;skipaheadifstillwaiting;JPUBJPOa;…o&erwise,updatepercentUBPOaRESWait0PJFlags2;setflagtoindicatenotwaitingLDA,Percent;…otherwise,get加w%JPUBPfinish;...anddon'twaittodisplayUUBPxJPUHPexitandjustexitUBP1DECPwitL;decrement%intemiptcounterJKNZUBPx;ifnot0thenjustexit;JEZNewPsec;if0,decrementsecondscounter;JPUBPexit"'otherwise,justexitLDIPcntL,MSINIT;re-initialize%interuptcounterDECPcntH;decrementintervalcounterIRNZUBPx;ifnotdownto0,thenjustexit;IRZNewPrcnt;ifcounter=K),readytoupdatepercent;JPUBPexit"..otherwise,justexit;NewFrcntLDIPcn但,PCint;re~initialize%intervalcounterLDA,DspPcnt;getlast%displayedJRMZUBP2;skipaheadifnot0%LDAjPercentjgetnew%JPUBPfinish;andfinishroutineUBP2CPA,Percent;comparetonewestJRZUBPexit;ifequal,donothingJRCIncBP;ifless,increasedisplay%by1JRSChMode,Flags2,UBPexit;don'tdecrease%ifchargingDECA"..otherwise,decrease%by1JPUBPfirdsh;…旭dfinishIncBPINCA;increasedisplay%by1UBPfinishLDDspPcnt,A;storeupdateddisplay%UBPexitRET*Ho咖um**ThisroutinecallsNumDatatodisplayLEDnumonthe3_digitLEDdisplay,then柳its200mSandloadsLEDnumintoA,*HoldNumCALLNumData;getdatafor,andshowLEDnumberCALLFifthSecond;waitonefifthsecondCALLFi池Second;waitonefifthsecondAjUSDnum;checklatestnumberRET*MsterNum**ThisroutinecallsModeOff:ShowNum,andShowDatatoturnoffthe:*displaymodeLED'sanddisplayLEDnumonthe3-digitLEDdisplay.***NumData**ThisroutinecallsShowNumandShowDatatodisplayLEDnumonthe*3-digitLEDdisplay,NumDataisthelastsectionofMeterNum.*MeterNuniCALLModeOff;turnoffalldisplaymodeLED'sNumDataCALLShowNum;getdatatoshowthenumberCALLShowData;showthenumberRET*SHOWDATA**ThisroutineupdatesthedigitalLEDand6switchLEDscontrolledby:*theserialtoparallelshiftregisters.ItsendsthebitsofSwData**andDigiDatatotheregistersbitbybitfromLSBtoMSBusing**SerData.Aftereachbitissent,SkftClkistoggledtoshiftthebit**tothenextposition.Afterall24bitshavebeensent,LtchClkis**usedtoupdatetheoutputs,whichupdatestheLEDs.*ShowDataCALLRstWDR;resetwatchdogtimerRESClrData,DRAbuf;clearshiftregisterCALLUpdatePA;updateportAfrombufferSETClrData,DRAbuf;preparetoacceptdataCALLUpdatePA;updateportAfromtufferLDIBitCnt,008h;initializebitcounterto8LDIBytCnt,003h;initializiebytecounterto3LDA,DigiDatl;getfirst8bitsofdigitdataGe舰RLCA;sendMSBofAcumulatortoCarryJRCSetB仕;ifCarry=lthendatabitis1RESSerData,DRAbuf"..otherwisesetSerDatato0JPSendBit;skipaheadtoSendBitSetBitSETSerData,DRAbuf;setSerDatato1SendBitLDDataBuf,A;storeshifteddatafromACALLUpdatePA;updateportAfrombufferRESShflClk,DRBbuf;setShiftClocklowRESLtchClk,DRBbuf;setLatchClocklowCALLUpdatePB;updateportBfrombufferSETShftClk,DRBbuf;setShiftClockhighCALLUpdatePB;updateportBfrombufferDECBitCnt;updatebitcountJRZNextData;ifallbitssentthenskipaheadJPGetBit;otherwise,getnextbitNextDataDECBytCnt拜datebytecountJRNZ^FextByte;getnextbyteiscountis加t0JPLatchData""otherwise,donesendingbitsNextByteLDIBitCnt,08h;setbitcountfor8morebitsLDA,BytCnt;whichbyteisnextCPIA,02h;checkfor2ndbyteis織tJRZScndByte;skipaheadifequalLDA,SwData;get8bitsofswitchLEDdataJPGetBit;sendbitsofsecondbyteScndByteLDA,DigiDat2;getlast8bitsofdigitdataJPGetBit;sendbiteofsecondbyteLatchDataSETLtchCik,DRBbuf;updatelatchesCALLUpdatePB;updateportBfrombufferRET;*ShowMeter*;*ThisroutinesetsttedigitalLEDtoshoweitherthecurrentvoltage*;*orlastpercentbasedonFlagsandCurentSS.DuringEnginestart,it*;*willcountdownsecondsofeitherremainingcranktimeorcooldown;*time.*ShowMeterJRSAlert,Flags2,SMeXit;exitifabortmode;IRRAlert,Flags2,ChkMtr;skipaheadifnotabortmode;JPSMeXit;響..andexit;ChkMtrJRSMtrUnits,Flags,GetPrait;skipaheadandsetfor%CALLGetVoltsotherwise,getvoltsJRSChMode,Flags2,SMl;skipaheadifnotinTestermodeCALLShowStatus"..otherwise,updateStatusLEDsSMIJPShowMtrX;...andskiptoendorroutineGetPrcnt;JRSCliMo(2e,Fkgs2,SlioPer;ifnottestermode,show%JRRChMode,Flags2,TstMtr;ifintester迈ode,get%JPShowPrcnt"..otherwise,skipahead&show%ShowOALLSet0p;s改toshow0o/oShoPerJPShowPrcnt;andskipaheadTstMtrLDA,FreshBV;getlatestBatteryvoltageJRZShowO;ifOV,showO%IRRMtrScale,Flags,SlioPer;sliowBattery0/。ifnotsetforAlt%;JRSMtrScale:Hags,AltTest;skipaheadifsetforAlt0/o;JPShowPrcnt"..otherwise,skiptoBattery%;AltTestCALLDouble6V;doubleBatteryvoltageifsetfor6VCPIA,AltMin;checkfor<1stLUTvalueIRCShowO;ifso,show0o/o;JRNCAltMaxT;ifnot,testfor>lastLUTvalue;JPShow0otherwise,show0%jAlMaxTCPIA,AltMax;checkfor>lastLUTvalueJRCAltVal;ifnot,skipaheadandcheckLUTLDIPercent,199;…o^ierwise,settomaxvalueJPShowPrcnt口ndskipaheadAltValLDIDRWR,AltLvls,w;LUTforalternator%LDIX,AltLvls,d;initializeLUTSUBIAjAltMin;diffenceisindexinlookuptableANDIA,03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofva〗ueinXLDA,(X);storevalueatXintoALDPercent,A;storevalueintoPercent;JPShowPrcnt;andskipaheadShowPrcntCALLShowPercent;otherwise,showpercentageCALLShowStatus;turnonappropriatestatusLEDShowMtrXCALLShoMtrMode;turaonappropriatemeterLEDSMeXitCALLRstWDR;resetwatchdogtimerRET;*SHOWMETERMODE*;*ThisroutineturnsononeofthemeterunitsLED'sbasedonFlagsand*;*Flags2.IftheunitisinTesterMode(ChMode=0),theroutinewill*;*alsolighttheappropriatestatusLEDbasedonthevoltageatthe*^*clamps.*ShoMtrModeSETLEDvolt,DRAbuf;tumoffDCVoltageLEDSETLEDprcnt,DRAbuf;turnoffBattery%LEDSETLEDalt,DRAbuf;turaoffAlternator%LEDShowVoltsJRSMtrUnits,Flags,ShoPrcnt;gotoShoPrcntifsetRESLEDvok,DRAbuf;加monVoltageLEDJPShowMMXShoPrcntJRSMtrSca!e,FIags,ShowAIt;gotoShowAltifsetRESLEDprcnt,DRAbuf;tumonBattery%LEDJPShowMMXShowAltRESLEDalt,DRAbuf;turnonAlternator%LEDShowMMXCALLUpdatePA;updateportAfrombufferRETHoldMeterModeLED(dependingonmode)*ThisroutineturnsontheBatteryo/o,VoltsDC,orAlternator%LEDbased;*onFlags&Flags2andkeepsthatLEDonforonefi他second.*koldMtrMdCALLShoMtiMode;turnondisplaymodeLEDCAIXFi池Second;waitonefif^isecondRET*SHOWSTATUS**ThisroutineturnsononeofthethreestatusLED'sbasedonthe**batteryvoltage.Thisroutineisforuseinthetestermode.*ShowStatusJRSChMode,Flags2,ShoStatX;exitifnotTestermode;JRRChMode,Flags2,TstrStat;checkforTestermode;JPShoStatX;ifnot,skiptoend;TstrStatJRRBatt,Flags2,RedStat;showredLEDifnobattery;JRSBatt,Flags2,StatBatt;skipaheadifbatteryconnected;JPRedStat;shcrwredLEDifnobattery;StatBattJRRMtrUnits,Flags,ClrStat;turnoffStatusLED'sifvoltsmode;JRSMtrUnits,FJags,SfatPrcnC;skipaheadifnotshowingvoltage;JPClrStat"..otherwise,turnStatusLED'soff;StatPrcntLDA,FreshBV;getlatestBatteryvoltageJRSMtrScale,Hags,TestAlt;skipaheadifsetforAlternatorLDA,DspPcnt;getlast%displayedCPIAJ00;IsitlOOJRZGrnBatt;…ifso,showgreenLEDCALLResetStatus"..otherwise,turnStatusLED'soffJPShoStatX;.,'andskiptoendGrnBattCALLShowGreen;turnonGreenLEDJPShoStaiX;skiptoendTestAltCALLDouble6V;doubleBatteryvoltageifsetfor6VCPIA,Volts15a;Isalternatoratleast15.07VJRNCRedStat;…ifso,skipaheadandshowredCPIA,Volts138;isalternatoratleast13.80VJRCRedStat;...ifnot,skipaheadandshowredCPIA,Volts14;Isalternator<14屈JRCClrStat;,.ifso,skipaheadandshowyellowCPIA,Volts149;isalternatoratleast14.87VJRNCClrStat;…ifso,skipaheadandshowyellowCALLShowGreen".otherwiseturnonGreenLEDJPShoStatX""andskiptoendRedStatCALLShowRed;tuinonRedLEDJPShoStatX;skiptoendClrStatCALLResetStatus;tumStatusLED'soffShoStatXRET*METEROFF**ThisroutineturnsoffthethreedispkymodeLED's.ModeOffSETLEDvo化DRAbuf;tunaoffDCVofageLEDSETLEDprcnt,DRAbuf;tumoffBattery%LEDSETLEDalt,DRAbuf;tumoffAlternator。/0LEDCALLU"pdatePA;updateportAfrombufferRET*DigiOff**Thisroutinesettheregisterstoturnoffthethree-digitLED.*DigiOffLMDigiDatl,DigiOffa;tumoff8of16digitalsegmentsLDIDigiDat2,DigKDffb;turnoffother8of16digitalsegmentsRET*DIGITSOFF**Thisroutineturnsoffthethree-digitLED.DigitsOffCALLDigiOff;setregistersforallsegmentsoffCALLShowData;updatedisplayRET*DIGITSON**ThisroutineturnsONallsegmentsofthethree-digitLED.DigitsONLDIDigiDatl'DigiONa;turnON8of16digitalsegmentsLDIDigiDat2,DigiONb;turnONother8of16digitalsegmentsCALLShowData;updatedisplayRET*SHOWPERCENT**ThisroutineturnsONtheBattery0/。LED.ShowPercentSETMtrUnits,Flags;setFlagsfor%(notvolts)JRRWaitOP,Flags2,SPl;skipaheadifnotwaitingfrom0LDIDigiDatl,Dashes1otherwise,showdasheswhilewaitingLDIDigiDat2,Dashes2;…otherwise,showdasheswhilewaitingJPShowPxIDA,DspPcnt;getPercentvaluetodisplayJRRMtrScale,Flags,SP2;don'tuseDisplay%forAltemator%LDA,Percent;..,useactualPercentfordisplay.IFCEQShoOff;assemblenextlineonlyifdebuggingJRRChMode,Flags2,SP2;skipahead**DEBUG**LDA,CurentSS;getcurrentstate**DEBUG**CPIA,12;checkfordi/dtorhigherstate**DEBUG**JRNCSP3;don'tshowV迈axifstate>11LDA,Vmax;getlimitfordV/dt**DEBUG**JPSP4;don'tshowMaintVoltifstate<12SP3LDA,MaintVolt;getlimitforVoltReg&di/dtSP4CALLGV10;shcwvoltageondigitalLEDJPShowPx;LDA,OFFSET;dispkyOFFSET**DEBUG**;msRmpng,Flags3,SP2;**DEBUG**;LDA,RmpCnt;displayRampCount**DEBUG**.ENDCSP2LDLEDnum,A;.andstoreitinAccumulatorCALLShowN咖;setdigitalLEDforLEDnumSETDecimal,DigiDatl;turnOFFdecimalpointShowPxRET:RESETLEDS承:ThisroutineturnsofftheType,Rate,andStatusLED'sCLEARLEDS*'ThisroutineturnsofftheTypeandRateLED's.*ResetLEDsCALLResetStatus;turnoffallthreestatusLEDsClrLEDsLDISwData,SwsOff;turnoffTypeandRateLED'sRET*ResetStatus**ThisroutineturnsofftheLED'sintheStatusarea.ResetStatusSETLEDchgng"RAbuf;tumoffChargingLEDSETLEDdone,DRAbuf;turnoffChargedLEDSETLEDalert,DRAbuf;turnoffFault(red)LEDRET*BLINKChargingLED**ThisroutineblinkstheChargingLEDatarateofoncepersecond.BlnkChrgLDA,MSECsl;getMSECscountCPIA,MS500;testfor>1/2secJRNCBlinkCM;ifso,skipaheadCALLResetStatus"..otherwise,turnoffstatusLEDsJPBlinkChX;…andexitroutineBlinkCMCALLShowChgng;T咖onChargingLEDBlinkChXRET;*ShewCharging*;*ThisroutineturnstheChargingLEDonandtheCheckandChargedLEDs*;*off.*;承ShowYdlow*:*ThisroutineturnstheChargingLEDonanddoesnotaffecttheCheck*'*andChargedLEDs.ShowYellowisactuallythelastpartofShowChgng*ShowChgngCALLResetStatus;turnoffallStatusLEDsShowYellowRESLEDchgng,DRAbuf;turnONChargingLEDCALLUpdatePA;updateportAfrombufferRET;*BLINKAlertLED*;*ThisroutineblinkstheAlertLEDatarateofoncepersecond.**BIinkAIertLDAjMSECsl;getMSECscountCPIA,MS500;testfor1/2secJENCBlnkAlrt;ifso,skipaieadCALLResetLBDs;…otherwise,turnoffallLEDsJRSBumln,Flags3,BBI;skipaheadifnotBum-InCALLDigitsON;...turncmaUdigitalLEDsegmentsJPBAeXit;...andexitroutineBBICALLNuniData;getdatafor'andshowLEDnumberJPBAeXit;...andexitroutineBlnkAlrtCALLAlertON;TurnonAlertLEDCALLDigitsOff;T咖off3-digitLEDBAeXitRET*AlertLEDON*,*ThisroutineturnsontheAlert(red)LEDandturnstheothermeter*;*LEDsoff.NOTE:itdoesnotaffecttheRateandTypeLEDs.*AlertONCALLModeOff;T咖offdisplaymodeLEDsShowRedCALLResetStatus;TurnoffStatusLEDsRESLEDalert,DRAbuf;Turn。nAlertLEDCALLUpdatePA;updateportAfrombufferRET*ShowDoneLED**ThisroutineturnsontheDone(green)LEDandturnsalltheother*LEDsoff.NOTE:itturnsofftheRateandTypeLEDs.*ShowDoneCALLResetLEDs;TumoffallLEDsLDISwData,SwsOff;setType&RateLED'soffCALLShowType;showbatterytype&updatedisplayShowGreen-CALLResetStatus;turnoffallthreestatusLEDsRESLEDdone,DRAbuf;TurnonDoneLEDCALLUpdatePA;updateportAfrombufferRET;*BLINKCrankLED*;*ThisroutineblinkstheCrankLEDatarateofoncepersecond.BlinkCrankLDA,MSECs2;getMSECscountCPIA,MS500;testfor>1/2secIRNCBlinkES;ifso,skipaheadSETLEDboost,SwData;...o也erwise,turnoffCrankLEDJPBCeXit;...andexitroutineBlinkESCALLShcwCrank;tumonCrankLEDBCeXitRETShowCrank**ThisroutineturnstheEngineStart(Crank/Boost)LEDonandturns:*theTypeandotherRateLEDsoff.**NOTE:The6VLEDwillbeleftonifappropriate.*ShowCrankCALLClrLEDs;tumoffallRate&TypeLEDsJRRBat6V,FIags2,ShoES;skipaheadifnot6VRESLED6V,SwData;turnonRegular6VLEDShoESRESLEDboost,SwData;加mONCrankLEDCALLShowData;updatedisplayRET;*SetSlow<formula>formulaseeoriginaldocumentpage131</formula>ShowTypsSETLEDreg,SwData;setRegularLEDtoo任SETLEDdeep,SwData;setDeepCycleLEDtooffSETLEDgel,SwData;setGel/AGMLEDtooffSETLED6V,SwData;set6VLEDtooffJRRBat6V,Flags2,ShowTl;sMpaheadifnot6VShowTORESLHD(5V,SwData;turnonRegular6VLEDJPShowT2a;setVnm;forregular(15.5V)ShowTlJRRBatTypeB,Flags,ShowT2;skipaheadifnotGel/AGMRESLEDgel,SwData;加rnonGd/AGMLEDLDIV边ax,Volts144;Vmax=14.4VforGel/AGMMODEJPShoTypeXShowT2JRSBatTypeA,Flags,ShowT3;gotoShowT3ifsetRESLEDreg,SwData;turnonRegularLEDShowT2aLDIVmax,Voltsl5:5;V迈ax-15.:SVforRegularMODEJPShoTypeXShowT3RESLEDde印,SwData;turnonDeepCycleLEDLDIVmax,Voltsl6;Vmax=16VforDeepCyclebatteryShoTypeXRET*HoldChargeTypeLED(dependingonmode)**ThisroutineturnsontheRegular,DeepCycle,orGel/AGMLEDbasedon'*Flagsandkeepsitonforonefifthsecond.*HoldTypeCAULShowType;turnonBatteiyTypeLEDCALLShowData;updatedisplayCALLFi他Second;waitonefifthsecondRET*HoldChargeRateLED(dependingonmode)**ThisroutineturnsontheSlow,Fast,orRapidLEDbasedonFlagsand*keepsitonforonefifthsecond.*HoldRateCALLShowRate;turnonChargeRateLEDCALLNumData;getdatafor,andshownominalrate(amps)CALLFi他Second;waitonefifthsecondRET*CheckOV*;*Thisroutinechecksthelatestrunningaverageofthebatteiyvoltage:*andsetstheCanybitifit'slessthanVoltsO+1DACcount.This**routineisusedtocheckwhetherabatteryisconnected.*CheckOVIDA,FresKBV;testlatestaveragevoltageCPIA,VoltsO+l;checkifhigherthanzeroRET;*Checkl7v*;*Thisroutinechecksthelatestrunningaverageofthebatteryvoltage;*andsetstheCarrybitifit'slessthanMaxVolts.Thisroutineis*;*usedtocheckwhetherabatteryisconnected.*Checkl7vLDA,FreshBV;testlatestaveragevoltage;LDA,BADhi;testaveragevoltageCPIA,MaxVolts;checkformaxvoltreadingRET;*CheckBattery*;*CheckBattcomparesthelatest32sample(l/4second)averagebattery*;*voltage,FreshBV,tothemaximumpossiblebattery"voltagereading,17V,;*IfFreshBVis17V,thenthebatterywasdisconnected.CheckBattalso*;*checkswhetherthevoltageislessthan1,0V.Ifso,Flags2issetfor*;*加batterydetected.*CheckBattSETBatt,Flags2;setflagforconnectedbatteryJRSSettle,Flags3,ChkBattX;dontclieckduringsettletimeLDA,FreshBV;Getlatest1/4secondaveragevoltage;LDA,CurVolt;GetlatestbatteryvoltageJRRBat6V,Flags2,ChkBatt4;skipnextlineifnotsetfor6VBattJRRHi6V,Flags4,ChkBatt4;skipnextlineif6Vbatt<8.5V;JRSStarted,Flags,ChkBatt3;abortchargeif6Vbatt>8.5VJRSStarted,Flags,NoBatt;setfornobattif6Vbatt>8.5VChkBatt4CPIA,穆sOl;IsitatleastIVIRCNoBatt;Ifnot,batteryisnotconnected;JRNCChkBattO;Ifso,batterymightbeconnected;JPNoBatt;Ifnot,batteryisnotconnected;CbkBattOCPIA,MaxVolts".otherwise,checkformaxvoltreadingIRNZChkBatX;ifjqo仁thenstillconnectedsojustexit;JRZChkBattl;if=MaxVolts,mightnotbeconnected;IPChkBattXotherwise,stillconnected,justexit;ChkBattlJRRSOC,Sv/Down,ChkBatt2;skipaheadifcliargestarted0-5secagoChkBatt3CALLSetAbort;settostartAbortmodeChkBatXJPChkBattXjumptoendofCheckBattChkBatt2LDA,BADhi;iftrulyMaxVolts,BADhishouldbe>16VCPIA,Volts16;ifBADhi<16V,thendisconnectedJRNCChkBattX"..otherwise,justexit;JRCNoBatt;…sosetfornobattery;JPChkBattXotherwise,justexitNoBattRESBatt,Flags2;otherwise,setfornotconnectedCALLShowRed;turnonAlert(Red)LEDCALLClrPcnt;clearPercentandDisplayPercentCLRBADhi;clearpreviousvoltagereadingCLUFreshBV;clearpreviousvoltagereadingChkBattXRET*CheckProgress**Thisroutineisusedtoensurethatthechargerwillabortifthe**batteryvoltagedoesnotincreasethroughoutthecharge.Itchecksthe:承voltageeveryGPintminutesforameasurableincreasesincethe承*previouscheck.Ifthereisn't,thechargeisaborted.*CMProgJRRMIN,TicFagl,ChkProgX;exitifnottimetocheckforprogressChkProgOJRRSOC,SwDown,ChkProgl;skipaheadifnotStartOfChargeRESSOC,SwDown""otherwise,clearSOCflagCALLIniTime1;initializeTimerlLDIMINsl,5;,..setTimerlfor5minutesCLRLastBatt;clearLasiBatt(ensurepass1sttest)JPChkProgX;...andexitChkProglLDA,BADhi;getlatestbatteryreadingSUBIA,l;subtractonecountCPA,LastBatt;checkforincreaseJRCChkProgA;settoabortifnoincreaseLDA,BADhi;setAbacktoBADhiLDLastBatt,A;updateLastBattCALL/IniTimel^initializeTimerl.IFCNEFastCP;assemblenextlineonlyifnotdebuggingLDIMINs1,CPint;setTimerlfor60minutes.ELSE;assemblenextlineonlyifdebuggingLDIMINs1,3jsetTimerlfor3mins.ENDCDECCCDcnt;updateintervalcountJRNZChkProgX;justexitifnotzeroSETHR,TicFlag1;ifzero,setfortimeexpiredChkProgACALLSetAbort;settostartAbortmodeChkProgXRET*BatteryProgress**ThisroutineisusedtoensurethatChkProgandCheckBattarecalled**onlywhenthechargerateisabouttorampuporisn'tsettorampat**all.Thatway,thebatteryvoltageusedtocheckchargingprogress**won'tbeaffectedbythehighercurrent.BattProgworksbydiecking*;*RmpCnttomakesureifslessthan5,Ifthestartofchargeflag(SOC)*;*isset,BattProgdoesnotcheckRmpCnt.*,承*BattProgJRRRmpng,FJags3,BtPrgO;skipaheadifnotRapid->FasttransitionCALLRampOS;otherwise,graduallyreducedutycycleBiPrgOCLRA;setAto0toensure<(9,12,or14.2V)JRSHiFwr,Flags4,BtPrgX;exitifhighpowermode;JRRHiPwr,Flags4,BtPrgl;skipaheadifnothighpowermode;JPBtPrgX"..otherwise,justexit;BtPrglJRSSOC,SwDown,BtPrg2;skipaheadifStartOfChargeLDA,RmpCnt;getRampintervalcounter;NOTE:RmpCntwillbe0ifnotsettorampatallCPIA,5;isitalmosttimetorampupJRNCBtPrgX;ifnot,thenexitBtPrg2CALLChkProg;checkforchargingprogressCALLAdjVolt;adjustvoltageforcabledrop(&6Vscale)BtPrgXRET:CheckDip*:CheckDipcomparesthelatest32sample(l/4second)averagebattery*:voltage,FreshBV,tothemaintainvoltageusedbyVoltReg,MaintVolt,*'IfFresfaBVismorethan0.5VbelowtheMaintVolttheCheckDipchecks:thedutycycle.IfOFFSETisbetweenOffSlowandHiOff,thenthe*:chargecurrentismorethan0butlessthantheSlowrate(usually2A).*:Inthatcase,thebatterywasprobablydisconnectedCheckDipraises*:thechargeratetoSlowbysettingOFFSETtoOSSlow,CheckDipalso*:re-initializestheVoltRegintervalcounter,VRcnt,sothatVoltReg*:won'tadjustOFFSETagainforanothersecond.Ifthebatteryreally*:wasdisconnected,theoutputwillshootto17VandCheckBattwill*:indicatenobattery.Ifthereisabatteryconnected,thentheoutput*:neededaboosttoraisethevoltage.*:NOTES:*:CheckDipisonlycalledbyVoltReg,sotheoutputmustbeon.*:VoltRegisonlycalledwhenthechargerisnotinhighpowermode.*fIfOFFSETifHiOff,thentheoutputiszero.*CheckDipCALLAdjAvg;getFreshBVadjustedforcabledropand6VADDIA,Vo謹5;add1/2voltCPA,MaintVot;comparewithsetvalue+1JRCChkDpl;ifFreshBV<MaintVoit-0.5V,continueJPChkDipX;…otherwise,exitroutineChkDplLDA,OFFS3BT;getOFFSETCPIA,OffSlow;checkforrate>SlowJRCChkDipX;exitif>Slow;JRNCChkDp2;ifrate<Slow,thencontinue;JPChkDipX"..otherwise,exitroutine;ChkDp2CPIA,HiOff;testifoutputiso任JENCChkDipX;ifso,justexitLDIOFFSET,Offilow;…otherwise,setforSlowrateLDIVRcnt,MSINTT;re-initializeinitervalcounter(1sec)ChkDipXRET;*CHECKSWITCHES*;*Checkifswitchisengagedandchangemodesifappropriate,*CheckSwJRRCrankWait-Flags,ChkStart;checkswitchesifnotduringCrankwaitJPChkSwRET;don'tcheckswitchesifduringCrankwaitChkStartJRSCrank,Flags,ChekRate;don'tcheckdisplaymodeduringBoost;JRRCrank,Fkgs,ChkMeter;checkdisplaymodeifnotduringBoost;JPChkRate;skipdisplaymodeswitchduringBoost;ChkMeterIRRMeterSw,DRC,MeterDown;Ifswitchisbeingpressed,skipaheadRESMeterSw,SwDown;setforMeterswitchnotpressed(up)ChekRateJPChkRate;Meterswitchnotpressed,soexitCheckSwMeterDownRESIdle,Fkgs3;setfornotidleJRSMeterSw,SwDown,ChekRate;Ifswitchwasn'treleased,don'tcheckit;JRRMeterSw,SwDown,ChngMeter;Ifswitchwasreleased,thencheckit;JPChkRate;Otherwise,skipahead;ChngMeter;changedisplay迈odeSETMeterSw,SwDown;setformodeswitchpressed(down)IRRMtrScale,Flags,ChkPrcnt;ifnotsetforAlt,thenskipaheadRESMtrScale,Flags;setforAlt%,sochangetoBatt%;CLRDspPcnt;preparetoshownew%(notadjustold%)JPChkRateChkPrcntJRRMtrUnits,Flags,ChkAlt;ifsetforvolts,thenskipaheadRESMtrUnits,Flags;setforBatt%,sochangetovoltsJPChkRateChkAltSETMtrUnits,Flags;setforvolts,sochangeto%,IFCNEShoOff;assembienextlineonlyifnotdebuggingJRSChMode,Flags2,ChkRate;donltsetforAltifchargingENDCSETMtrScale,Flags;setforbatt,sochangetoaltRESWaitOP,Flags2;settostopwaitingforbattery%;CLRDspPcnt;preparetoshownew%(notadjustold%)ChkRateCALLShoMtrMode;MeterunitsaresetbeforerateJRRRateSw,DRC,RateDown;Ifswitchisbeingpressed,skipaheadRESRateSw,SwDown;setforRateswitchnotpressed(up)ChekTypeJPCbkType;Rateswitchnotpressed,socheckTypeRateDownRESIdle,Flags3;setfornotidleJRSRateSw,SwDown,ChekType;Ifswitchwasn'treleased,don'tcheckit;JRRRateSw,SwDown,Chngkate;Ifswitchwasreleased,thencheckit;JPChkType;Otherwise,skipaheadtoTypeSwitch;ChngRate;changeChargeRateSETRateSw,SwDown;setformodeswitchpressed(down)瓜SChMode,Flags2,ChkCM;skipaheadifalreadyChargermodeSETCrank,Flags;,..otherwisetemporarilysetCrankflagRESDisable,DRBbuf;enableoutputafterRateispressed;JRRMtrScale,Flags,ChkCM;skipaheadifnotsetforAlt%;CLRDspPcnt"..otherwise,don'tuseAlt%forchargeRESMtrScale,:Flags;setforBatt%(notAlt%)whennottesterChkCMSETChMode,Flags2;setforCharger(nottester)ModeJRRCrank,Flags'ChkSIow;ifnotsetforCrank,checkforSlowRESCrank^Flags;clearCrankbitofFlagsRESRate,Flags;wasCrank,sosetforSlowJPModeChange;gotoendofCheckSwChkSlow;ifsetforSlow,tibenchangetoFastJRSRate,Flags,ChkFast;IfnotStow,thencheckFastSETRate,Flags;,.,otherwise,setrateforFastJPModeChange;gotoendofCheckSwChkFast;ifsetforFast,thenchangetoRapidJRSRapid,Flags2,ChkES;IfnotRapid,thenmustbeFastSETRapid,Flags2;setChargerateforRapidJPModeChange;gotoendofCheckSwChkES;wassettoRapid,changetoBoostCALLSetSlow;setforSlowRateSETCrankjFlags;setChargerateforBoostCALLSetReg;setbatterytypeforRegularCALLShowCrank;turnONCrankLEDCALLTurnOff;openrelayandsetformindutycycleCALLSetSafe;setOFFSETforOffSafe(5A)whenrelayclosesLDIQirentSS,CrankSS;setChargestatetoCrankCALLIniTime2;resettimer2LDISECs2,003h;setTimer2for3secondsJPChkSwRE丁ChkType;ifGel/AGM,thensetforRegularJERTypeSw,DRC,TypeDown;IfSwitchisbeingpressed,skipaheadRESTypeSw,SwDown;setforTypeswitchnotpressed(up)ChkSwXJPChkSwRET;Typeswitch加tpressed,soexitCheckSwTypeDownRESIdle,Flags3;setfornotidle爪STypeSw,SwDown,ChkSwX;IfSwitchwasn'treleased,don'tcheckit;JRRTypeSw,SwDown,ChngType;IfSwitchwasreleased,thencheckit;JPChkSwRET;Otherwise,justexit;ChngType;changeBatteryTypeSETTypeSw,SwDown;setformodeswitchpressed(down)JRRBat6V,Flags2,ChkBTl;Ifnotsetfor6V,checkforRegularChkBTO;ifsetfor6V,changeto12VregularRES服V,Flags4;clear6VovervoltageflagCALLSetl2V;setforRegular,12VbatteryCALLCbPcnt;clearPercentandDisplayPercentJPTypeChange;gotoendofCheckSwC腿T1;ifsetforAGM/Gel,changeto6VJRRBatTypeB,Flags,ChkBT2;If加tsetforGel/AGM,checkforRegularJRSHi6V,Flags4,ChkBT0;doi^tsetto6Vifbatt>8.5VCALLSetReg;setbatterytypeforRegularSETBat6V,Hags2;setfor6VbatteryCALLClrPcnt;clearPercentandDisplayPercentIPTypeChange;gotoendofCheck^wChkBT2;ifRegular,thensetforDeepCycleJRSBatTypeA,Flags,ChkBT3;IfnotsetforRegular,mustbeDeepCycleSETBatType入Flags;setbatterytypeforDeepCycleRESBatTypeB,Flags;setbatteryt^)enotAGM/GelJPTypeChange;gotoendo£CheckSwChkBT3;mustbeDeepCycle,sosetforGel/AGMSETBatTypeB,Flags;setbatterytypeforGel/AGMRESBatTypeA,Flags;setbatterytypefornotDeepCycleTypeChangeRESCrank,Flags;setchargeratefornon-BoostCALLShowType;turnonBatteryTypeLEDModeChangeRESCrankjFlags;clearCrankbitofFlagsLDICurentSS,000h;restartchargingChkSwRETRETFANON**ThisroutineturnsthecoolingfanON,FanONiscalledduringoneof*thefollowingcoiuMons--**1,Startofcharge(endofState2).**2.Startofboost(State16)*矛'3.IfOFFSET<HiOff-3inMaintain(State14)**4.ManualMode(State15)**5.States4,5,11,12,and13*FanONLDATemp,A;saveAccumulatorLDIA,OOO10000b;updateAccumulatorfrombufferLDDRC,A;updateportfromAccumulatorLDA,ATemp;restoreAccumulatorRET*FANOff*:*Thisroutineturnsthecoolingfanoff.FanOffiscalledduringoneof**thefollowingconditions:*:*1.Beforestartofcharge(State0)*;*2.StartofAbort(State8)**3.BeforestartofMaintain(State14)**4.IfOFFSET-HiOffinMaintain(State14)*FanOffLDATemp,A;saveAccumulatorLDIA,00000000b;updateAccumulatorfrombufferLDDRC,A;updateportfromAccumulatorLDA,ATemp;restoreAccumulatorRET;*ShutOff*Thisroutinesetsthechargerfornoouputbyopeningtheoutput*I*relay,turningoffthefan,andsettingtfieP^Mformininmmduty;*cycle(HiOFF).*:*TumOff*;*Thisroutinesetsthechargerfornoouputbyopeningtheoutput*relayandsettingthePWMforminimumdutycycle(HiOFF),TumOffis*,actuallypartofShutOff.*ShutOffCALLFanOff;turncoolingfanoffTumOffIRHRlyCls,Flags4,TniOffX;finishifrelayalreadyopenLDIOFFSET,Offiafe;setforSafedutycycleCALLFifthSecond;wait200msbeforeopeningrelayRESRlyCls,Flags4;openoutputRelayCALLFifthSecond;wait200迈sbeforereducingdutycycleTmOffXLDIOEFSKT,HiOff;setforminimumdutycycleRET*TuruON**ThisroutinesetsthechargertorunwiththeChargingLEDandfanon,andtheoutputrelayclosed,*;*SetON*;*Thisroutinesetsthechargertorunwiththefanonatidoutputrelay:*closed.SetONisactuallypartofTumON*TurnONCALLShowChgng;tumChargingLEDonSetONCALLFanON;turncoolingfanonSETRlyCls,Flags4;closeoutputrelayRET*Updatetheclocksandsetoverflowflagsasnecessary,*TicFkgl(s)bit0=hourswenttozero**TicFlagl(s)bit1=minuteswenttozero**TicFlagl(s)bit2=secondswenttozero**TidFlagl(s)bit3=milisecondswenttozero*CLOCKSDECMSBCsl;decrementmillisecondcounter;JRZDOMSECs;JPCLOCKS1JKNZClksl;skiptoclock2ifMSECsoODO一MSECsix5A'MSINIT;restartmillisecondcounterLDMSECsI,A;SETMSEC,TicFlagl;setmillisecflagDECSECsl;decrementsecondcounterJRZDO一MINsClkslJPCLOCKS1DO—MINsSE亍SEC,TicFlag1;setsecondexpiredflagLDISECs1,SecInit;restartsecondcounterDECMNs1;decrementminutecounter;JRZDO—HRs;checkforoverflow'-jpclo5ksi,ZCLOCKS1;skipHRslifMINsldowntozeroDO—HRsSE亍MIN,TicFlag1;setminuteexpiredflagLDIMINs1,MININTT;restartminutecounterDECHRs1;decrementhourcounterJRNZCLOCKS1;checkforoverflowSETHR,TicFlagl;sethourexpiredflagCLOCKS1DECMSECs2;decrementmillisecondcounterjkzDOMSECs2ClkExitJPCLOCEXITDOMSECs2LDIA,MSIMT;restartmillisecondcounter;LDMSECs2,A;SETMSEC,TicFlag2;setmillisecflagDECSECs2;decrementsecondcounter;JRZDO一MINs2;JPCL05EXITIRNZClkExit;exitifnotdowntozeroDO—MINs2SE亍SEC,TicFlag2;setsecondexpiredflagLDISECs2,SecInit;restartsecondcounterDECMINs2;decrementminutecounter;JRZDO—HRs2;checkforoverflow;JPCLo5EXITJRNZCLOCEXIT;exitifnotdowntozeroDO一孤s2SE亍MIN,TicFlag2;setminuteexpiredflagLDIMINs2,MININIT;restartminutecounterDECHRs2;decrementhourcounterJRNZCLOCEXIT;checkforoverflowSETHR,TicFlag2;sethourexpiredflagCLOCEXITRET;*INITIALIZET應Rl*Subroutinetoinitializetimerl*IniTimelLDIMSECsI,MSINITLDISECsl,SecInitLDIMINsl,MININITCLRHRsiCLRTicFlaglRETINITIALIZETMER2*SubroutinetoinitializeTimer2IniTime2LDIMSECs2,MSIMTLDISECs2,SecInitLDIMINs2,MININ[TCLRHRs2CLRTicFlag2RET*ShiftA7**Subroutinetoshifttheaccumulatorleft7times.UsedbyDivide2*andDivide4.Writtenonlytosavecodespace.*ShiftA7SLAA;shiftleftRLCA;rotateleftthroughCARRYbit6timesRLCARLCARLCARLCARLCARET*DIVIDEBY2**SubroutinetodividethenumberinAby2.Theremainder,ifany*willbeavailableinthecarrybituponreturn.*Divide2CALLS础A7;shiftleftoncethenrotateleft7timesRLCA;rotateleft7thtimeRET*DIVIDEBY4**SubroutinetodividethenumberinAby4.Divide4CALLShiftA7;shiftleftoncethenrotateleft7timesANDIA,01111111b;dropMSBRET;*ATimes5*;*Subroutinetomultiplytheaccumulator(A)by5.*;*Atimes5multplies入by4byshiftingleAtwicethenaddingthe*originalvalueofA:(A*4)+A=A*5*ATimes5LDATemp,A;ATemp=AADDA,A.;A-A+A=A*2ADDA,A;A-A+A=ATemp*4ADDA,ATemp;A=A+AT咖p=ATemp*5RET;*VOLTAGEREGULATION*;*ThissubroutinewilladjustthevalueofOFFSEToncepersecondto*controlthecurrentandmaintainthevoltagedeterminedbyMaintVolt.*承VoltReg.IFCEQShoReg;assemblenextlineonlyifdebuggingLDA,OFFSET;getlatestOFFSETLDTEMPI,A;storelatestOFFSETinTEMPI.ENDCCALLCheckDip;checkfordipinbattvoltageDECVRcnt;decr咖entintervalcounterJRZVReg_0;Yes:thentimetoadjustJPVRegEXIT;No:thennottimetoadjustVReg一O;adjustoffsetLDIVRcnt,lsisiNrr;re-initiaHzeinitervalcounter(Isec)CALLAdjAvg;getFresliB"Vadjustedforcabledropand6VDECA;adjustAforcomparisonCPA^MaintVolt;comparewithsetvalue+1;JRCVReg—1;notgreaterthan,testiflessthanJKNCVRup;greaterthan,skipaheadJPVReg一l;notgreaterthan,testiflessthanVRup一LDA,OFFSET;greaterth叫getphasedelayvalueINCA;adjustforcon^arisonCPIA,HiOff+l;testifathighlimit;JRNCVReg—3;atthelimit,don,tchangeOFFSETJRCVReg—4一;notatlimit,sochangeOFFSETSETVRlmt,Flags4;…otherwise,setVoltRegLimitflagJPVReg—3;atthelimit,don'tchangeOFFSETVRsg—4—LDO》FSET,A;updateOFFSETCPIA,HiOff-l;dieckforminimumoutputJRNZVReg—3;ifnot,thenskipnextlineSETMinOu[Flags4""otherwise,setMinOutflagVReg—3JPV^egEXIT;doneforthispassVReg一lINCA;ajdustforcomparisonCPA,MaintVoIt;comparewithsetvalueJRNCVRegEXIT;notless也an,justexitLDA,OFFSET;lessthan,getphasedelayvalueDECAjCPIA,Of£Fast;testifatlowlimit;JRNCVReg—4;notatthelimit,updateOFFSETJRCVR邻E^TT;atlimit,don,tupdateJPVReg一4;notatthelimit,updateOFFSETVRegExS1IRRRlySw,Flags4,VRR;skipifrelaynotabouttochangeJUSRlyCls,Flags4,VRK;skipifrelayalreadyclosedLDIOFFSET,HiOff-l;OFFSETshouldbeHiOff"whenrelayclosesVRR;thenextsectionlightsLED'sfordebugging.IFCEQShoReg;assemblenextlinesonlyifdebuggingLDA,OFFSET;getnewoffsetCPA,TEMP1;compareittopreviousvalueJRZ"^RegYel;tumonyellowLEDifnochangeJRCVR邻Red;tumonredLEDifdecreasedCALLShowGreen;turaonGreenLEDotherwiseJPYRegDone;…andexitroutineVRegRedCALLShowRed;turncmRedLEDJPYRegDone;…andexitroutineVRegYelLDA,CurentSS;checkcurrentstateCPIA^9;indesulphationmodeJRZVRegDone;'.,ifsosexitroutineCAL;ShowChgng"..otherwise,turnonChargingLEDVRegDone.ENDCKET*TIMERINTERRUPTHANDLER**ThisroutineturnstheFETsonaftereverytimerinteruptandinhibits*thetimer.ItalsoopensordosestherelaydependingonRlyCls.*PwrConLDATemp,A;saveAregisterJRSRlyCls,Flags4,PCon;skipaheadifchargerisonPCoffRESRlyCtlJDRBbxif;…openo啤utrelayJPPCend;notcharging,ieaverelayopenPConSETRlyCtl,DRBbuf;…otherwise,closeoutputrelayPCendRESPWMbi,DRBbuf;turaFBTsonCALLUpdatePB;updateportBfrombufferLDITSCR^OOO10101b;resetTSCRandinhibitinteruptCALLRstWDR;resetwatchdogtimerLDIA,FULLT謹;TCRisreloadedherefor1flillcycleLDTCH,A;settimer(ontime)forFULLTIMELDITSCR,01011101b;rekmdprescalerandstarttimerSETNMInt3Flags2;tellExiMainthiswastimerinteruptPCexitIDA,ATemp;restoreAregisterRETI*NON-MASKABLEINTERRUPTHAMDLER**ThisistheNMIinterruptroutine.TheNMIisgeneratedonthefalling'*edgeofthefUUwaverectifiedAClinevoltage.Aninterruptis**generated120timespersecond,onceevery8.333風AftereachNMI,*thisroutineperformsthefollowingsteps,**1.Resetthewatchdogtimerandsavetheregisters,**2,TurnofftheFETs(unlessOFFSETH)andRelayoO).**3.Set也einterrupttimeraccordingtoOFFSET,**4.ResetNMIntsoExitMainknowsit'sanNMI(nottimerint).**5.Updatetheclocks,**6,Restoretheregisters.**Ifturnedoff,theFETswillremainoffforaperioddeterminedby**OFFSET.TheTimerwillthentriggeraninterruptwhichtellsPwrCon*toturntheFETsbackonifnecessary.*IT—TIMERCXLLRstWDR;resetwatchdogtimerI^DATemp,A;saveAregisterLD入X;getXregisterLDXTEMP,A;saveXregisterIRSRlyCls,Flags4,IT—ON;skipaheadifoutputisonIT—OFFR^SRlyCtl,DRBbuf"..otherwise,shutoffoutputJPIT—PWMj'umpalieadandsetPWMIT—OSS§TRlyCti,DEBbuf;closeouQnxtrelayLDA,QirentSS;checkforCrankONstateCPIA,013h;CrankONstateis013hexJRZIT—Bst;jumptofoilonduringCrankONsiTPWMhi,DRBbuf;shutoffPWMhiLD、OFFSET;getlatestoffeetCPIA,MinOff;OFFSET-MinO任meansalmostfUllonJRNZIT—OS"..otherwise,skipahead&setoffset;JRZIT_3st;ifalmostfidlon,thengofoilon;JPIT—;skipahead&setoffsetIT—Bst—;Boost(FullPower)r5sPWMhi,DRBbuf;turnonhighpowerpwmSETRlyCtl,DRBbuf;closeoutputrelayLDITSCR,00010101b;resetTSCRandinhibitTIMERinteruptJPIT一TMRl5TCRjA;loadthecounterwithcurrentoffsetLDITSCR,OIOl1101b;reloadprescaler(32)andstarttimerIT—TMRCALLUpdatePB;updateportBfrombufferRESNMIn1^Flags2;tellExitMainthiswasNMIinteruptCALLCLOCKS;updateclocksLDA,XTEMP;restoreregistersLDX,ALDAjATempRETI;*A/DINTERRUPTHAM)LER*;*ThisistheAtoDinterruptserviceroutine.Theonlythingitdoesis*;*cleartheinterruptbitandwakestheprocessorupfromitswaitmode.ADINTRES7'ADCRLDA,ADRRETI*ROMDATAWINDOWforTHIRDVOLTSLEDDIGIT**Thefollowingbitpatternsareusedtodisplaytheindicatednumbersas:*thethird(leastsignificant)digitofthevoltagedisplay.*blockl6-$%16DigitsOVx;patternsforDigiDat-Digit1(LSD)&decimalpoint.byte00010010b;display__0for00h.byteOllllllOb;display二lforOm.byte01111110b;display_lfor02h.byte0011000lb;display—2for03hbyte00111000b;display一3for04hbyte00111000b;display^^3for05h.byte01011100b;display—4for06h/byte10011000b;display二5for07h.byte10011000b;dispky二5for08h.byte10010000b;display—6for09h.byte00111110b;display=7forOAh.byte00111110b;display二7forOBh.byte00010000b;display二8forOCh.byte00011000b;display二9forODh.byte00011000b;display二9forOEh*ROMDATAWINDOWforTHIRDLEDDIGIT**Thefollowingbitpatternsareusedtodisplaytheindicatednumbersas**thethird(leastsignificant)digitontheLED.*.block16-$%16DigitsOOx;patternsforDigiDatl-Digit1(LSD)&decimalpoint.byte00010010b;bitpatterntodisplay一O.byte01n111Ob;Wtpatterntodisplay—1byte00110001b;bitpatterntodisplay—2,byte00111000b;bitpattemtodisplay—3.byteOlOl1100b;bitpatterntodisplay__4.byte10011000b;bitpatterntodisplay一5.bytelOQIOQQOb;bitpatterntodisplay二6.byte0011111Ob;bitpatterntodisplay=7.byte00010000b;bitpatterntodisplay—8.byte00011000b;bitpatterntodisplay__9*ROMDATAWINDOWforSECONDLEDDIGIT**Thefollowingbitpatternsareusedtodisplaytheindicatednumbersas*thesecond(middlesignificant)digitontheLED..block16-$%16Digits0x0;patternsforDigiDat2-Digit2(middledigit)andMS,byte00000101b;bitpatterntodisplay—0—.byte1100111lb;bitpatterntodisplay二1—.byte0010001lb;bitpatterntodisplay一2一.byte10000011b;bitpatterntodisplay—3—.byte11001001b;bitpatterntodisplay—4—.byte10010001b;bitpartemtodisplay一5一.byte00010001b;bitpatterntodisplay—6—.bytellOOOlllb;bitpattemtodisplay—7—.byte00000001b;bitpatterntodisplay—8—.byte10000001b;bitpattemtodisplay—9_*ROMDATAWINDOWforOutputCableVoltageDrop**ThefollowingvaluesaretheOFFSETvaluesatwhichVdropisadjusted.*ThevalueofOFFSETisaroughindicationoftheoutputcurrent,whichs*isdirectlyrelatedtothevoltagedropintheoutputcable.*.block16-$%16DrapOffs;OFFSETVdropPowerCurrent.byte0FFh;00High>0.0A.byteO她;OlHigh>5.A.byte0舰;02High>IO.Abyte088h;03High>15.7Abyte080h;04High>19.6Abyte07Bh;05High>23.5Abyte075h;06High>28.2Abyte070h;07High>32.1Abyte06Dh;08High>34.5Abyte0691i;09High>37.6A.byte065h;OAHigh>40.7A;.byte068h;0BHigh>27.2A;.byte063h;0CHigh>30.0A;.byte05Fh;0DHigh>32.2A;.byte05Ah;0EHigh>35.1A;.byte056h;OFHigh>37.5A;.byte066h;10High>40.2A;*ROMDATAWINDOWforAlternatorChargeinPercent*;*ThefollowingvaluesarethePercentvaluesforthealternatorvoltages*;*listedbelow.Thesenumbersareonlyusedwhenthechargerisin*;*Testermode.Voltageslowerthanthe&stentryaredisplayedas0%*;*charged.Voltagesabovethelastentryaredisplayedas199%charged.:block32-$%32AltLvls;%VolteHex.byte0;13.53CBred.byte12;13.60CC|.byte25;13.67CD|.byte38;13.73CEred.byte50;13,80CFyellow.byte62;13.87DO|.byte75;13.93Dlyellow.byte85j14.00D2green.byte92;14.07D3|.byte97;14.13D4|.byte100;14.20D5|.byte100;14.27D6|.byte100;14.33D7j.byte100;14.40D81.byte100;14.47D9j.byte100;14.53DA|.byte100;14.60DB|,byte103;14.67DC|.byte110;14.73DD|,byte120;14.80DEgreen.byte130;14.87DFyellow.byte140;14.93EO|.byte150^15.00Elyellow.byte160;15.07E2red.byte170;15.13E31.byte180;15.20E4j.byte190;15.27E5|.byte196;15.33E6red.byte199;15.40E7redInterruptvectors.orgOFFOhADCIP'ADINTTIMERJPPwrConINT2NOPRBTIINT1NOPRETI.orgOFFChNMIJPIT一T歸RRSTJPRESET71223D.asm5Checksum;RawCode:6E460;WithInfo:6E460:*COPYRIGHT2004SCHUMACHERELECTRIC*;*ALLRIGHTSRESERVED*;*WRITTENBY*;*THOMASF.JOHNSON*;*DigitalDieHard712232/15/50/125ACharger/Starter/Tester*,*ThiscodeisfortheSGS-THOMPSONmicro-ccmtroler*;*PartnumberST62T25/ST62E25*.title"DigitalDieHard71223ChargerVer.0.17".LINESIZE131.vers"ST6225".ro咖ize4.w一oiiDESUG.SET1;1->加rmal,0->IgnoreType幼dRateswitchesafterSS5ShoOff.SET0;1->normal,0->ShowOFFSETinAlt%modeduringchargingFastCP.SET1;1->normal,0->3minChkProgintervalinsteadof60minShoADC.SET1;1->normal,0->UseI"B2toindicateactivityLongTst.SET0;1->normal,0->Setmanualmodefor255(not1)hoursAdjOff.SET0;1->normal,0->AllowmanualadjustmentofOFFSET(SS15);*Definetheporthardwarelocations**Attimes,the.defstatementisfollowedbyavalueand"!m,'.The!m1*isusedbythesimulator/emulatorfordebugging.Thissymboltellsthe*equipmentwhatregisterstheuserwantstomonitorduringdebuging.X.def80h!mY.def81hV.def82hW.def83h;Indexregister;Indexregister;Shortdirectregister;ShortdirectregisterA.defOfih!m;AccumulatorDRA.defOcOh!mDRB,defOclh!mDRC.def0c2h;Portadataregister;Portbdataregister;PortcdataregisterDDRA.def0c4hDDRB.def0c5hDDRC.def0c6h;Portadirectionregister;Portbdirectionregister;PortcdirectionregisterORA.defOcchORB.defOcdhORC.defOceh;Portaoptionregister;Portboptionregister;PortcoptionregisterADR.defOdOh!mADCR.defOdlh;A/Ddataregister;A/DcontrolregisterPSC.defO孤TCR.defO咖mTSCR.def0d4h;Timerprescalerregister;Timercounterregister;TimerstatuscontrolregisterWDR.defO咖;WatchdogregisterIOR.def0c8h!迈DRWR.defOc处;Interruptoptionregister;Dataromwindowregister*Thesearetheramequatesusedbythebatterycharger.DRAbuf.def084h;shadowr咖forportAdataregisterDRBbuf.def085h;shadowramforportBdataregisterDRCbuf.def0861i;shadowramforportCdataregisterATemp,def0871i;AccumulatortemporarystorageXTEMP.def088h;XregistertemporarystorageMSecsl,def089h;storagefor8.333mstics-countof120=1secSecsl.def08Ah;storagefortimerlsecondsMiosl.def08Bh;storagefortimerlminutesHrsl.def08Ch;storagefortimerlhoursTioFlagl.def08Dh;overflowflagsforSecsl,Minsl,andhoursMSecs2.def08Eh;millisecondonecounterSecs2,def08Fh;storagefortimer2secondsMins2.def0卯h;storagefortimer2minutesHrs2.def09lh;storagefortimer2hoursTicFlag2.def092h;overflowflagsforSecsl,Mins2,andhourslTries.def093h;usedbybatterydetectroutinesTEMP.def094h;soratchpadareaTEMPI.def095h;scratchpadareaTemp2.def096h;countusedforFreshBVCurVolt.def097h;cuiTentbatteryvoltageMaintVolt.def0卿;storageforMAINTAINvoltagelevelOldVolt.def0卿;previousbatteryvoltage,usedfordv/dtCCE>cnt.def09AJb;displaycountdownduringcrankcooldownOldOff,def09Bli;oMvalueofOFFSETusedindl/dtBADlo,def09Ch;lowbitsbatteryvoltageaverageBADhi.def09Dh;h'bitsbatteiyvoltageaverageVmax.def09Eh;maxinmmbatteryvoltage(perBatteryType)Vref.def09Fh;refvoltagefordesulfationOFFSET.def0A0h;storageforphasedelayvalueFreshBV,def0Alh;avgbattvoltusedfordi/dtrefFBVTotLo.defOA2h;lowbyteoftotalusedforFreshBVEBVTotHi.def0A3h;higlibyteoftotalusedforFreshBVCurentSS.def0A4h;storescurrentchargerstateFlags.def0A5h;chargerconfigurationstates;bitO(BatTypeA):0forReg,1forD/C;bit1(BatTypeB)'0forNo叫1forAGM/GEL;bit2《Rate):0forSlow,1forFast;bit3(Crank):1ifinBoostmode;bit4(CrankWait):1duringE/Scooldown;bit5(Started):1ifchargingstarted;bit6(MtrUnits):0forVolts,1for%;bit7(MtrScal^:0forBatt'1forAltFlags2.def0A6Ii;storesthefoibwingFlags;bit0(Batt):1ifbatteryconnected;bit1(Rapid):1ifsetforRapidchargerate;bit2(Bat6V):1ifsetfor6Vbattery;bh3(Power):1ifoutputison;bit4(NMInt):1ifNMIinterrupt,0ifTin^r;bit5(ChMode):1ifinChargerMode;bit6(WaitOP):1ifwaitingfor。/。tochangefrom0;bit7(Alert):1indicatesAlertconditionFlags3.def0A7h;storesthefollowingFlags;6it0(Rmplnt):1duringlsthalfofeadiRampinterval;bit1(Settle):1duringvoltagesettletime;bit2(H正nd):1ifhighervoltageforEndCharge;bit3^Idle):1untilabuttonispressed;bit4(Hi6V):1ifbattery>8.5V;bit5(NxtCnt):1->1stsecondofcount;bit6(Manual):1ifinManualMode;bit7(Burnlh):1ifinBurn-inModeSwDown.def0入8h;Indicatesstateofswitches(Impressed);bit4=SwOffflag(debugging);bit5=Typeswitch;bit6=Rateswitch;bit7-MeterswitchDigiDat2.def0A9h;datafor8of16segmentsofdigitalLED(0->ON,l->off);bit0=digit3segmentsB&C;bit1=digit2segmentF;bit2=digit2segmentG;bit3=digit2segmentA;bit4=digit2segmentB;bit5=digit2segmentC;bit6=digit2segmentD;bit7-digit2segmentEDigiDatl.defOAAh;datafor8of16segmentsofdigitsLED(0->ON,i->off);bit0-digit1segmentC;bit1-digit1segmentG;bit2-digit1segmentD;bit3=digit1segmentE;bit4=digit2decimalpoint;bit5=digit1segmentF;bit6=digit1segmentA;bit7-digit1segmentBSwData.def0ABh;dataforthe3Rateand3TypeLEDs(0、>ON,l->o旬;bit0=6VbatterytypeLED;bit1=RegbatteiytypeLED;bit2=D/CbatteiytypeLED;Wt3=AGMbatterytypeLED;bit4-60AchargerateLED;bit5=15AchargerateLED6-300AchargerateLED;bit7-2AchargerateLEDBitCnt.def0ACh;IndexofbitsenttodisplayBytCnt.def0ADh;IndexofwordsenttodisplayDataBuf.def0AEh;TempstorageforDatabitsVMCnt.defOAFh;CounterforvoltagedisplayiatervdTempOff.defOBOh;te迈poffsetval肪RmpCnt.defOBlh;countsrampintervalsuntilnextrampLEf)num.def0B2h;storesnumbertobeshownondigitalLEDPercent.def0B3h;storespercenttobeshownondigitalLEDIndex.def0B4h;usedforlookuptableaccessLowOff,def0B5h;minoffsetvaluefordi/dt(highestcurrent)VRoit.def0B6h''CounterforvoltageregulationintervalPcntL.def0B7Ii;NMIcounterforpercentdisplayupdatePcntH.def0B8h;IntervalcounterforpercentdisplayupdateDspPoit.def0B91i;storageforlastpercentdisplayedFlags4.def0BAh;stores&efollowingFlags;bit0(IdleSet):1if10mirmteIdletimerwasstarted;bitI(NoRamp):1duringManualFastcharge;bit2(SOC):1ifatstartofcharge(1st5s);bit3〖Crnkng):1ifcraiiking(State19);bit4(HiPwr):1ifchargerate>Fast;bit6(Restore):1ifindesu版ionmode(SS9)LastBatt.def0BBh;storesbatteryreadingusedtomonitorprogress;free,def0BCh;freeORBbuf.def0BDh;shadowRAMforORBregister;free.def0BEh;fi:ee;free,def0BFh;free;咖h=lastRAMlocation;*Thesearetheconstantsusedbythebatterycharger.*Volte005.equ008h;0.5VOLTSVolts0.equ00Ah;0.7VOLTSVoltsOl.equOOFh;1.0VOLTSVolts016.equ017h;mimimunvoltageforenginestart,1.5VVolts02.equOlEh;2.0VOLTSVolts05.equ04Bh;5.0VOLTSVolts06.equ05Ah;6.0VOLTSVolts066.equ061h;6.6VOLTSVolte075.equ071h;7.5VOLTSVolts09.equ087h;vezydischargedbatteryvoltageVoltelO,equ096h;10.0VOLTSBattMin.equ0AFh;lowestvalueinBattery%LUTVolts12.equ0B4h;lowbatteryvoltageVolts122.equOB7hVoltel25.equOBChBattMax.equ0BDh;highestvalueinBattery%LUTVolts127.equOBEhVolte128.equ0C0h;goodbatterytestvoltageVoltsl3.equ0C3hVolts132.equOC6hVoltel35.equOCAhAltMin.equ0CBh;lowestvalueinAlternator%LUT輔sl38.equOCFhVolts14.equOD2hVolts142.equ0D5h;startmonitoringdv/dtvoltageVoltsl435.equOD7hVoltsl44.equ0D8hVolts146.equ0DAh;maximumallowedvoltageforreg/gelmodeVolts147.equ0DCh;starttrickletimervoltageVoltsl49.equ0E他;14.87VVoltsl5.equ0Elh;maximumallowedvoltageforRV/DCMarineVoltsl5a.equ0E2h;15.07VAltMax.equ0E7h;highestvalueinAlternator%LUTVolts155.equ0E9h;maxhnumallowedvoltageforAuto/MarineStartingVoltsl6.equ0F0h;maximmnallowedvoltageVoltsl65.equ0F7h;maxim咖allowedvoltagefordeepcycle2Volts17.equ0FCh;maxinmmallowedvoltageMaxVolts.equOFFh;maximumvoltagereading-17.0VRCinitR.equ75;rarapcountintervalsforRapidrateRCinitF.equ180;rampcountintervalsforFastrateRIinit.equ60;NMIinterruptsper1/2rampcountintervalMSINIT.equ078h;millisecondinitializationvalue(120)MS500.equ03Ch;millisecondcountervaluefor500mS(60)MS200.equ018h;millisecondcountervaluefor200mS(24)Seclnit.equ03Ch;secondinitializationvalue(60)Minlnit.equ03Ch;minuteinitializationvalue(60)MaxHrs.equ25;maximumallowedchargehours+1CPint.equ60;mimitesperchargeprogressintervalHR.equOOOh;hoursbitofTicFlaglandTicFlag2MIN.叫u001h;miimtesbitofTicFlaglandTicFlag2SEC.equ002h;secondsbitofTicFlaglandTicFlag2MSEC.equ003h;millisecondsVLO.equ0C0h;lowlinelimit-100VACVHI.equ0EEh;highlinevoltagelimit-130VACBatLoSlo.equ150;lowbatteryvoltagecurrentadjust-10.0VdcBatLoFst,equ150;lowbatteryvoltagecurrentadjust-10,0VdcBatLoRap,equ135;lowbatteryvoltagecurrentadjust-9.0VdcBat6LoSio.equ75;lowbatteryvoltagecuirentadjust-5.0VdcBat6LoFst.equ75;lowbatteryvoltagecurrentadjust-5.0VdcBat6LoRap,equ75;lowbatteryvoltagecurrentadjust-5.0Vdc;BalHiSlo,equOD5h;BatffiFst.equ0C6hPCint.equO^Ah;numberof1-secondintervalsbetween%updatesFULLTIME.equ0ADh;halfsecondwhenACpowerisOFFSlowAmps.equ2-'NominalampsoutatSlowrateFastAmps.equ12;Norai加lampsoutatFastrateRapAmps,equ30;NominalampsoutatRapidrateCrnkAmps,equ80;NominalampsoutatCrankrateCodeRev.equ0;sofhvarerevisionldvelOffLowSlo.equ130;Lowestcurrentin12V2AoffsettableOffSlow.equi30;Nominaloffsetforslowcharge(20%)O細Slo,equl16;Currentin12V2Aoffsettablefor14.2VMinOffSlo.equl14;MaxCurrentfor12V2Arateduringdi/dtOffLowFst.equ103;Lowestcurrentin12VFastoffsettableOffFast,equl03;Nominaloffsetforfastcharge(12A)OfiHiPst.equ87;Highestcuirentin12VFastoffsettableMinOfFst.equ85;MaxCurrentfor12VFastrateduringdi/dtOffRamp,equ80;offsetfbrFastoRapidtransitionOfERap.equ74;Nominaloffsetforrapidcharge(~90%)OffLowRap.equ74;Lowestcurrentin12VrapidoffsettableOfflHiRap.equ30;Highestcurrentin12VrapidoffsettableOffCrank,equ95;OFFSETforCrankstandbyOfPSLoSlo,equl37;Firstentryin6V2AoffsettableOff6Sl。.equi37;Nominaloffsetfor6Vslowcharge(2A)Off6HiSl0,equ137;Currentin6V2Aoffs改tablefor7.0VMiii60舰o.equ135;MaxCurrentfor6V2Arateduringdi/dtOff6LoFst.equ107;Lowestcurrentin6VFastoffsettableOff6Fst.equ107;Nominaloffsetfor6VFastcharge(12A)Off6HiFst.equ106;Highestcurrentin6VFastoffsettableMin6QfFst.equ104;MaxCurrentfor6VFastrateduringdi/dtOff6Rap.equ82;Nominaloffsetfor6VRapidchargeOff6LoRap,equ82;Lowestcuirentin6VRapidoffsettableOff6HiRap,equ77;Highestcurrentin6VRapidoffsettableO筋Cmk-equ90;OFFSETfor6VCrankstandby扭Off.equ140;highlimitforOFFSETvariableHiOff6.equ160;highlimitforOFFSETvariable(6Vmode)ABORT,equ008h;abortstateLEDslow.equ007h;SlowLED-bitofSwDataLEDboost,equ006h;CrankLED-bitofSwDataLEDfast.equ005h;FastLED-bitofSwDataLEDrap,equ0O4ii;RapidLED-bitofSwDataLEDgel'equ003hi;AGM/GelLED-bitofSwDataLEDdeep.equ002h;DpCyclLED-bitofSwDataLEDreg.equ00lh;RegularLED-bitofSwDataLED6V.equ000h;6VRegLED-bitofSwDataLEDdone.equOOOh;ChargedLED-PORTALEDchgng.equOOIh;ChargkigLED-PORTALEDalert.equ002h;FaultLED-PORTALEDprcnt.equ003h;PercentLED-PORTALEDvolt.equ004h;VoltageLED-PORTALEDalt.equO05h;AltmtrLED-PORTASerData.equ006h;SerialData-PORTAClrData.equ007hpataC〗ear-PORTAShftClk.equOOOh;ShiftClock-PORTBLtchClk,equOOlh;LatohClock-PORTBESrly.equ003h;E/Srelay-PORTBDisable,equ006h;DisaWeCtrl-PORTBSCRs,equ007h;SCRcontrol-PORTBFanCtl.equ004h;Fancontrol-PORTCTypeSw.equ005h;Typeswitch-PORTCRateSw.equ006h;Rateswitch-PORTCMeterSw.equ007h;Meterswitch-PORTCSwOff.equ004h;bitinSwDownfordisabledType&RateswitchesBatTypeA,equOOOh;bitinFlagsforbatterytype:0-Reg,1=D/CBatTypeB.equOOlh;bitinFlagsforbatterytype:1=AGM/GelCellRate.equOO^h;bitinFlagsforchargerate:0=Slow,1-FastCrank.equ003h;bitinFlagsthatindicatesenginestartCrankWait.equ004h;bitinFlagsthatindicatescooldownbetweencranksStarted,equ005h;bitinFlagsthatindicateschargestartedMtrUnits.equ006h;bitinFlagsformeterunits:6=volts,1=%MtrScale-equ007h;bitinFlagsformeterscale:0=batt,1=altrntrBatt.equOOOh;bitinFlags2:1ifbatteryisconnectedRapid.equ00lh;bitinFlags2:1ifchargerateisRapidBat6V,equ002h;bitinFlags2:1ifoutputis>10APower,equ003h;bitinFlags2:1ifoutputisonNMInt,equ004h;bitinFlags2:1ifNMIinterrupt0ifTimerChMode,equ005h;bitinFlags2:1ifinChargermode(notTester)Wait0P.equ006h;bitinFlags2:1ifbattery>10VAlert.equ007h;bitinFlags2:1indicatestroubleRmpltit.equOOOh;bitinFlags3:1during1sthalfeachRampintervalSettle.equ00lh;bitinFlags3:1duringvoltagesettletimeHiEnd.equ002h;bitinFlags3:1ifhighervoltageforEndChargeIdle.equ003h;bitinJFlags3:1untilabuttonispressedHi6V.叫u004h;bitinFlags3:1ifbattery>8.5VNxtCnt'equ005h;bitinFlags3:0duringlasthalfofCCDcntintervalManual,equ006h;bitinFlags3:1duringManualmodesBurnln,equ007h;bitinFlags3:1duringBura-lnmodeIdleSet.equ000h;bitinFlags4:1if10minuteIdletimerwasstartedNoRamp.equ001h;bitinFiags4:1duringmanualfastchargeSOC,equ002h;bitinFlags4:1duringStartOfCharge(1st5sec)Cmkng.equ003h;bitinFlags4:1duringcranking(Statel9)HiPwr.equ0041i;bitinFlags4:1ifchargerate>FastRestore.equ006h;bitinFlags4:1ifindesulfationroutineCrankOff.equ180;crankofftimeinsecondsCrankON.equ5;crankontimeinsecondsCCDint.equ00lh;crankcooldowndisplaycounterinterval(seconds)CrankSS.equ010h;crankSSisstate16=10hexDecimal,equ004h;bitinDigiDatlfordecimalpointDigitl.equ000h;bitinDigif)at2formostsignificant1SwsOff.equ11111111b;bitpatternforallswitchesoffDigiOffa.equ1111111lb;bitpatternforallsegementsoffDigiOffb,equ11111111b;bitpatternforallsegementsoffDigiONa.equOOOOOOOOb;bitpatternforallsegementsONDigiONb,equOOOOOOOOb;bitpatternforallsegementsONDashes1.equ1111110lb;bitpatterntodisplay_Dashes2.equ11111011b;bitpatterntodisplay—-一DigiRevl.equ00010010b;bitpatterntodisplay一0DigiRev2.equ01100001b;bitpatterntodisplay^f一DigiMVl.equ〗101001lb;bitpatterntodisplayUDigiMV2.equOOOOOlOlb;bitpatterntodisplay]]5—;.orgO88OI1;forST6210/15.org0100h;forST6220/25RESETCALLRstWDR;resetwatchdogtimerRAMCLRLDIX,084h;pointXto1stRAMLocationRAMCLR1CLRA;clearALD(X),A;storeAatlocationpoiptedtobyXINCXjincre迈entXLDAjX;getpointerinACPI乂0C0h;testforendofRAMJKNZRAMCLR1;doagainifnotfinishedNowSetUpTheHardwareI/OPortsPORTA;Bit0=LED-Done(Output,0=ON);Bit1=LED-Charging(Output,0=Ol^I),Bit2=LED-Alert(Output,0=ON);Bit3-LED-Battery%(Output,0=ON);Bit4=LED-VolteDC^Output,0=ON);Bit5=LED-Altatr%(O争t'0=ON);Bit6=SerialData(O争t,0=ON);Bit7=DisplayClear(Outpu"0=clear);Bit#76543210LDIDDRA,lllinilb;SetallbitsasoutputsLDIORA,11000000b;open-drainou*uts0-5;6-7push-pullLDIDRA,11111111b;Setinitialvaluesto1(off)LDIDRAbuf,1m1lltb;storesettingsinshadowRAMPORTB;Bit0=Shiftclock(Output,0->l=Shift),Bit1=Latchclock(0啤ut,0->1=Latch);Bit2=LED-Amps(notused);Bit3-E/Srelay(Ou帆0-Charge,1=Start);Bit4=Battsense(notused);Bit5-歸Voltage(Input,Analog);Bit6=Disableout(Ou"1=disabled);Bit7-SCRdrive(O争t'0=ON);Bit#76543210IDIDDRB,11011111b;bits5isinputothersareoutputsLDIORB,1111111lb;PB5analog;otherspush-pullLDIDRB,11100111b;initializehighexcept3-4LDIDRBbuf,l110011lb;storesettin群〗nshadowRAMPORTC;Bit4-FanControl(Output,0=off,1-ON);Bit5=Typeswitch(Input,0=IN/change);Bit6=Rateswitch(input,0=IN/change);Bit7=Meterswitch(Input,0=IN/change);Bit#76543210LDJDDRC,0002ib;bit4isoutput,othersareinputsLDIORC,00011111b;non-interruptinputs,push、pu11outputLX)IDRC,00001111b;Setinternalpull-upsforbits5-7LDIDRCbuf,0000U11b;storesettingsinshadowRAMTSCRJMTLDITSCR^O00I01Olb;resetTSCRandinhibitinteruptSET4,IOR;卿bleinteruptsRETICALLInitState;initializetoslow(2A)automode;Thenextthreelinesaretosetthe咖ximuniidletestertimeCALLIniTimel;initializetimer1LDIMinsi,0Ah;settimer1for10minutesSETIdle,Flags3;indicatesnobuttonspressedyet;ThenextthreelinessettheunitforTester(notCharger)咖deRESChMode,Flags2;setforTesterModeCALLShowDatainitializedisplay1NTT一0];*TestRoutines*;*Thisroutinecheckstheswitchesatpoweruptodeterminewhetherto*;*enteroneofthetestmodes.Thepossibletestmodesandtheswitch*;*combinationsthattriggerthemareasfollows.**承*;*MeterRateTypeTestMode*;*YxNPowerOnSdfTest(POST):LED'slightinsequence*;*NYNM幼uaSowCharge(1hourmaxforallmanualmode)*;*NNYManualMediumCharge(Fastforboostmodels)*;*NYYManualFastCharge(Fast-Rapidforboostmodels)*;*YxYBum-InMode:Fast/RapidChargefor60minutes***;*Y->pressed,N->notpressed,x->either(notchecked)*承TESTJRSMeterSw,DRC,NoPOST;SkipaheadifMeterModebuttonnotpressedJRSTypeSw,DRC,POST;SkiptoPOSTifTypebuttonnotpressedJPTestBI;...o也erwise,skipaheadtoBurn-InsetupNoPOST,JRRRateSw,DHC,TESTl;CheckTypeswitchifRateswitchispressedJRSTypeSv/,DRC,NoTest;gotoMAINif加switchispressed;SetforManualFastChargeSETRate,Flags;turnonFastLED,turnoffSlowLEDRESHapid,Flags2;turnoffRapidLEDRESHiPwr,Flags4;turnoffhighpowermode;SETNoRamp,Flags4;setforFastratew/orampuptoRapidLDIOFFSET,OfiFast;setforFastrateJPTestMMljsetforManualchargeNoTestJPMAIN;skiptestandgotoMAINTEST1;Setform咖alSlowChargeJRRTypeSw,DHC,TEST2;ifTypeswitchispressed,setforFastTestCAL3LSetSbw;setforSlowRateCALLStartSlow;setOFFSETforSlowrate;LDIOFFSET,O制ow;setOffsetfor2AJPTestMMl;setforManualchargeTes氾I;Setfor60minuteBurn-InSETBumln,Fiags3;SetforBum-InmodeLDIOFFSET,OffFast;setforFastrateRESHiPwr,Fags4;tumoffhighpowerCALLSetRmpUp;preparetorampfromFasttoRapidTEST2;setforManualRapidCharge;SETManual,Flags3;setforManualmodeSETRate,Flags;setfornon-SlowrateSETRapid,Flags2;tumonRapidLED;RESNoRamp,Flags4;setforrampingJRSBurnlnjFlags3,TestRap;don'tsetforrampdownifBurn-InSETHiPwr,Flags4;turnonhighpowerLDIRmpCnt,RCinitR;setcounterforRapid;RESRampUp,Flags3;setforrampdownLDIOFFSET,OffRap;setO飽etforRapidChargeCALLSetRamp;setrampingparametersTestRapJPTestMMl;setforManualchargePOSTCALLResetLEDs;turnoffalltype,rate&StatusLED'sCALLMeterOff;turnoffallmetermodeLED'sCALLDigitsOff;turnoff3-digitLEDRESPower,Flags2;makesureoutputwillbeoff;showstatusLED'sCALLShowGreen;lightGreenLEDonlyCALLFifthSecond;waitoneFifthsecondCALLShowChgng;iightCliargingLEDCALLFifthSecond;waitoneFifthsecondCALLAlertON;加rnonAlert(Red)LEDCALLFifthSecond;waitoneFifthsecondCALLResetLEDs;turaoffalltype,rate&StatusLED's;showchargerateLED'sSETChMode,Flags2;mustsetflagtoshowrateLED,sRESCrank,Flags;turaoffCrankLEDCALLSetSlow;setforSlowRateLDILEDnum,SlowAmps;setdigitalLEDtoshowSlowrateCALLHoldRate;showRateandwaitaFi他secondSETRate,Flags;turaonFastUEDLDILEDnum,FastAmps;setdigitalLEDtoshowFastrateCALLHoldRate;showRateandwaitaFifthsecondSETRapid,Flags2;turnonRapidLEDLDILEDmrai,RapAmps;setdigitalLEDtoshowRapidrateCALLHoldRate;showRateandwaitaFifthsecondRESChMode,Flags2;clearflagtodisableoutputLDILED皿m)CrnkAmps;setdigitalLEDtosiiowCrankrateCALLShowNum;getdatatosRowtheLEDnumberCALLShowCrank;turnonCrank(Boost)LEDCALLFifthSecond;waitoneFifthsecondCALLResetLEDs;tumoffalltype,rate&StatusLED'sCALLShowData;updatedisplay;showbatterytypeLED'sCALLSetl2V;setforRegular,12VbatteryLDIDigiDatl,DigiRevi;setdigital!LEDtoshowCodeRevisionLDIDigiDat2,DigiRev2;setdigitalLEDtoshowCodeRevisionCALLHoldType;showTypeandwaitaFifthsecondSETBatTypeA,Flags;turnonDeepCycle&turnoffRegularLEDCALLHoldType;showTypeandwaitaFifthsecondSETBatTypeB,lags;turnonGel/AGMLEDRESBatTypeA,lags;turnoffDeepCycleLEDCALLHoldType;showTypeandwaitafifthsecondRESBatTypeB,Flags;tumoffGel/AGMLEDSETBat6V,Flags2;tumON6VLEDCALLHoldType;showTypeandwaitaFifthsecondCALLResetLEDs;tunioffalltype,rate&StatusLED'sRESBat6V,Flags2;setfor12Vbattery(not6V);showdisplaymodeLED'sCALLS&owData;updatedisplaySETMtrUnits,Flags;setfor%LEDsON,voltsLEDoffRESMtrScale,Flags;setforAlternator%LEDoffCALLHoldMtrMd;showmetermodeandwaitonefifthsecondRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffCALLHoldM仕Md;showmetermodeandwaitonefifthsecondSETMtrUnits,Flags;setfor%LEDsON,voltsLEDoffSETMtrScak,Flags;setforAlternator%LEDONCALLHoldMtrMd;showmetermodeandwaitonefifthsecondCALLMeterOff;turnoffallmetermodeLED'sCALLResetLEDs;tumoffalltype,rate&StatusLED'sLDILEDnum-5;initializeto5toshow41stPOST2DECLEDrmm;thenextnumberwillbe1lessCALLNumData;getdatafor,andshowLEDnumberCALLFi他Second;waitonefifthsecondLDA'LEDnum;checkforlastnumberJRNZPOST2;loopbackandrepeatifnottherePOST3ADDIA,20;adding20changes2nddigitLDLEDnum,A;preparetosliownewnumberCALLNumData;getdatafor,andshowLEDnumberCALLFifthSecond;waitonefifthsecondLDA^LEDnum;cliecklatestnumberCPIA,IOO;comparetolastnumberJRNZPOST3;loopbackandrepeatifnotthereCALLResetLEDs;turnoffallt^pe,rate&StatusLED'sCALLInitState;resettoSlow,TypeAchargemodeRESChMode,Flags2;setforTestermodeJPTEST;repeatPOSTifnecessaryTestMM1;SetformanualchargeSETManual,Flags3;setforManualmodeSETChMode,Flags2;setforChargerMode(outputenabled)RESDisable,DRBbuf;enableoutputLDICurentSS,15;State15isManualchargeSETStarted)Flags;setFlagsforchargestartedSETPower,Flags2;tdlPwrConchargerisonCALLIniTimel^initializeTimerl.IFCNELongTst;assemblenextlineonlyifnotdebuggingLDIHrsl,1;setTimerlfor1hour.ELSE;assemblenextlineonlyifdebuggingLDIHrsl,255;setTimerlfor255hours.ENDCJRJRBurnln,Flags3jMAIN;skipnext2linesifnotBum-inTestMM2CALLIniTime2;resetTimer2LDIMins2,1;settimerforcounterinterval(1minute)LDICCDcnt,60;setBura-inminutecounterto60*BecausetheA/Dvoltageisbeingaveraged,itwouldtakeconsiderable**timetonoticethatabatteryhasbecomedisconnected.Toovercomethis**DELAYUieprogramwillmonitortheinstantaneousvoltageeachtimethru*thelooptodetectthiscondition.Thischeckwillbemadeonlyifthe**unitisinachargingmode.*MAINCALLRstWDR;resetwatchdogtimerLDA,CurentSS;getcurrentstateCPIA,ABORT;checkforabortIRNZMainMore;continueMainifnotAbortJPMAIN3;don'tcontinueMainifAbortMainMoreJKRManual,Flags3,MainAuto;continueMainifnotManualMode<formula>formulaseeoriginaldocumentpage160</formula>转滔齿被158/354:KXPSS4;*SS4-BELOW12\,01tB*NSS5CPIA,005hJRNZNSS8JPSS5;*SS5-NORMALCHARGE*養6;CPIA,006h;JPSS6;*SS6-dv/dtMONITOR*NOTUSED;CPIA,007h;JRNZNSSS;JPSS7;*SS7-CHARGECOMPLETE*NOTUSEDCPIA,008hJHNZNSS9JPSS8;*SS8-ABORTCHARGE*CPIA,o夢JPSS9;*SS9-DESULFATION*NSS10;CPIA.OOAh;!RNZNSSll;JPSSIO;*SSIO-RESTORECHARGE*NSS11CPIA,OOBhJRNZNSS12JPSS1I;*SSli-dWdtMONITOR*養12CPIA,oo门hJRNZNSS13JPSS12;*SS12,IMOKTTOR*NSS13CPIA,OODhJRNZNSS14JPSS13;*SS13-ENDCHARGE*NSS14CPIA,OOEhJ1RNZNSS15JPSS14;*SS14-MAINTAIN*115CPIA,OOFhJRNZNSS16JPSS15;*SS15-Mall*NSS16CPIA,010hJRHZNSS17JPSS16;*SS16-CRANK*117CPIA,on!lJRNZNSS18JPSS17;*SS17-CRANK*NSS18CPIA,012hJRNZNSS19JPSS18;*SS18卿19CHA,013hJRNZNSS20JPSS19SS19NSS20CMA,014hJRNZNSS21JPSS20;*SS20顺21LDIWDR,001hCRANK*CRANK*-CRANK*;invalidsequencestate,reset*ENDOFM細**WaitforNMI,whichin<UcatesendofFETonperiod'beforemeasuring*batteryvoltage.*XMainWATT;waitforinteruptJRSNMInt,Flags2,XMain;timerinterupt*READBATTERYVOLTAGE**Thisroutineisexecutedatornearzerocross.Thecurrentvoltage**isstoredinCurVoltandthereadingisaddedtoBADhi(twolocations),*BADhiwillcontainarunningaverageofthelast256readings.*BADREAD.IFCEQShoAPC;ass咖blenext2linesonlyifdebuggingSET2,DRBbuf;setPB2*nA/DsamplingstartsCALLUpdatePB;updateportBfrombuffer.ENDCLD入BADlo;getaveragereadingSUBA^BADhi;subtractonereadingfromtherunningtotalJRNCBADRBAD1;nocarry,goonDECBADhi;adjusthighorderbiteBADREAD1LDBADlo,A;storenewvalueLDIADCR,0B0h;startA/DconversionTJ>ADCR,0B0h;doagaintoinsureavalidstartWAIT;lettheinteruptnotifyuswhendataisreadyLDCurVolt-A;saveCTOrentreadingADDA,BADlo;addintorunningaverageJHNCBADKEAD2;nocany,goonINCBADhi^incrementhighbitsBADREAD2LDBADlo,A;stoenewlowbits.IFCEQShoADC;assemblenext2linesonlyifdebuggingRES2,DRBbuf;setPB2whenA/Ds咖ptoigstartsCALLUpdatePB;updateportBfrombuffer,ENDC;LDIORB,OlFh,'LDIORB:O卿*磁AVERAGECALCULATION**Forusebythedi/dt,aboutfourtimeseverysecondtheave鹏eofthe**previous32curvoltreadingsisstoredinFreshBVforcomparisontoa**readingtakenonceeverysecond,*DEDTAVGLD入Temp2;ifTemp2=0thenfirstreadingJKNZDIDTAVGl;skipinitifnot1streadingLDITerap2,020h;initializeTemp2to32DIDTAVGlLDA,FBVToiLo;ADDA,CurVolt;addcurrentvoltagetototal廳CDIDTAVG2;don'tinchighbytsifnocarryINCFBVTo但i;inchighbyteD1DTAVG2LDFBVTotLo,A;updatetotalDECTemp2;updateTemp2JHZDIDTAVG3.'computeavgJPDIDTAVGX;exittoMainDIDTAVG3LDITemp2,0031i;preparetoshift3timesDIDTAVG6LDA,FBVTo沮i;loadhighbyteoftotalintoaccumulatorSLAA;shiftaccumulatorleftLDFBVTotHi,A;updatehighbyteoftotalLDA,FBVTofLo;loadlowbyteoftotalintoaccumulatorSLAA;shiftaccumulatorLDFBVTotLo,A;updatelowbyteoftotalJRNGDID丁AVG4;msbwaszero,skipnextline認FBVTo舰;DIDTAVG4DBCTemp2;decloopcounterJRZDBDTAVG5;ifzero,finishaverageJPDBDTAVG6;notzero,shiftagainDIDTAVG5LDA,FBVTotHi;storeaverageinFreshBVLDFreshBV,ACLRFBVTotHiCLRFBVTotLo顶S7,FreshBV,DA7;skipaheadif>8.5V'RESHi6V,Flags3;clearHi6VflagJPDIDTAVGX;andskiptoendofroutineDA7SETH化V,Flags3;setHi6VflagDIDTAVGXJMAIN:Thisiswherethesequencestatesaredefined.ThenumberofagivenssequencestatehasnorelevancetotheorderinwhichitisactuallyH;executed.Anygivenstatecangivecontroltoanyotherstate.:BATTERYDETECT*'Thisis也echargeridlestate.Theprogramremainshereuntilabattery';*isdetected.Dectectionisdeterminedbyfindingapositivevoltagegreaterthanonevolt,*^S0,IFCEQDEBUG;assemble加xtlineonlyifdebuggingRESSwOff,SwDown;settocheckTypeandRateswitches.ENDC;RESCrankjFlags;clearCrankbitofFlagsRESRestore,Flags4;clearRestorebitofFlags4CALLShutOff;Iow&highpower,fan,&crankoff;边indutyCALLShowHate;turnonchargerateLED(SloworFast)CALLShowType;turnonbatterytypeLED(Reg,D/C。rGel);CALLCbrgRly;ckmgeE/SrelayifnecessaryJRSChMode,Hags2,Heady;coQtinueroutineifinChargerModeCALLCheckBatt"..otherwise,checkiftestershouldshowO'sJPSSOEXITandexitReadyJURStarted,Fl绍s,SSOO;skipifoutputhasr^tbeencmRESStarted,Flags;setFlagsforchargenotstarted'ssooLDA,FreshBV;checklatestaveragevoltageJ]RNZRvrsBatt;Isit0(exactly)CALLShowRed;turnonRedLEDuntilbatteryisdetectedJPSSOEXIT;",Yes:mustberev.bat^sostopRvrsBattCPIA,VoltsO+l;No:otherwise,checkif>0.7VJRCPulse;no:trypulsingtheoutputJPSSO—1;yes:setupfornosparkdelayPulse;turnonchargerfor1cycleeachsecondLDA,MSecsl;pulseoncepersecondCPIA,MSINIT;timetopulseIRZFulseON;yes,gototopulsecodeRESPower,Flags2;otherwse,telltimertoleavechargeroffJPSSOEXIT;andke印waiting(untilnextsecondstarts)PulseON;pulsechargerononcepersecondSETPower,Flags2;tellPwrConchargerison;CALLShowGreen;tumonGreenLED***test***JPSSOEXIT;加battery,justexitSSO一lCALLIniTimel;setuptimerLDISecsl,002h;adjustfor2secondsLDITries,005ii;5TriesfordebounceSETO,C丽tSS;goontoBATTERYDETECTDELAYSSOEXITJPExi她in*BATTERYDETECTDELAY*,*Thisstatechecksthatavoltageispresentfortwoseconds.Ifthe*;*voltagedropsbelow1Vdc,thetimerisrestartedandthe"try"counterisdecremented.Ifafter5Triesthevoltagehasnotbeenabove1Vdc*:*for2seconds,gobacktobatterydetect.Thisdelayhastheeffectof*,*debouncingtheleadsbeingconnectedtothebattery.*■SSICALLCheckBatt;checkforconnectedbatteryJRRBatylags2,SS1—2;subtracUtryifnotconnectedCALLShowChgng;turnChargingLEDonJRR2,TicFlagl,SSlEXIT;gooniftimeisup,otherwiseexitLDIOldVolt,OOOh;clearOldVoltbeforeenteringSS2LDITEMPl,OOOli;clearTempibeforeenteringSS2INCCurentSS;goontostartchargeJPSS1一3;settimerfor2secondsSS1一2一;NOTE:Triessetto5inSSODECTries;subtractatryJRNZSSl一3;tryagainifnottoomanyTriesDECCurentSS"..otherwise,gobacktoid〗e(state0)JPSS1EXTTandexitroutineSS1一3CALLIniTimel;resettimerandtryagainLDISecsl,002h;adjustfor2secondsSS1EXITJPExi她in;*AUTOMATICCHARGESTART**Thisstategetsthebatteryvoltageanddecideshowtocontinuethe*thecharge.Themaximumallowedchargetimeisalsostarted.*SS2;NOTES:OldVoltSETTO0INSSI;TEMPISETTO0ATRESETFASTAVGDECTEMPI;decreaseTempionecount(startsat0);havewecounteddownto0IRZFASTDOISIE;yes,jumptoFASTDONELD人TEMP;no,loadpreviousTEMPvalueADDA^CurVolt;addCURVOLT,Didweoverflowthecounter厕COVER;no,jumptoOVERINCOldVolt;yes,bumpuptherunningaverageOVERLDTEMP,A;storethelatestvalueinTEMPJPSS2EXTT;exitandgoupdateCurVoltFASTDONELDA,TEMP;loadpreviousTEMPvalueADDA,CurVolt;Didweoverflowthecounteronelasttime厕COVER2;no,jumptoOVER2INCOldVolt;yes,bumpuptherunningaverageonelasttimeOVER2CALLCheckBatt;ChecktoseeifbatterywasremovedduringFastAvgIRSBatt,Flags2,SS2一0c;Stillconnected-continueLDICurentSS,O;notconnected-gobacktostate0JPSS2EXIT;...andexitState2SS2—0cLD"X,OldVolt;getOldVolt(initialbatteryvoltage)LDBADhi,A;initializeBADhito01編t;LDA,Percent;getupdated%LDA,DspPcnt;comparetolast0/odisplayedJRNZSS2—GP;if°/。previouslyshown,skipaheadCALLGetPercent;updatePercentforinitialvoltageLDA,Percent;getlatest%LDDspPcnt,A;storeatest%inDisp〗ayPercentRES讨aitOP,Flags2;setflagtoindicatenotwaitingJPSS2—BP;skipaheadSS2—GfCPIA,100;checkfor100%JRNZSS2-BP(continueState2ifnot100%CALLSetMinOff;limitoutputtomax2AcurrentJPSS5—Maint"..otherwise,gotoMaintainSS2一Bf"CALLShowChgng;turnChargingLEDonCALLIniTimel^initializetimer1LDIMinsl,5;settimer1for5minutes;LDISecsl,005h;settimer1for5secondsLDICCDcnt,MaxHrs;setintervalcountertoMaxHrsCLRLastBatt;clearLastBatt(ensurepass1sttest);SETSOC,Flags4;setStartOfChargeflagCALLIniTime2^initializetimer2LDISecs2,001h;settimerfor1secondLDIMSecs2,MS500;settimerfor500milliseconds(0.5secs)LDIMins2,006h;settimerfor5minutesand2secondsLDIHrs2,005h;settimerfor4hours,5minutes&2secondsJRSRate,Fiags,SS2Fast;skipaheadifnotsetforSlow""otherwise,setforSlowchargeCALLStartSlow;setOFFSETforSlowrateJPSS2—Oa;skip由adandreadvoltageSS2Fast;setforFastchargeLDIOFFSET,OfEFast;setOffsetforFastrateJRRBat6V,Flags2,SS2Fst;skipifnotsetfor6VmodeLDIOFFSET,O筋Fst"-.otherwise,adjustOFFSETSS2FstJRRRapid,Flags2,SS2Rap;skipaheadifrateisnotRapidCALLSetRmpUp;preparetorampfromFasttoRapidSS2Rap;setforRapidchargerateJPSS2—Oa".otherwiseskipaheadandreadvoltageSS2—0a—CALLGetBatt;getlatestvoltage&doubleif6VmodeCPIA,Volts09;verylowbattery腿CSS2一2;no,trynextlimitSS2一1;B^tei7<:9VLDfA,003h;yes,serviceit,below9VOLTSSJPSS2—5SS2一2,Battery>9VCPfA,Volts12;lowbatterystateJRNCSS2一4;no,gotoSS5SS2—3;9于<Battery<12VLDfA,004h;yes,serviceit,below12VOLTSSJPSS2—5SS2一4;Battery>12V;JRSAlert,Flags2,SS2EXIT;don'tstartchargeifAlertsetbyDouble6VLDIA,005h;normalchargeSSSS2—5LDCurentSS,A;preparetogotothecorrectstate(3,4or5)SETStarted,Flags;setFlagsforchargestartedCALLTumON;turnoutput,Fan,andChargingLEDoaSETSettle,Flags3;initialchargevoltagesettle咖deSS2EXITJPExitMain*BELOW9Volts**Batteryisextremelydischargedandmaybebad.Chargeforamaximum,*offiveminutes.Ifvoltagedoesnotcomeabove9Voltsinthistime**period,abortcharge.Otherwise,gotobelow12Volts.*SS3CALLChkRapid;updateRamptimer,ifnecessaryJRRSEC,TicFlag2,SS3EXTT;exitifvoltagesettletimenotexpiredRESSettle,Flags3;clearsettleflagCALLIReg;regulatecurrenttillwegettodV/dtJRRMIN,TicFlag2,SS3—1;checkiftimehasexpiredCALLSetAbort;yes,timetoabortJPSS3EXITSS3一1CALLBattProg;checkbatteryvoltageforchargeprogressCPIA,Volts09;isbatteryupto9VJRCSS3EXTT;contiimestate3if<9VINCCurentSS"..otherwise,gotostate4SS3EXITJPExitMain*BELOW12Volts**Batteryisverylow.Allowamaximumof2hoursforthevoltageto*riseabove12voltsundercharge.Ifvoltagedoesnotcomeup,goto*abortcharge.Otherwisegotonormalcharge.*SS4CALLChkRapid;updateRamptimer,ifnecessaryJRRSEC,TicFlag2,SS4EXIT;exitifvoltagesettletimenotexpiredRESSettle,Flags3;…otherwise,clearsettleflagCALLReg;regulatecurrenttillwegettodV/dtJRR眠TicFlag2,SS4一l;checkiftime(4hours)hasexpiredCALLSetAbort;yes,timetoabortJPSS4EXIT;exitroutineSS4—1CALLBattProg;checkbatteryvoltageforchargeprogressCPIA,Volts12;isbatteryupto12Vifnotjustexit;...otherwise,gotostate5JRCSS4EXITINCCurentSSSS4EXITJPExitMain*NORMALCHARGE**Programstayshereuntiltheventagereaches14.2voltsorthemaximum:*chargetimeisexceded.Ifthevoltagelimitisreachedtheprogram**willtransferto:*;*A.SSB(dV/dt)ifthethebatteryhasbeenchargingmorethan5*;*minutesor*;*B.SS9(Desulfation)iftheOCVwaslessthan12.2voltsor*;*C.SS14(Maintain)iftheOCVwasmorethan12.2volts*;*Ifthemaximumohargetimeisexcededtheprogramwillabort**CALLShowChgng;turaChargingLEDonCALLChkRapid;updateRamptimer,ifnecessary.EFCEQDEBUG;assemblenextlineonlyifdebuggingSETSwOff,SwDown;settoignoreTypeandRateswitches.ENDCJRRSEC,TicFlag2,SS5x;exitifvoltagesettletimenotexpiredRESSettle,Flags3"..otherwise,clearsettleflagCALLBattProg;checkbatteryvoltageforchargeprogressIRRHR,TicFlagl,SS5一0;skipnextlineifmaxtimenotexpired;NOTE:CurentSSsettoABORTbyBattProg.ChkProgSS5xJPSS5EXIT;exit(andabort)ifmaxtimeexpiredSS5—0CPIA,Voltsl42+l;checkifover14.2voltsyetSS5—1JRI^CSS5—2;yes,checkif>5minutesCALLIReg;no,regulatecurrenttillwegettodV/dtJPSS5EXTT;…andjustreturnSS5_2LD入CCDcnt;getCCDcnt(setbyBattPRogw/minutes)LDHrsl,A;setTimedhowstoCCDcntRESHiPwr,Flags4;setforlowpowermodeEESRmpInt^Flags3;clearflagbeforemovingon;RESSettle:flags3;clearflagbeforemovingonJRSMIN,TicFlag2,SS5一3;if>5迈in,gotodV/dtLDA301ciVolt;otherwise,checkinitialvoltageCALLDouble6V;doubleBatteryvoltageifsetfor6VCPI入Voltsl22;initialvoltage<12.2VJRCSS5—5;Yes:thendesulfateJPSS5一Maint;No:gotoMaintainSS5—5一LDfCurentSS,009h;batteryissulfatedLDIMaiiitVolt,Volts16;trytoholdbatteryat16VLDIVref,Volts15;andseeifitdropsto15VCALLIniTime2;LDIHrs2,002h;inlessthan2hoursSETRestore,Fkgs4;setRestoreflagJPSS5EXIT;SS5—3CaLlSetMinOff;min2Aoffsetvalue(maxcurrent)JRRRateflags,SS5—6;checkfor15AchargerateCALLSetMinFst;minFastoffsetvalue(maxcurrent)SS5一6LDA,LowOff;LoadLowOffintoAfornextstepLDOkiOff,A;initializeOldOfffordi/dttoLowOffLDICurentSS,OOBli;gotowaitfordv/dttripvoltageLDIPercent,77;setPercentto77CALLIniTime2LDIMins2,13;setto13minutesfordV/dtLDA,BADhi;getlatestbatteryvoltageSUBIA,4;preventmatch@1stdV/dtcheckLDMaintVolt,A;storeasmaintainvoltagefordi/dtLDITries,004h;initializedV/dtfor4Tries(3intervals)JPSS5EXIT;SS5—Maint;gotoMAINTAIN,batteryisalreadychargedCALLSetlOOp;setPercentto100LDIMaintVoltjVolts132;setmaintainvo!tagetoI3,2V;CALLFanOff;tumcoolingfanoffJRRBatTypeB,Flags,SS5—7;skipaheadifnotGel/AGMLDIMaintVolt,Volts135maintainvoltageto13,5VforGel&AGMSS5—7LDrCurentSS,00Eh;Maintainisstate14(0Ehex)CALLSetON;turncoolingfan&outputonCALLFanOff;turncoolingfanoffCALLSetHiOif;MAXoffsetvalue->mindutycycleSS5EXITJPExi麵in556557*SS8-ABORTCHARGE*承承:*TurnoffallDSD's.BlinkTROUBLELEDathalfsecondinterval.If*batterybecomesdisconnected,gotoBATTERYDETECT,*SS8SETAlert,Flags2;setAlertflag;CALLShutOff;low&highpower,fan,&crankoff;mindutyCALLSetoff;tumoffpowerandsetforduty;CALLChrgRly;chsmgeE/SrelayifnecessaryCALLBlinkAlert;biinlcredLEDJRSBurnln,Flags3,SS8X;don,tcheckforbatteryifB咖-InCALLCheck0V;checkfordisconnectedbatteryJRSBatt,Flags2,SS8X;ifconnected,justexitRESAlert,Flags2"..otherwise,endabortrcmtineSS8rstJPMAIN2;re-initializeSS8XJPExitMain*SS9-DESULFATION*;*DesulfationModeisenterediftheinitialbatteryvoltageis'less*;*than12.2voltsandthevoltagereaches14.0voltswithinfive*minutes.*Thechargertriestoholdthevoltageat16.0volts.Asthebattery*;*startstoconduct,tlievoltagewillfail.Ifthevoltagereaches14.0*inareasonabletimelimit(iohours),wewilltransitiontothe*;*nonnalchargingsequence(SS5),Ifthevotagedoesn'tfallto14.0;*voltswewilltransitiontotheABORTsequencestate(SS8),*SS9LDIPercent,15;setto15%CALLBlnkChrg;blinkChargingLEDCALLCheckBatt;checkforconnectedbatteryJRRBatt,Flags2,SS8rst;re-initializeifnotconnectedCALLVoltRegJRRSEC,TicFlag2,SS9X;wait1minuteJRRHR,TicFlag2,SS9」;maximumtimeout(1or2hours)DECCurentSS;AB(JrTstateSS9exitJPSS9X;doneSS9—1CALLGetBatt;getlatestvoltage&doubleif6VmodeCP入Vref;arewethereJRNCSS9exit;ifnot,thenexitDECVref;1countis0.0667voltsDECVref;reduceVrefby0.133voltsLDA,Vref;seeifbattisdesulfatedyetCPIA,Volts14;isVref<14.0VoltsJRCSS9—2;yes:skipnextlineJPSS9一3;no:tryanotherhourSS9—2一LDICurentSS,005h;preparetogotonormalchargeRESRestore,Flags4;abouttofinishRestoremodeLDA,Vmax;§etMaintVolttoVmaxLDMaintVolt,X;maintainvoltageforstate5CALLIniTime2''initializetimer2LDISecs2,002h;settimerfor2seconds(voltagesettletime)JPSS9X;SS9—3CALLIniTime2;resettimerLDIHrs2,001h;setmaxtimefor1hourSS9XJPExitMainSS10;*dV/dtMONITOR**Thisstateislookingforoneofthreeconditions:*:*1.Maximumtimeisexceded-setforcheckbatteiyandturnoffcharger.';*2.NochangeindV/dtfor45minutes-batteryisabout80%charged.*:*3.MAXvoltageisreached-GOTOdl/dt.*SS11IRRHR,TicFlagl,SSll一l;If加tmaxtimeout,gotoSSIl一lCALLSetAbort;otherwise,gotoabortJPSS11XSSll一lCAlXShowChgng;lightChargingLEDCALLGetBatt;getlatestvoltage&doubleif6V迈odeGPA,Vmax;isbattvoltage<MAXvoltageIRC112;yes:continueloopSETHiEn5,Flags3;no:settoboostduringD/CEndChargeJPSS11一6;,,,andpreparetoGOTOdI/dtSSIl一2一JRR^N,TkFiag2,SSnX;exitifnottimefordv/dttestLDA,Percent;getPercentCPIA,84;isPercent<84篇CSSIl一3;..,ifnot,skipaheadINCPercent""otherwise,increasePercentSS11—3LDX,BADhi;getbatteryvoltageDECA;limitfor6Vbatteriesis1ccomtJRSBat6V,Fiags2,SS1l一3a;leavelimitat1for<5VbatteriesDECA;limitfor12V"latteriesis2countsSSI1—3aCPA,MaintVolt;testforupperlimitchangeIRCSSI1—4;lessthan〗countup,testdownchangeJPSSI1—7;otherwise,skipaheaS&updateMaintVoltSSI1—4—DECTries;decrementcountermzSSI1—6;alldone,GOTO纖LDAjPercent;getPercentCPI入87;isPercent<88層CSS11—5;…ifnot,skipaheadINCPercent;.,,otherwise,increasePercentSSI1—5JPS§11—8;no,reloadtimerSS11一6一INCCurentSS;GQTOdi/dtnextLDIPercent,88;setPercentto88-NOTEmustalwaysbeevenJRSH正nd,Flags3jMntMx;skipaheadifVmaxreachedCALLGetBatt;getlatestvoltage&doubleif6VmodeLDMaintVolt,A;saveBADhiasmaintainvoltageJSSI1—9^initializeTriesandTimer2fordi/dtMntMxLDA,Vmax;otherwise,setMaintVoittoVmaxLDMaintVolt,A;MaintVoltusedfordi/dtJPSSI1—9^initializeTriesandTimer2fordi/dtSSI1—7;updateMaintVoltLDA4BADhi;getcurrentbatteryvoltageLDMaintVolt,A;updateMaintVoltfordV/dt&di/dtSSI1—9LDITries,004h;resetcounter(4matches=3intervals)SS11—8CALLIniTin]e2;initializetimerLDIMms2,009h;…for9minutesSSllXJPExi她in*di/dtMONITOR*,*Indi/dttheOFFSETvalueisadjustedtoholdthevoltageatthedV/dt**value.TheOFFSETvaluewillincreaseandstabilize.**Thisstateislookingforoneoftwoconditions:*;*1,Maximumti迈eisexceded-setforcheckbatteryandturnoffcharger,2.NochangeinOFFSETvaluefor39minutes-currentstabilizedata*;*lowvalue.Batteryisabout97%charged.GotoSS13(EndCharge)for*;*1hour.*SS12CALLVoltReg;regulatebatteryvoltageatMaintVoltLDA,DspPcnt;getlast%displayedCPIA,IOO;has%displayedreached100JRZSSi:2一l斗;,"ifso,turnongre6iiL:EDCALLShowYellow;.,,otherwise,turnonyellowLEDJPSS12—15;..,andskipahead(leavegreenofQSS12—14—CALLShowDone;tumonchargecompleteLEDSS12__15JRR^TicFlagl,SS12—1;咖ximumtimeoutJRSAler^Flags2,SS12二0;If2ndmaxtimeout,gotoSSI2—0SETAlert,Flags2;If1stmaxtime,setAlert迈agCALLIniTimel;andresettimerLDIHrsl,004h;toalow4咖rehoursSS12—10LDA,MaintVolt;andgetMaintainvoltageSUBI人007h;thensubtract0.5VLDMaintVolt,A;andupdateMaintainvoltageJPSS12EXTT;thenrestartdi/dtSS12一0CALLSetAbort;gotoabortRESAlert,Flags2;resetAlertflagforAborttimerJPSS12EXITSS12—1JRR"klN,TicFlag2,SS12EXlT;timefordi/dttestLDA,Percent;getPercentCPIA,IOO;isPercent<蘭JRNCSS12—2;…ifnot,skipaheadINCPercent;,..otherwise,increasePercentLDAjPercent;getpercentCPIA,IOO;Ispercent=100JRZSS12一2;YES,don'tincreaseanymoreINCPercent;No,increaseby2SS12—2CAlXchkHiOff;checkformaxOFFSET(PWMfoiloff)JRNCSS12—13;ifso,finishdi/dtDECA;ensurecarryifequalCPA,OldOff;testforlowerlimitchangeJRCSS12—4;offsetwithin1,finishdi/dtJPSS12一7;offsettoohigh,tryagainSS12—13—JPS^"l2一6SS12一4DECTries;decrementcounterJRZSS12—13;if0,thenpr邻areforEndCharge(SS13);JRNZSS12一5;Arewedone7;JPSS12一6syes,alldone,cleanupandexit;SS12—5;no,continueLDA,Percent;getPercentCPIA,99;isPercent<100JRNGSSi:2—3;…ifnot,skipaheadINCPercent"..otherwise,increasePercentJPSS12—8;reloadtimer&checkagainlaterSS12一3—LDA,Tries;getthecurrenttriesCPIA,03;Istrieslessthan3JRNCSS12一11;No,justexitCALLSetl5bp;Yes,show100%anddoneSS12—11JPSS12—8;reloadtimer&checkagainlaterSS12一6一INCCurentSS;GOTOEndCharge(SS13)CALLIniTime2^initializeTimer2LDIHrs2,001h;chargefor1迈orehour(EndCharge)LDIMins2,00Fh;chargeforonly15minutes(EndCiarge)JRRBatTypeA,Flags,SS12一9;skipifnotDeepCycle(Voyager)■H正nd,Flags3,SS12—9;kipifnotusinghigherEndChargevoltageINCHrs2;otherwise,changeHrs2from1to2LDA,MaintVolt;also,storeMaintVoltinAADDIA,04h;increaseAby4counts~0.267VLDMaintVolt,A;storeupdatedvalueinMaintVoltSS12一9JPS§i2EXITSS12一7LDA,OFFSET;setnewbaseoffsetLDOldOff,A;saveinOldOffLDITries,004h;resetcounter(4matches=3intervals)SS12—8CAlXIniTinie2;initializeTimer2LDIMins2,009h;setTimer2for9minutesLDA,OFFSET;GetcurrentoffsetCPA,LowOff;Istheoffset-MinOffJRNZSS12EXTT;NOJustexitRES腿nd,Flags3;YES,don'tboostvoltageforEndChargeJPSS12—10;Currentnotfalling,reducevoltageby1/2VSS12EXfiJPExitMainENDCHARGE*:Chargefordesiredhoursafterdl/dtatdV/dtvoltage.SS13CALLSetlOOp;setPercentto100LDA,DspPcnt;getlast%displayedCPIA,100;has%displayedreached100JKNZSS13一2;...ifso,turnongreenLEDCALLShowDone;tarnonchargecompleteLEDSSI3—2CALLVoltReg;regulatebatteryvoltageatMaintVoltCALLChkHiOff;checkformaxOFFSET(PWMfiilloff)JTRZSSI3—1;exitifmaxOFFSETreachedJRRHR,T^Fkg2,SS13EXIT;exitif1hourtimenotupSS131JPSS5_Maint;…otherwise,GOTOMAINTAINSS13E^JPExitMain*MAINTAIN**Batteryhasreachedfiillcharge.Stayhereandmaintainbattery*at13.2voltsuntilbatteryisdisconnected.*SS14CALLSetlOOp;setPercentto100CALLVoltReg;regulatebatteryvoltageatMaintVoltLDA,DspPcnt;getlast%displayedCPIA,100;has%displayedreached100JRZSS14_1".,ifsD,turnongreenLEDCALLShowYellow"..otherwise,turnonyelkwLEDJPSS14—2;...andskipahead(leavegreenoff)SS14—1—CALLShowDone;turnonchargecompleteLED.IFCECJDEBUG;assemblenextlineonlyifdebuggingRESSwOff,SwDown;settocheckTypeandRateswitches.ENDCSS14_2CAlXChkHiOff;checkformaxOFFSET(PWMfoiloff)IRNCSS14—3;...ifso,shutofffanIRSBat6V,flags2,SS14_5;skipaheadif6VmodeCPIAJEOff-4;checkforsustainedo啤utJPSS14一7SS14—5一CPIA,Hi0ff64;checkforsustainedoutputSS14—7JRNf5sS14—4;...ifnot,leavefanoffSS14—6—CALLFanON;…otherwise,turnfencmJPSS14—4andskipaheadSS14—3_CALLFanOff;tarncoolingfanoffSS14一4CALLCheckBatt;checkforbatteryJRSBatt,Flags2,SS14EXIT;...connected:continueJPMAIN2;...disconnected:startoverfromstate0SS14EXITJPExitMain*SS15MANUAL**Regulatecurrent.Novoltagelimit.Resetafter1hour.SS15JRRPower,Flags2,SS15—2;poweroffindicatescompletedBurn-InCALLShowRate;tum—onthe2Aor15ALED;NOTE:outputalreadyon,butTumONsavescodespaceCALLTumON;tumoutput,Fan,andChargingLEDon,IFCEQAdjOff;assemblenextlineonlyifdebuggingIRRBumln,Flags3,SS150K;don'tregulateifnotB咖-inmode.ENDCCALLIReg;regulatecurrentatselectedrate;CALLCheck!7v;checkfordisconnectedbattery;JRNZSS150K;if17V,thencontinue;LDICurentSS,ABORT"..otherwise,Abort;RESManual,Fiags3;…endM咖a〗Mode;JPSS15EXTT;...andskiprestofState15SS150K爪SBumln,Flags3,SS15BI;skipaheadifB咖-inmode'IFCNEAdjQff;assemblenextlinesonlyifnotdebuggingRESMtrScale,Flags;setforAlternator%LEDoffRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffCALLShowMeter;updatemeterLEDs.ENDCJPSS15rmp;jumptorampcheckSS15BIJRRMIN,TicFlag2,SS15b;skipaheadifnottimetoupdatecounterDECCCDcnt;decreasedisplaycountby1CALLIniTime2;resetTimer2LDIMins2,;settimerforcounterinterval(〗minute)SS15bLDA,CCDcnt;getlatestcountdownvalueLDLED加m,A;storeinLEDnumCALLShowNum;displaycountondigitalLEDCALLMeterOff;turnoffallmeter迈odeLED'sSS15rmp.IFCEQAdjOff;assemblenextlinesonlyifdebuggingCALLCheckSw;checkifswitchisbeingpressedCALLGetMeter;updatemeterLEDsJPSSI5—1;skipnextthreelines.ENDC—CALLShowData;updatedisplayJRRRapidjFlags2,SS15—1;don'trampifRapidisnotsetCALLChkRapid;updateRamptimer,ifnecessarySS15一1JRRHR,TicFlagl,SS15EXIT;continueifnotmaxmanualchargetimeJRSBumln,Flags3,SS15一2;skipaheadiffinishedBura-InJPRESET;,,,otherwise,resetSSI5—2CAllDigitsOff;tumoff3-digi1:LEDCALLResetLEDs;turnoffalltype,rate&StatusLED,sCALLShowGreen;lightGreenLEDonlyCALLSetOff;resetPower&Crankingflags;set迈in.dutySS15EXITJPExitMain*BOOSTMODE*,Firstsetthechargeroffsetvaluefor2ampcharging.Next,wait*;*forthevoltagetostabilize.Thenwaitforthevoltagetodrop*,*abouttwovolts.Whenthevoltagedrops,gofullonfor5seconds.**Afterfivesecondsofcranking,waitfor4minutesandstartover.*CommenttheCALLandthefollowingtwoLDI'sfortest.Alsoloadoffset*<formula>formulaseeoriginaldocumentpage176</formula>CALLVoltReg;regulatebatteryvoltageatMaintVoltLDA,FreshBV;getoiurentreadingSUBIA,01Oil;adjustforaonevoltdropCPA,oidVolt;hasvoltageincreasedJRCSS18—2;ifnot,thenskipaheadLDOldVo"it,A;updateOldVoltSS18xJPSS1犯XIT;andexitroutineSS18一2LDA,FreshBV;getcurrentreadingCPA'OldVoH;1Vdropmightindicatecranking腿CSS18xijustexitifnodropADDIA,0Ch;storeFreshBV+0.8VinACPA,BADhi;islatestaverage>FreshBV+0、8VIRNCSS18EXIT;ifBADhi>FreshBV+0.8V,startcrankingSS18—1SETPower,Flags2;turnoutputonINCCurentSS;timethecrankingSETCralaig,Fbgs4;indicatecrankingstartedCALLIniTime2LDISecs2,CrankON;crankforCraukON(5)secondsSS18EXITJPExitMain;*CRANKTIMING*;*Allowcrankingforfivesecondsandthengobacktocharging,*SS19LDA,Secs2;getremainingcranksecondsLDLEDnum,A;storeinLEDnumCALLMeterNum;showLEDn咖andturnoffmetermodeLED'sJRRSEC,TicFlag2,SS19EXIT;ifcrankingnotfinished,thenexitRESSCRs,DRBbuf;turnoffSCR's(inbuffer)CALLUpdatePB;updateportBfrombufferCA11ResetStatus;turnoffChargingLEDRESCrnkngjFlags4;indicatefinishedcrankingRESPower,Flags2;telltimertoleavechargeroffINCCurentSS;justwaitfortimetoexpireCALLSetOff;turnoffpowerandsetformindutySETCrankWai、Flags;indicatescrankcool-downtimeCALLIniTimel;resetTimerlLDISecsl,CCDint;settimerforcounterinterval(seconds)LDICCDcntCrankOff;setcrankcooldowncountertoCrankOffseesSS19EXITJPExitMain*INTER-CRANKDELAY**Stayhereuntilthe4minutetimerhasexpiredthengobacktoBOOST:*ifswitchstillengaged,elsegoto2Aauto(default)*SS20CALLFanON;turncoolingfanONJERSEC,TicFlagl,SS20一0;skipaheadifnottimetoupdatecounterDECCCDcnt;decreasedisplaycountby1<formula>formulaseeoriginaldocumentpage178</formula>LDIWDRjOFEH;resetwatchdogtimerRET*SetAbortState**ThisroutinesimiplysetsCurentSStoABORTsothatthecodewillgo'*totheAbortstateafterthenextNMI.SetAbortwaswrittenonlyto**saveprogramspace(LDIrequire3bytes,CALLrequiresonly2).*SetAbortLDICurentSS,ABORT;setcurrentstatetoAbortRET*Setl00Percent**ThisroutinesimiplysetsPercentto100,Setl00pwaswrittenonlyto;*sawprogramspace(LDIrequire3bytes,CALLrequiresonly2).*Setl00pLDIPercent,100;setPercentto100RETClearPercent*:ThisroutinesimiplysetsPercentandDspPcntto0.ClrPcntwas*:writtenonlytosaveprogramspace(CLRrequire3bytes,CALLrequires:only2),SetOpisthesecondhalfofClrPcnt.**Set0Percent*Thisroutinesi迈ipiysetsPercentto0.SetOpwas"writtenonlyto*saveprogramspace(LDIrequire3bytes,CALLrequiresonly2).*ClrPcntCLRDspPcnt;setDisplayPercentto0SetOpLDIPercent,O;setPercentto0RET*UpdatePortA**ThisroutineupdatesPortAwiththecontentsoftheDRAbuffer.*UpdatePAwaswrittenonlytosaveprogramspace,*UpdatePALDA,DRAbuf;updateAccumulatorfrombufferLDDRA,A;updateportfromAccumulatorRET*UpdatePortB**ThisroutineupdatesPortBwiththecontentsoftheDRBbuffer,**UpdatePBwaswrittenonlytosaveprogramspace.*UpdatePBLbA,DRBbuf;updateAccumulatorfrombufferLDDRB,A;updateportfro迈AccumulatorRET*UpdatePortBOptions**ThisroutineupdatesthePortBoptionswiththecontentsoftheORB*buffer.UpdateORBwaswrittenonlytosaveprogramspace.*UpdateORBLDA,ORBbuf;updateAccumulatorfrombufferJLDORB,A;updateoptionsregisterfromAccumulatorRET*WaitaFi他Second**Thisroutinecausestheprogramtowaitonefifthsecondbywaiting*for24interrupts.*Fi他SecondCALLIniTimelLDIMSecsl,MS200;settimerfor1/5secondWFS—1CALLRstWDR;resetwatchdogtimerJRRMSEC,TicFlagi;WFS一l;waittmtntimergoesto0RETSetRampUp*:Thisroutinesetstheparametersnecessarytochangethedutyfro迈the:fastratetotherapidrate.ItisusedbeforeBurn-InandAutomatic*:Rapidcharge,*SetRamp*:Thisroutinesetstheparametersnecessarytochangethedutybetween;thefastandrapidrates.ItisactuallythelastpartofSetRmpUp.*SetRmpUpLDIE]mpCnt,ilCinitF;setcounterforFastRESHiPwr,Flags4;setforlowpowerSetRampLDITEMP,RIinit;120丽Iinterruptsyields1.5secondsSETRmpInt,Flags3;counting1stoftwo180cycleperiodsRET*CHECKRAPID**丁hisroutinedetermineswhethertoreduceorincreasethechargerate*fromRapidtoFastorvicaversa,ifnecessary.Itsetstheflags**usedbyRampOSappropriately.*ChkRapidJRRRapid,FIags2,ChfcRapX;ifnotRapidchargerate,thenexitDECTEMP;otherwise,updateramptimerIRNZChekRapX;exitifnottimetoupdatecoratLDI丁EMP,RIinit;count180morecycles(1,5seo)JRRRmpInt,Flags3,RmpCtr;skipalieadifjustcounted1sthalfRESRmpInt,Flags3"..otherwise,startcounting2ndhalfChekRapXJPChkRapX:andexitRmpCtrSETRmpInt,Flags3;counting1stoftwo180cydeperiodsDECRmpCnt;checkiftimetorampJRNZChekRapX;exitifnottimetorampJRRHiPwr,Flags4,StRmpUp;sldpaheadifchangingtohigherrateRESHiPwr3Flags4;setfornotHiPw(changetolowerrate)LDIRmpCnt,R5initF"..otherwise,setforFastrate;LDIOFFSET,OffRamp;setforbetweenFast&RapidratesJPChkRapRStRmpUpSETHiPwr,Flags4;setflagsfor>FastrateLDIRmpCnt,RCinitR;setcounterforRapidrateChkRapRLDIOFFSET,OfiRamp;setforbetweenFast&HapidratesChkRapXRET*SHOWNUMBER**ThisroutinedetermineswhatthreedigitstodisplayonthedigitalLEDs*torepresentthenumberstoredinLEDNum.Thethreedigitswillbe**displayednexttimetheShowDataroutineiscalled,*ShowNuraCLRIndex;initializeLUTIndexto0CALLDigiOff;setregistersforallsegmentsoffLDA,LEDnum;storeLEDnuminaccumulatorCPIA,10;dieckforsingledigitnumberJRNCChkMaxN咖;...ifnot,checkformaxnumberJPNextOOl".'otherwiseskipto3rddigitChkMaxNum.IFCNEAdjOff;assemblenextlinesonlyifnotdebuggingCPIA,199;checkforhighestdisplayablenumberJRCCheckl00;ifkss,checkvalueLD1A,199"..otherwise,display199.ENDCCheck100CPIA,100;checkwhethertoshowmostsignificant1JRCCheck010;ifnot,checkfor10RESDigitl,DigiDat2;otherwise,turnONmostsignificant1SUBIA,IOO;…andsubtract100fromaccumulator.IFCEQAdjOff;assemblenextlinesonlyifdebuggingJPCheck100;checkwhethernumberwasgreaterthan200.ENDCCheck010CPIA,IO;checkif<10IRCCheck001;…ifso,skipaheadandcheck3rddigitINCIndex"..otherwise,shownexthighervalueSUBIA,IO;.',andsubtract10fromAcumulatorJPCheckOlO;,,,andcheckfor加xthighervahieCheckOOlLDIDRWR,Digits(bcO.w;lookuptable(LUT)for2nddigitLDIX,DigiteOxO.d;initializeLUTLDAT加p,A;saveAccumulatorLDA,Index;getindexfromstartofLUTANDIA,03Fh;limittowindowADDA,X;a<WbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAANDA,DigiDat2;…setbitsinAforseconddigitLDDigiDat2,A;…storeAintoDigiDat2LDA,ATemp;restoreAccumulatortoremainderofLEDnumLDIDRWR-DigitsOOx.w;lookuptable(LUT)for3rddigitLDIX,DigitsOOx.d;initializeLUTANDIA,03Fh;iimittowindowADD入X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAANDA,DigiDatl;…setbiteinAforsegmentsLDDigiDatl,A;,..storeAintoDigiDatlShowNumXRET;*GETVOLTDIGITS*:*Thisroutinedetermineswhatthreedigitstodisplayonthedigital;*LEDtorepresentthebatteryvoltage(BADhi).GetVoltsDECVtCnt;decre迈entintervalcounterJRZNewVolt;if0,readytoupdatedisplayJPGetVexit;...otherwise,justexitNewVoltLDIVltCnt,MS500;re-initializeintervalcounterJRRChMode,Fkgs2,GVT;ifTestermode,useFreshBVLDAjBADhi;getlatestavgbattvoltageJPGV10GVTLDA,FreshBV;GetlatestaveragebatteryvoltageG稀CALLDigiOff;setregistersforallsegmentsoffCLRIndex^initializeLUTIndexto0CP〗A)MaxVolts;checkformaxvoltreadingJRCGV17;skipaheadiflessthanmaxLDIDigiDatl,DigiMVl;setfordigit1ofmaxvoltdisplayLDIDigiDat2,DigMV2;setfordigit2ofmaxvoltdisplayJPGetVexit;exitGetVoltsGV17CPIA,Vo諸;checkfor醇JRCChecklV;if加tlOVthenskipaheadRESDigitl'DigiDat2;otherwise,turnONmostsignificant1SUBIA,VoltslO;…andsubtract10VfromaccumulatorChecklVCPIA,VoUsOl;checkif>1.OVJRCCheckOlV;.,.ifso,skipaheadandcfaieck3rddigitJNCIndex"..otherwise,shownexthighervalueSUBIA,VoltsO〗;'』ndsubtract1.OVfromaccumulatorJPChecklV;.,.andcheckfornexthighervalueCheckOlVLDATemp,A;saveAccumulatorLDIDRWR,DigitsOxO.w;lookuptable(LUT)for2nddigitLDJX,DigitsOxO.d^'initializeLUTLDA,Index;getindexfromstartofLUTANDIA'03Fh;limi"owindowADDAjX;addb朋eaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAANDA,DigiDat2;…setbitsinAforbottomsegmentsLDDigiDat2,A;…storeAintoDigiDat2LDA^ATemp;restoreAccumulatortoremainderofLEDnumShcrwYOOlLDIDRWR,DigitsOVx.邻;lookuptable(LUT)for3rdvotedigitLDIX,DigitsOVx,d;initiaUzeLUTANDIA^03F1l;limittowindowADDAjX,'addbaseaddressoftableLDX,A;storeaddressofvalueinXLD人(X);storevalueatXintoAANDA,DigiDatl;...setbitsinAforbottomsegmentsLDDigiDatl,A;…storeAintoDigiDatlRESDecimal,DigiDatl;tumONdecimalpointGetVexitRETVoltMeter*'Thisroutinesetsthedisplaytoshowvolts,thencallsShowMeterand'ShowDatatoupdatethedisplaywiththecurrentbatteryvoltage.**GetMeter*:ThisroutinecallsSho*wMeterandShowDatatodisplaythelatest步:voltageorpercentage(determinedbyMtrScale&MtrUnits)onthe*:3-digitLEDdisplay.GetMeteristhelastsectionofVoltMtr.*VoltMtrRESMtrScale,Flags;setforAlternator0/0LEDoffRESMtrUnits,Flags;setforVoltsLEDON,batt。/。LEDoffGetMeterCALLShowMeter;updatemeterLEDsCALLShowData;updatedisplayRETGETPERCENT*;*Thisroutinedetermineswhatvaluetouseforthepercentageof*;*chargebeforethechargestatehasreachedthedv/^tstate.The*;*percentiscalculatedbyreadingthebatteryvoltage(BADhi)and*;*performingthefollowingcalculations:*AsTester*;*1.0V<BADhi<ll,6VDC=>Percent-(BADhi/16)+l*;*11.61V<BADhi<12.8VDC=>Percent-(BADhi-175)*5+15*;*12.80V<BADhiPercent-100*AsCharger*;*1Volt<BADhi<12Volts=>(BADhi/4)+15-Percent*;*12Volts<BADhi<dv/dt=>(BADhi/2)-30=Percent*GetPercentJRRChMode,Flags2,TstrBP;jumptoTester%ifnotcharging爪SRestore,Flags4,GPend;don'tget%inRestoremodeLDA^CurentSS;getcurreatprogramstateCPIA,11;haschargingreacheddV/dtJRCCalcPrcnt;…ifnot,calculatepercentageJPGetPctEnd;..'otherwise,donothingCalcPrcntLDAyPercent;getPercentCPIA,76,'ciieckforhighestcalculated%IRKCGPend;exitifalreadythereJRSHiPwr,Flags4,GPend;exitifinHighPowermodeLDA,RmpCnt;getRampintervalcounter;NOTE:RmpCntwillbe0ifnotsettorampatallCPIAj5;isitalmosttimetoramp邵?JRNCGPend;dou,tupdate%untilendoflowpowerintervalCALLGetBatt;getlatestvoltage&doubleif6VmodeCPIA,V。lts12;isthebatteryvoltagelessthan12VJRNCFomula2;...No,gotoFormuia2CPIA,Vo謹;Isbattery>1JRNCGPforml;…ifso,skipnextlineIPGP2er0;…ifnot,setforzero%GPformlCALLDivide4;...Yes,usefirstformulaADDIAJ5;Addl5and…JPGetPctExit;...storemtoAFormula2CALLDivide2;Divideby2andSUBIA,30;…犯btract30JPGetPctExit;skipaheadandfinishroutineTstrBPLDA,FreshBV;getlatest(avg)batteryvoltageCALLDouble6V;doubleBatteryvoltageifsetfor6VCPIA,Volts128;Isbattery>12.8VJRCTst測;".ifnot,skipaheadCALLSetlOOp".otherwise,Percent=100JPGetPctEnd;…andendrcrutineTstrlOOCPIA,BattMk;Isbattery>BattMin羅CTstrBPhi;…ifso,jumpaheadCPIA,Vo繊;Isbattery>1JRNCTstrBPmed;…ifso,jumpaheadGPzeroCALLSetOp;…otherwisesetPercentto0JPGetPctEnd;…andendroutineTstrBPhiSUBIA,BattMin;subtractminimumhighvoltageCALLATimes5;multiplyby5ADDIA,15;addl5JPGetPctExit;…storeintoATstrBP边edSUBIA,15;A-battery-15CALLDivide4;A-(battery隱15)/4CALLDivide4;A-(battery-15)/16INCA;A=(battery-15)/16+lGetPctEdtLDPercent,A;storeintoPercentGetPctEndRET*UPDATEBATTERYPERCENT**Thisroutinecontrolshowthebatterypercentagedisplayedisupdated.51*UpdateBPensuresthatundernormalcircumstances,thebattery%dis-1*playedisupdatedaccordingtothefollowingtworules'**1.The%displayeddoesn'tchangebymorethan1%atatime**2.The%displayedisnotupdatedtwicein<PCintseconds*承TThareareafewexciGptioiis.承*I.The%displayedcanjumpupmorethanIifitwas0**2.The%displayedwilldropto0immediatelyfordisconnectedbatt.**3.The%displayedcanchangebymorethan1ifthescale**changes****Scalereferstothe%scale,whichiseitherbatteryoralternator*UpdateBPLDA,Percent;checkwhether%is0JRNZUBPO;..,ifnot,waitforupdateintervalJPUBPfinish"..otherwisefinishroutineUBPOLDA,DspPc加;getlast%displayedJRZUBP00;continueif0o/oJPUBP1;skipaheadifnot0%UBP00JRSMtrScale,Flags,UBPl;alsoskipaheadifAlternator0/oJRSWaitOP,Flags2,UBP2:;skipaheadifWaitOPflagalreadysetSETWaitOP,Fkgs2"..otherwise,setflagtowaitCALLIniTime2;initializeTimer2LDISecs2,3;setTimer2for3secondsJRRChMode'Fiags2,UBPz;skipaheadifintestermodeLDISecs2,5;setTimer2for5secondsitichargermodeUBPzJRRSEC,TicFlag2,UBPx;skipaheadifstillwaitingUBPOaRESWaitOP,Flags2;setflagtoindicatenotwaitingLDA,Percent;,.,otherwise,getnew%JPUBPfioish;,,,anddonrtwaittodisplayitUBPxJPUBPexit;…andjustexitUBP1DECPcntL-'decrement%interruptcounterJRNZUBPx;ifnot0thenjustexitLDIPcntL,MSINIT;re-initialize%interuptcounterDECPcntH;decrementintervalcounterJENZUBPx;ifnotdownto0,thenjustexitLDIPcntH-PCint;re-;initialize%intervalcounterLDA,DspPcnt;getlast%displayedJENZUBP2;skipaheadifnot0%LDA,Percent;getnew%JPUBPfinisli;andfinishroutineUBP2CPA,Percent;comparetonewest%JRZUBPexit;ifequal,donothingJRCIqcBP;ifess,increasedisplay%by1JRSChMode,Flags2,UBPexit;don'tdecrease%ifchargingDECA;".otherwise,decrease%by1JPUBPfmishandfinishIncBPINCA;increasedisplay%by1UBPfinishLDDspPcn仁A;storeupdateddisplay%UBPexitRET*MeterNum**ThisroutinecallsMeterOff,ShowNum-andShowDatatoturnofftbe**displaymodeLED'sanddisplayLEDnumonthe3-digitLEDdisplay.*NumData**ThisroutinecallsShowNumandShowDatatodisplayLEDn咖onthe*3-digitLEDdisplay,NuraDataisthelastsectionofMeterNum.*MeterNumCALLMeterOff;turnoffallmetermodeLED'sNumDataCALLShowNum;getdatatoshowthenumberCALLShowData;showthenumberRET*SHOWDATA**This咖tineupdatesthedigitalLEDand6switchLEDscontrolledby:*theserialtoparallelshiftregisters.ItsendsthebitsofSwData**andDigiDatatotheregistersbitbybitfromLSBtoMSBusing**SerData.Aftereachbitissen、ShftClkistoggledtoshiftthebit**tothenextposition.Afterall24bitshavebeensent,LtchClkis**usedtoupdatetheoutputs,whichupdatestheLEDs,*ShowDataCALLRstWDR;resetwatchdogtimer;RESClrData,DRAbuf;dearshiftregister;CALLUpdatePA;updateportAfrombuffer;SETClri)ata,DRAbuf;preparetoacceptdata;CALLUpdatePA;updateportAfromimfferLDIBitCnt,008h^initializebitcounterto8LDIBytCnt,003h;initializiebytecounterto3LDA,DigiDatl;getfirst8bitsofdigitdataGetBitRLCA;sendMSBofAcumu!atortoCanyJRCSetBit;ifCarry=lthendatabitis1RESSerData,DRAbuf"..otherwisesetSerDatato0JPSendBit;skipaheadtoSendBitSetBitSETSerData,DRAbuf;setSerDatato1SendBitLDDataBuf,A;storeshifteddatafromACALLUpdatePA;updateportAfro迈bufferRESShftClk,DRBbuf;setShiftClocklowRESLtchC丁k,DRBbuf;setLatchClocklowCALLUpdatePB;updateportBfrombufferSETShftCli;DRBbuf;setShiftClockhighCALLUpdatePB;updateportBfrombufferDECBitCnt;updatebitcountIRZNextData;ifallbitssentthenskipaheadLDAjDataBuf;storeshifteddatabackinAIPGetBit;otherwise,getnextbitNextDataDECBytCnt;updatebyte咖ntJRNZNextByte;getnextbyteiscountisnot0JPLatchData;…otherwise,donesendingbitsNextByteLDIBitCnt,08h;setbitcountfor8morebitsLDA,BytCnt;whichbyteisnextCPI人02h;checkfor2ndbyteisnextIRZScndByte;skipaheadifequalLDA,SwData;get8bitsofswitchLEDdataJPGetBit;sendbitsofsecondbyteScndByteUDA,DigiDat2;getlast8bitsofdigitdataJPGetBit;sendbitsofsecondbyteLatchDataSETLtchClkjDRBbuf;updatelatchesCALLUpdatePB;updateportBfrombufferRET*ShowMeter**ThisroutinesetsthedigitalLEDtoshoweitherthecurrentvoltage**orlastpercentbasedonFlagsandCurentSS,DuringEnginestart,it**willcountdownsecondsofeitherremainingcranktimeorcooldown*time.*ShowMeterJRSAlert^hgs2,SMeXit;exitifabortmodeIRSMtrlMts,Flags,GetPrcnt;skipaheadandsetfor%CALLGetVolts;…otherwise,getvoltsJRSChMode,Flags2,SMl;skipaheadifnotinTestermodeCALLShowStatus""otherwise,updateStatusLEDsSMIJPShowMtrX;".andskiptoendorroutineGetPrcntJRRChMode,Flags2,TsMtr;ifintestermode,get%JPShowPrcnt"..otherwise,skipahead&show%ShowOCALLSetOp;settoshow0%ShoPerJPShowPrcnt;andskipaheadTs飾LDA,FreshBV;getlatestBatteryvoltageIRZShowO;if0V,show0%JRRMtrScale,Flags,ShoPer;showBattery%ifnotsetforAlt%CALLDouWe6V;doubleBatteiyvoltageifsetfor6VCPA,AJtMin;checkfor<1stLUTvalueJRCShowO;ifso,showO%CPIA,AltMax;checkfor>lastLUTvalueJRCAltVal;ifnot;skipaheadandcheckLUTLDIPercent,199""otherwise,setto迈axvalueJPShowPrcnt;andskipahead層alLDIDRWR,AltLvls.w;LUTforalternator%LDIX,AltLvls.d;initializeLUTSUBIA,AltMin;diffenceisindexinlookuptableANDIA,03Fh"imittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoALDPercent,A;storevalueintoPercentShowPrcntCALLShowPercent;otherwise:showpercentageCALLShowStatus;turnonappropriatestatusLEDShowMtrXCALLShcMtrMode;tumonappropriatemeterLEDSMeXitCALLRstWDR;resetwatchdogtimerRETSHOWMETERMODE*ThisroutineturnsononeofthemeterunitsLED'sbasedonFlagsandFlags2.IftheunitisinTesterMode(ChMode-O),theroutinewill**alsolighttheappropriatestatusLEDbasedonthevoltageatthe*clamps,*ShoMtrModeSETLEDvolt,DRAbuf;turnoffDCVoltageLEDSETLEDprcnt,DRAbuf;turnoffBattery%LEDSETLEDalt,DRAbuf;turnoffAlternator%LEDShowVoltsJRSMtrUnits,Flags,ShoPrcnt;gotoShoPrcntifsetRESLEDvolt,DRAbirf;turnonVoltageLEDJPShowMMXShoPrcntJRSMtrScale,Flags,ShowAlt;gotoShowAltifsetRESLEDprcnt,DRAbuf;turnonBattery%LEDJPShowMMXShowAltRESLEDalt,DRAbuf;turnonAlternator%LEDShowMMXCALLUpdatePA;updateportAfrombufferRET*HoldMeterModeLED(dependingonmode)**ThisroutineturnsontheBattery%,VoltsDC,orAltemator0/。LEDbased*onFlags&Flags2andke邻stl^itLEDonforonefifthsecond.*HoldMtrMdCALLShoMtrMode;turnonMeterModeLEDCALLFifthSecond;柳itonefifthsecondRET*SHOWSTATUS**ThisroutineturnsononeofthethreestatusLED'sbasedonthe*batteryvoltage.Thisroutineisforuseinthetestermode.*ShowStatusJRSChMode,Flags2,SlioStatX;exitifnotTester加odeJRRBatt,Flags2,RedStat;showredLEDifnobatteryJRRMtrUnitsJFlags,QrStat;tumoffStatusLED'sifvotsmodeLDA,FreshBV;getlatestBatteryvoltageJRSMtrScale,Flags,TestAlt;skipaheadifsetforAlternatorLDA,DspPcnt;getlast%displayedCPIA,IOO;Isitl00%JRZGmBatt"..ifso,showgreenLEDCALLResetStatusotherwise,turnStatusLED'soffJPShoStatX;…andskiptoendGrnBattCALLShowGreen;turnonGreenLEDJPShoStatX;skiptoendTestAltCALLDouble6V;doubleBatteryvoltageifsetfor6VCPIA,Voltsl5a;Isalternatoratleast15.07VIRNCRedStat;…ifso,skipaheadandshowredCPIA,Volts138;isalternatoratleast13.80VJRCRedStat;...ifnot,skipaheadandshowredCPIA,Volts14;Isalternator<14.0VJRCCliStat;…ifso,skipaheadandshowydlowCPIA,Volts149;isalternatoratleast14.87VJRNCClrStat;…ifso,skipaheadandshowyellowCALLShowGreen;...otherwiseturnonGreenLEDJPShoStatX;...andskiptoendRedStatCALLShowRed;turnonRedLEDJPShoStatX;skiptoendClrStatCALLResetStatus;turnStatusLED'soffShoStatXRET*METEROFF**ThisroutineturnsoffthethreemetermodeLED's.MeterOffSETLEDvolt,DRAbuf;turnoffDCVoltageLEDSETLEDprcnt,DRAbuf;turnoffBattery0/0LEDSETLEDalt,DRAbuf;turnoffAlternator%LEDCALLUpdatePA;updateportAfi:o迈bufferRET*DigiOff**Thisroutinesettheregisterstoturnoffthethree-digitLED.DigiOffLDIDigiDatl,DigiOffa;turnoff8of16digitalsegmentsLDIDigiDat2,DigiOffb;tumoffother8of16digitalsegmentsRET*DIGITSOFF**Thisroutineturnsoffthethree"digrtLED.DigitsOffCALLDigiOff;setregistersforallsegmentsoffCALLShowData;updatedisplayRET*DIGITSON**ThisroutinetonsONallsegmentsofthethree-digitLED.DigitsONLDIDigiDatl,DigiONa;tumON8of16digitalsegmentsLDIDigiDat2,DigiONb;turnONother8of16digitalsegmentsCALLShowData;updatedisplayRET*SHOWPERCENT**ThisroutineturnsONtheBattery%LED.ShowPerce加SETMtrUnits,Flags;setFlagsfor%(notvolts)IRRWaitOP,Flags2,SI11;skipaheadifnotwaitingftom0LDIDigiDatl,Dashes]"..otherwise,showdasheswhilewaitingLDIDigiDat2,Dashes2otherwise'showdasheswhilewaiting<formula>formulaseeoriginaldocumentpage191</formula>ShowCharging*rThisroutineturnstheChargingLEDonandtherestoff.**ShowYellow**ThisroutineturnstheGhargingLEDonanddoesnotaffecttheGheck**andChargedLEDs.ShowYellowisactuallythelastpartofShowChgngShowChgngCALLResetStatus;tonoffallStatusLEDsShowYellowRESLEDchgng,DRAbuf;turnONChargingLEDCALLUpdatePA;updateportAfrombufferRET*BLINKAlertLED**ThisroutineblinkstheAlertLEDatarateofoncepersecond.BlinkAlertLDA,MSecsl;getMSecscountCPIA,MS500;testfor1/2secJGRNCBlnkAlrt;ifso5skipaheadCALLResetLEDs;".otherwise,turnoffallLEDsJRSBumln,Flags3^BI;skipaheadifnotBum-InCALLDigitsOM;",tumonalldigitalLEDsegmentsJPBAeXit;...andexitroutineBBICALLNumData;getdatafor,andsiiowLEDnumberIPBAeXit;...andexitroutineBlnkAlrtCALLAlertON;TumonAlertLEDCALLDigitsOff;Turnoff3-digitLEDBAeXitRET承AlertLEDON**ThisroutineturnsontheAlert(red)LEDandturnstheothermeter*LEDsoff,NOTE:itdoesnotaffecttheRateandTypeLEDs.*AlertONCALLMeterOff;TurnoffMeterModeLEDsShowRedCALLRes改Status;TumoffStatusLEDsRESLEDalert,DRAbuf;TumcmAlertLEDCALLUpdatePA;updateportAfrombufferRET*ShowDoneLED**ThisroutineturnscmtheDone(green)LEDandturnsalltheother*LEDsoff.NOTE:itturnsofftheRateandTypeLEDs,*ShowDoneCALLResetLEDs;Tumo任allLEDsLDISwData,SwsOff;setType&RateLED'soffCALLShowType;showBatteryType&updatedisplayShowGreenCALLResetStatus;turnoffallthreestatusLEDsRESLEDdo加,DRAbuf;TurnonDoneLEDCALLUpdatePA;updateportAfrombufferRET*BLINKCrankLED**ThisroutineblinkstheCrankLEDatarateofoncepersecond,BlinkCrankLDA,MSecs2;getMSecscountCPIA5MS500;testfor>1/2secJRNCBlinkES;ifso,skipaheadSETLEDboost,SwData""otherwise,turnoffCrankLEDJPBCeXit;,.,andexitroutineBlinkESCALLShowCrank;turnonCrankLEDBCeXitRET*ShowCrank**ThisroutineturnstheEngineStart(Craiak/Boost)LEDonandturns:水theTypsandotherRateLEDsoff.**NOTE:The6VLEDwillbeleftonifappropriate.*ShowCrankCALLClrLEDs;turnoffdlRate&TypeLEDsJRRBat6V,Flags2,SlioES;skipaheadifnot6VRESLED6V,SwData;turaonRegular6VLEDShoESRESLEDboost,SwData;turaONCrankLEDCALLShowData;updatedisplayRET*SetSlow**ThisroutinesetsthechargerfortheSlowratebysettingtheappro-*priateflags.SetSlowRESRate,Flags;turnonSlowLEDRESRapid,Flags2;turnoffRapidLEDRET*SetSlow**ThisroutinesetstheOFFSETforthecorrect(12or6V)Slowrate.<table>tableseeoriginaldocumentpage194</column></row><table>Setl2V*Thisroutinesetsthechargerfortide12VRegularbatterytypeby**resettingthe6V,AGM/Gei,andDeepCycleflags.**SetReg**Thisroutinesets也echargerfortheRegularbatterytypebyreset-**tingtheDeepCycleandAGM/Geiflags.SetRegisactuallypartof11*Setl2V*Setl2VRESBat6V,Fags2;turnoff6VLEDSelRegRESBatTypeA,Flags;tum加RegularLEDRESBatTypeB,Fkgs;turnoffGeJ/AGMLEDRET*ShowChargeTypeLED(dependingon迈ode)**ThisroutineturnsoneithertheRegular,DeepCycle,Gel/AGM,or6V*LEDbasedonFlags.TheroutnealsosetsVmaxtomatch.*ShowTypeSETLEDreg,SwData;setRegularLEDtooffSETLEDdeep,SwData;setDe印CycleLEDtooffSETLEDgel,SwData;setGel/AGMLEDtooffSETLED6V,SwData;set6VLEDtooffJRRBat6V,Flags2,ShowTl;skipaheadifnot6VRESLED6V,SwData;tumonRegular6VLEDJPShowT2a;setVmaxforregular(15.5V)ShowTlJRRBatTypeB,Flags,ShowT2;sfcipaheadifnotGel/AGMRESLEDgel,SwData;tomonGel/AGMLEDLDIV腿,Volts144;Vmax=14.4VforGel/AGMMODEJPShoTypeXShow丁2JRSBatTypeA,Flags,ShowT3;gotoShowT3ifsetRESLEDreg,SwData;turnonRegularLEDShowT2aLDIVmax,Volts155;Vmax=15.5VforRegularMODEJPShoTypeXShowT3RESLEDdeep,SwDate;turnonDe印CycleLEDLDIVmax,Volts16;Vmax=16VforDe印CyclebatteryShoTypeXRET*HoldChargeTypeLED(dependingonmode)**ThisroutineturnsontheRegular,DeepCycle,orGel/AGMLEDbasedon'*FlagsandkeepsitonforoneFifthsecond.*HoldTypeCALLShowType;turnonBatteryTypeLEDCALLShowData;upciatedisplayCALLFiflhSecond;waitoneFifthsecondRET*HoldChargeRateLED(dependingonmode)**ThisroutineturnsontheSow,Fast,orRapidLEDbasedonFlagsand*keepsitonforoneFifthsecond.*HoldRateCALLShowRate;turnonChargeRateLEDCALLNumData;getdatafor,andshownominalrate(amps)CALLFifthSecond;waitoneFifthsecondRET*CheckHighOffset**ThisroutineisusedtocheckwhetherthelatestOFFSETisequaltothe*maximumvalue,HiOff.WhenOFFSET-HiOff,thechargerateis0.ChkffiOffLDA,OFFSET;getcurrentOFFSETIRSBat6V,Flags2,CH06;skipnextlineifnot6VmodeCPIA,HiOff-2;hasOFFSETreachedmaximum(outputoff)JPCHOxCH06CPIA,HiOff6-2;hasOFFSETreached迈axfor6V(outputoff)CHOxRET*CheckOV**Thisroutinechecksthelatestranningaverageofthebatteryvoltage:*andsetstheCanybitifit'slessthanVoks0+1DACcount.This**routineisusedtocheckwhetherabatteryisconnected.*CheckOVCheckBattSETBatt,Fiags2;setflagforconnectedbatteiy;LDAjFreshBV;testlatestaveragevoltageLDIA,Volts0+1;checkifhigherthanzeroJRRCrnkng,FIags4,ChkBat;skipnextlineifnotcrankingLDIA,l;checkfortrue0ifcrankingC腿atCPA,FreshBV;testlatestaveragevoltageJIOSICNoBatt;Ifnot>0,batterynotconnectedJPChkBattX;..,otherwise,justexitNoBattRESBatt'Flags2;setforbatterynotconnectedCALLShowRed;tumonAlert(Red)JLEDCALLClrPcnt;clearPercentandDisplayPercentCLRBADhi;clearpreviousvoltagereadingCLRFreshBV;clearpreviousvoltagereadingChkBattXRET*GetBatteryVoltage**ThisroutinegetsthebatteryvoltagestoredinBADhiandsaveditin**theaccumulator.Italsodoublestheresultifsetfor6Vbattery,*承**Double6V**Thisroutinedoublestheaccumulator,A,iftheBat6Vflagisset.This:*routineiscalledbeforetheaccumulatoriscomparedtooneofthe**constantsoriginallyassignedfor12vbatteries.*水**NOTE:IftheBat6Vflagisset'and&eaccumulatoris>8.5V,the**Hi6VHagissetinstetadofdoublingA.*GetBattLDA,BADhi;getlatest(avg)batteryvoltageDoubk6VJRRBat6V,Flags2,D6VX;skipaheadifnotsetfor6VJRRHi6V,Fl吗s3,D6V;doubieif6VBatt<8.5VLDIA,MaxVotsotherwise,setAtoMaxVolts;JRRChMode,Flags2,D6VX;checkforChargeorTestmode;CALLSetAbort;...setforAbortstateifChargemode;SETAlert,Flags2;…setAlertFlagJPD6VX;...andskiptoendofroutineD6VSLAA;doubleAD6VXRET*CheckProgress**Thisroutineisusedtoensurethatthechargerwillabortifthe**batteryvoltagedoesnotincreasethroughoutthecharge.Itchecksthe*voltageeveryCPintminutesforameasurableincreasesincethe**previouscheck.Ifthereisn't,thechargeisaborted.*ChkProgJRRMIN,TicFlagl,ChkProgX;exitifnottimetocheckforprogressChkProgOJRRSOC,SwDown,ChkProgl;skipaheadifnotStartOfChargeRESSOC,SwDown"..otherwise,clearSOCflagCALLIniTimel;initializeTimerlLDIMinsl,5;…setTimerlfor5minutesCLRLastBatt;clearLastBatt(ensurepass1sttest)JPChkProgX;…andexitChkProglLD、BADhi;getlatestbatteryreadingSUBIA,l;subtractonecountCPA,LastBatt;checkforincreaseJRCChkProgA;settoabortifnoincreaseLDA,BADhi;setAbacktoBADhiLDLastBatt,A;updateLastBattCALLIniTimel;initializeTimerl.IFCNEFastCP;assemblenextlineonlyifnotdebuggingLDIMins1,CPint;setTimerlfor60minutes.ELSE;assemblenextlineonlyifdebuggingLDIMinsl,3;setTimerlfor3mins.ENDCDECCCDcnt;updateintervalcountJRNZChkProgX;justexitifnotzeroSETHR,TioFlagl;ifzero,setfortimeexpiredChkProgACALLSetAbort;settostartAbortmodeChkProgXRET;*BatteryProgress*;*ThisroutineisusedtoensurethatChkProgandCheckBattarecalled*;*onlywhenthechargerateisabouttorampuporisn'tsettoratnpat*;*all.Thatway,batteryvoltageusedtocheckchargingprogress*;*won'tbeaffectedbythehighercurrent.BattProgworksbychecking*RmpCnttomakesureit'slessthan5.〗fthestartofchargeflag(SOC)**isset,BattProgdoesnotcheckRmpCnt.*BattiProg;JRRRmpng,Flags3,BtPrg0;skipaheadifnotRapid->Fasttransition;CALLRampOS;otherwise,graduallyreducedutycycle;BtPrgOCLRA;setAto0toensure<(9,12,or14.2V)JRSHiPwr,Flags4,BtPrgX;exitifhighpowermode;JRSSOC,SwDown,BtPrg2;skipaheadifStartOfChargeLDA,RmpCntigetRampintervalcounter;NOTE:RmpCntwiilbe0ifnotsettorampatallCPIA,5;isitalmosttimetor咖pupJRNCBtPrgX;ifnot,thenexit;BtPrg2CALLChkProg;checkforchargingprogressCALLGe氾att;getlatestvoltage&doubleif6VmodeBtPrgXRET*Check2V**Thisroutinechecksthelatestrunningaverageofthebatteryvoltage**andsetstheCarrybitifit)slessthanVoltsOl6.Thisroutineis**usedtocheckwhetherabatteryisreadyforcranking.*Check2VLDA,FreshBV;testlatestaveragevoltageCPIA,Volts016;checkifhigherthan1.6voltsRET*CHECKSWITCHES**Checkifswitchisengagedandchangemodesifappropriate.*CheckSwJRRCrankWait,Flags,ChkStart;checkswitchesifnotduringCrankwaitJPChkSwRET;don'tcheckswitchesifduringCrankwaitChkStartJRSCrank,Flags,ChekRate;don'tcheckdisplaymodeduringBoostJRRMeterSw,DRC,MeterDown;Ifswitchis"ingpressed'skipaheadRESMeterSw,SwDown;setforMeterswitchnotpressed(up)ChekRateJPChkRate;Meterswitchnotpressed,soexitCheckSwMeterDownRESIdle,Fl昭s3;setfor加tidleJRSMeterSw,SwDown'ChekRate;Ifswitchwasn'treleased,don'tcheckitSETMeterS"w,SwDo"wn;setformodeswitchpressed(dcrwn)JRRMtrScab,Flags,ChkPrcnt;ifnots改forAlt,thenskipaheadRESMtrScale,Flags;setforAlt%>sochangetoBatt%JPChkRateChkPrcntJRRMtrUnits,Flags,ChkAlt;ifsetforvolts,thenskipaheadRESMtrUnits,Flags;setforBatt0/0,sochangetovoltsJPChkRateChkAltSETMtrUnits,Hags;setforvolts,sochangeto%.IFCNEShoOff;asse迈blenextlineonlyifnotdebuggingJRSChMode,Flags2,ChkRate;don'tsetforAltifcharging.ENDCSETMtrScale,Flags;setforbatt,sochangetoaltRESWait0P,Flags2;settostopwaitingforbattery0/oChkRateCALLShoMtrMode;Meterunitsaresetbeforerate.IFCEQDEBUG;asse迈blenextlineonlyifdebugging;JRRSwOff,SwDown,Slq)Sw;skipRateandTypeswithifSwOffisset;JPChkSwRET;OtherwiseJustexitJRSSwOff,SwDown,ChkSwX;skipRateandTypeswithifSwOffisset;SkpSw,ENDCJRRRateSw,DRC,RateDown;Ifswitchisbeingpressed,skipaheadRESRateSw,S邻Down;setforRateswitchnotpressed(up)ChekTypeJPChkType;Rateswitchnotpressed,socheckTypeRateDownRESIdle,Fiags3;setfornotidleJRSRateS"W,SwDown,ChekType;Ifswitchwasn'treleased,don'tcheckitSETRateSw,Sw)3own;setforRateswitchpressed(down)ChkCM.IFCAdjOff;assemblenextlinesonlyifdebuggingJRRManual,Flags3,ManRate;debugonlyinmanualmodeINCOFFSET;increaseOFFSET(decreaseoutput)JPChkSwRET;exitCheckSwitchroutine.ENDCManRateJRRCrank,Flags,ChkSlow;ifnotsetforCrankycheckforSlowCALLTurnOff;low&highpowerandfanoff,mindutyRESChMode,Flags2;setforTester(notCharger)ModeSETDisable,DRBbuf;disableoutputifRatewasBoostJPModeChange;gotoendofCheckSwChkSlowJRSChMode,Flags2,ChkFast;skipaheadifalreadyChargermodeSETChMode,Flags2;setforCharger(nottester)ModeRESDisable,DRBbuf;enableoulputafterRateispressedRESMtrScale,Hags;setforBatt%(notAlt%)whennottesterRESRate,Flags;邻asGrank,sosetforSlowJPModeCh血ge;gotoendofCheckSwChkFast;ifsetforSlow,thensettoFastJRSRate,Fags,ChkRap;IfnotSlow,thenmustbeFastSETRate,Flags;setChargerateforFastJPModeChange;g。toendofCheckSwChkRap;ifsetforFast,thenchangetoRapid爪SRapid,Flags2,ChkES;IfnotRapid,thenmustbeFastSETRapid,Flags2;setChargerateforRapidJPModeChange;gotoendofCheckSwChkES;wassettoRapid,changetoBoostCALLSetSlow;setforSlowRateSETCrankjFlags;setChargerateforBoost;CALLSetReg;setbatterytypeforRegularCALLShowCrank;turnONCrankLEDCALXTurnOff;low&highpowerandfanoff,mindutyLDICurentSS,CrankSS;setChargestatetoCrankCALLIniTime2;resettimer2LDISecs2,003h;setTimer2for3secondsJPChkSwRETChkType;ifGel/AGM,thensetforRegularJERTypeSw,DRC,TypeDown;IfSwitchisbeingpressed,skipaheadRESTypeSw,SwDown;setforTypeswitchnotpressed(up)ChkSwXJPChkSwRET;Typeswitchnotpressed,soexitCheckSwTypeEfownRESIdle,Flags3;setfornotidleJRSTypeSw,SwDown,ChkSwX;IfSwitchwasn'treleased,don'tcheckitSETTYpeSw,SwDown;setformodeswitchpressed(down).IFCEQAdjOff;assemblenextlinesonlyifdebuggingJRRManualsFlags3,ManType;debugonlyinmanualmodeDECOFFSET;decreaseOFFSET(increaseoutput)JPChkSwRET;exitCheckSwitchroutine.ENDCManTypeJRRBat6V,Flags2,ChkBTl;Ifnotsetfor6V,checkforRegularChkBT0;ifsetfor6V,changeto12VregularRESffi6V>lags3;clear6VovervoltageflagCALLSetl2V;setforRegular,12VbatteryCALLClrPcnt;clearPercentandDisplayPercentJPTypeChange;gotoendofCheckSwChkBTl;ifsetforAGM/Gel,changeto6VJRRBatTypeB,Flags,ChkBT2;IfnotsetforGel/AGM,checkforRegularIRSHi6V,Flags3,ChkBT0;don'tsetto6Vifbatt>8.5VCALLSetReg;setbatterytypeforRegularSETBat6V,Flags2;setfor6VbatteryCALLClrPcnt;clearPercentandDisplayPercentJPTypeChange;gotoendofCheck^wChkBT2;ifRegular,thensetforDeepCycleJRSBatTypeA^lags,ChkBT3;IfnotsetforRegular,mustbeDeepCycleSETBatTypeA,Flags;setbatterytypeforDeepCycleRESBatTypeB,Flags;setbatterytypefornotAGM/GelJPTypeChange;gotoendofCheckSwChkBT3;nrnstbeDeepCycle,sosetforGel/AGMSETBatTypeB,Hags;setbatterytypeforGel/AGMRESBatTypeA,Flags;setbatteryt^efornotDeepCycleTypeChangeRESCrankjFlags;setchargeratefor加n-BoostCALLShowType;turnonBatteryTypeLEDModeChangeRESCrank^Flags;clearCrankbitofFlagsLDICurentSS,000h;restartchargingChkSwRETRET*FANON**ThisroutineturnsthecoolingfanON.FanONiscalledduringoneof*thefollowingconditions:**1.Startofcharge(endofState2)**2.Startofboost(State16)**3.IfOFFSET<HiOff-3inMaintain(State14)**4.ManualMode(State15)*".States4,5,11,12,and13*FanONLDATemp,A;saveAccumulatorLDIA,00010000b;updateAccumulatorfro迈bufferLDDRC,A;updateportfromAccumulatorLDA,ATemp;restoreAccumulatorRET,FANOff*;*Thisroutineturnsthecoolingfanoff.FanOffiscalledduringoneof*thefollowingconditions:*,*1.Beforestartofcharge(State0)*,*2.StartofAbort(State8)*,*3.BeforestartofMaintain(State14)*:*4.IfOFFSET=HiOffinMaintain(State14)*FanOffLDATemp,A;saveAccumulatorLDIA,00000000b^updateAccumulatorfrombufferLDDRC,A;updateportfromAccumulatorLDA,ATe边p;restoreAccumulatorRET;*ShutOff*;*Thisroutinesetsthechargerfornooutputbyturningofftheoutput:FJETs,turningoffthefan,settingthePWMibrminimumdutycycle;*(HiOFF),andsettingitfornon-boostmode.*:*TurnOff*;*Thisroutinesetsthechargerfornooutputbyturningofftheoutput';*FETs,turningoffthefan,andsettingPA^Mforminimu迈duty;*cycle(HiOFF).TumOffisactuallypartofShutOff.*^hutOffRESCranlqFlags;setchargerateforncm-BoostCLRRmpCnt;clearrampintervalcounterTumOffCALLFanOff;turncoolingfanoffSetOffRESPower,Flags2;turnoutputoffRESCrnkng,Plags4;indicatenotcrankingSe但iOffLDIOFFSET,HiOff;setforminimumdutycydeJRRBat6V,Flags2,SOx;skipnextlineifnot6VmodeLDIOFFSET,HiOff6;setformit6VdutycycleSOxRETTurnON*:ThisroutinesetsthechargertorunwiththeChargingLED,fan,andfoutputon,*Se護*:Thisroutinesetsthechargertorunwiththefanandoutputon*:SetONisactuallypartofTumON*TumONCALLSho邻Chgng;turnChargingLEDonSe認CALLFanON;turncoolingfanonSETPower,Flags2;tellPwrConchargerisonRET*ChargeRelay**ThisroutineswitchestherelayfromStarttoChargeifnecessary.**ChrgRlywaits200mSbeforeswitchingtherelay.Theoutputshould*beforeturnedoffbeforecallingChrgRly.*ChrgRlyJRRESriy,DRBbuf,ChgRlyX;skipaheadifrelayalreadysetforchargeCALLFi他Seccmd;wait200mSRESESriy,DRBbuf;setE/SrelayforchargeChgRlyXRET*Updatetheclocksandsetoverflowflagsasnecessary.*TicFlagl(s)bit0=hourswenttozero**TicFlagl(s)bit1-minuteswenttozero**TicFlagl(s)bit2=secondswenttozero*中TicFlagl(s)bit3=milisecondswenttozero*CLOCKSDEGMiSecsl;decrementmillisecondcounter,JRNZClksl;skiptoclock2ifMSECsoODo一MSecsLDIA,MSINIT;restartmillisecondcounterLDMSecsl,A;SETMSEC,TicFlagl;setmillisecflagDECSecsl;decrementsecondcounterDo一MinsClksl一JPCLOCKS1Do一MinsSEiSJEC/ricFlagI;setsecondexpiredflagLDISees1,Seclnit;restartsecondcounterDECMinsl;decrementminutecounterJRNZCLOCKS1;skipHRslifMINsldowntozeroDo—HrsSEJMIN,TicFlagl;setminuteexpiredflagIDIMinsl,Minlnit;restartminutecounterDECHrsl;decre迈enthourcounterIRNZCLOCKS1;checkforoverflowSETHR^TicFlagl;sethourexpiredflagCLOCKS1DECMSecs2;decrementmillisecondcounterJRZDOMSecs2ClkExitjpcLOCExrrDOMSecs2LDIA,MSINIT;restartmillise咖cicounter;LDMSecs2,A;SETMSEC,TicFlag2;setmillisecflagDECSecs2;decre迈entsecondcounterJRNZClkExit;exitifnotdowntozeroDo—Mins2SETSEC,TicFlag2;setsecondexpiredflagLDISecs2,Seclnit;restartsecondcounterDECMins2;decrementmimitecounterJRNZCLOCEXIT;ecitifnotdowntozeroDo—Hrs2S^i1MIN,TicFlag2;setminuteexpiredflagLDIMins2,Minlnit;restartminutecounterDECHrs2;decrementhourcounterJRNZCLOCEXIT;checkforoverflowSETHR,TicFlag2;sethourexpiredflagCLOCEXITRETINITIALIZETIMER1*SubroutinetoinitializetimerlIniTimelLDIMSecsl,MSINITLDISecsl,SecInitLDIMinsl,MinInit<formula>formulaseeoriginaldocumentpage204</formula>ATimes5LDATemp,A;ATe迈p-AADDA,A;A=A+A=A*2ADDA,A;A=A+A=ATemp*4ADDA,ATemp;A=A+ATemp=ATemp*5RET;*CURRENTREGULATION*;*ThisroutinereducestheoutputcurrentbyincreasingtheOFFSET*;*valuewhenthevoltageisbelow14.2volts(thruSS5).Anoffsetinto*:*anLUTisdeterminedbasedonthebatteryvoltage.Thevalueisloaded**intoOFFSETwhichisusedtocontrolstheofftimeoftheSCR's.*IR邻LDA,BADhi;getvoltage;LDA,FreshBV;getvoltageJRSBat6V,Flags2,IR—6V;skipaheadif6VmodeIRSRate,Flags,PH一l;skipaheadif15ampmodeLDIDRWR,OflEAd]slo.w;lookuptablefor12V2ampLDIX,OffAdjSlo.d;initializelookuptableLDIT加pOff,OHLowSlo;highest2Aoffset-lowestcurrentSUBIA^atLoSlo;submininum12V2amptableentry(10V)JKNCP—A14;d咖P—A15li)ATempOffJPP—A12P—A14li>ITempOff,O舰Slo;lowest12V2Aoffset-highestcurrentCPIA,040h;lasttableentry-highestindexJRNCP一A15;doneJPPH一2一;donewith12V2ampPH—1一JRSRapid,Flags2,IR—rap;skipaheadifRapidrateIR一1一L5lDRWR^OffAdjFst,w;lookuptablefor12V15ampLDIX,OffAdjFst.d;initializelookuptableLDITempOff'OffLowFst;highest15Aoffset-lowestcurrentSUBIA,BatLoFst;subrainin咖15amptableentryJKNCP—A17;doneP—A16P—A15P一Al7£blTempOff,O細Fst;l鬆st12V15Aoffset-highestcurrentCPIA'040h;lasttableentry-highestindexJRNCP一A16;doneJPPH一2一;donewith12V15ampIR一rap一J^kHiPwr,Flags4,IR一l;use12V15AtableiflowpowermodeLDIDRWRPfEAdjR:p.w;lookuptablefor60咖pLDIX,OffAdjRap.d;initializelookuptableLDITempQff,OfELowRap;highest60Aoffset-lowestcurrentSUBIA,BatLoRap;submininum60咖ptableentiyIRNCIR一ip2;doneIR一rpI一IPP—A15IR一ip5U5lTempOff,O甜iRap;lowest60Aoffset-highestcurrentCPIA,040h;lasttableentry-highestindexJRNCIRjpl;do加PH—2_Al^IA,03Fh;limitto64bytewindowADDA,X;addtablebaseaddressLDX,A;LDA,(X);getvaluefromtableJPP一Al5;skipaheadandupdateoffetvalueIR一6VJRSRate,Flags,IR6一3;skipaheadif15ampmodeLDIDRWR,OfAd6"ilo.w;lookuptablefor6V2ampLDIX,OfAd6Slo.d;initializelookuptableLDITe迈pOff'Off6LoSJo;highest2Aoffset-lowestcurrentSUBIA,Bat6L0Sl0;submininum6V2amptableentry(5V)JRNCIR6一2;doneIR6—1LDA,TempOffJPP—A12IR6一5LDlTe迈pOff,Off6HiSl0;lcwest6V2Aoffset-highestcurrentCPIA,020h;lasttableentry-highestindexJRNCER6一1;doneJPIR6一10一;donewith6V2ampIR6一3一JR§"Rapid,Flags2,IR6—7;skipaheadifRapidrateIR6—4一LD亍DRWR^OfAd6Fst.w;lookuptablefor6V15ampLDIX,OfAd6Fst.d;initializelookuptableLDITempOff'Off6LoFst;highest15Aoffset-lowestcurrentSUBI入Bat6LoFst;submininum6V15amptableentryJRNCIR6_6;do加IR6一5一JP"k6一lIR66LD亍TempOff,Off6HiFst;lowest6V15Aoffset-highestcurrentCPIA,020h;lasttableentry-highestindexJRNCIR6一5;do加JPIR6—10;donewith6V15咖pIR6—7—JRJRHiPwr,Flags4,IR6—4;use6V15AtableiflowpowermodeLDIDRWR,OfAd6Rap.w;lookuptablefor60ampLDIX,OfAd6Rap.d;initializelookuptableLDITempOff,Of伤LoRap;highest6V60Aoffset-lowestcuirentSUBIA,6at6LoRap;submininum6V60amptableentry厕CIR6—9;doneIR6_8—JPlR6一lIR6一9LDlTempOff,Off6HiRap;lowest6V60Aoffset-highestcurrentCPIA,020h;lasttableentry-highestindexJRNCIR6—8;doneIR6_10一Ab5)IA,01Fh;limitto32bytewindowADDA^X;addtablebaseaddressLDX,A;LDA,(X);getvaluefromtableP—A12;XDDA,FUDGE;debugfodgefactorLDOFFSET,A;savenewoffsetvalueP—A13远T*VOLTAGEREGULATION**ThissubroutinewilladjustthevalueofOFFSEToncepersecondto**controlthecurrentandmaintainthevoltagedeterminedbyMaintVolt.:Vo股eg;LDA,MSecs2;MSec2=MSInitoncepersecond;CPIA,MSINIT;IsMSEChMSINIT;JRZVReg一0;Yes:thentimetoadjust;VReg一X一;JPVReg一3;No:thennottimetoadjust;VReg—0;adjustoffsetDECVRcnt;decrementintervalcounterJRZVReg一0;Yes:thentimetoadjustJPVoltRegX;No:then加ttimetoadjustVReg一0;adjustoffsetLDIVRcnt,MSINIT;re-initializeinitervalcounter(1sec)LDA,FreshBV;getbatteryvoltageCALLDouble6V;doubleBatteryvoltageifsetfor6VDECACPAMakitVolt;comparewithsetvalue+1JKNCVReg_6;greaterthan,increaseOFFSETJPVReg—1;notgreaterthan,testiflessthanVReg_6一LDA,OFFSET;greaterthan,getphasedelayvalueINCA;JRSBat6V,Flags2,VReg—2CPIA'HiOff;testifathighlimitJPVReg一5VRsg一2CPlX卿筋VReg一5则6"VReg一3;atthelimit,don'tchangeOFFSETVReg_4一LDolTSET,A;updateOFFSETVReg一3JPVoltRegX;doneforthispassVReg—1INCXCPA,MaintVolt;co迈parewithsetvalueJUNCVoltRegX;notlessth叫justexitLDA,OFFSET;lessthan,getphasedelayvalueDECA;CPA,LowOff;testifatlowlimitJRNCVReg—4;notatthelimit,updateOFFSETVo欣egXRET*TIMERINTERRUPTHANDLER**ThisroutineturnstheSCRsonifthepowerflagsarenon-zeroand*承inhibitsthetimer,PwrConLDATemp,A;saveAregisterJRSPower,FJags2,PCon;diargeron,turnonSCRsJPPWREXIT;notchargingj'ustexitPConSETSCRs,DRBbuf;tonontheSCRs(inbuffer)CALLUpdatePB;updateportBfrombufferPWREXTT;LDITSC民015h;MiibittimerCALLRstWDR;resetwatchdogtimerLDIA^FULUTME;TCRisreloadedherefor1McycleLDTC&A;LDITSCR,05dh;rekmdprescalerandstarttimerJRRCrokng,F3ags4,PC—NonnPC—CrankCALLCLOCKS;updateclocksRES蘭lnt,Flags2;tellExitMainthiswasNMIinteruptJPPCexit;leaveSCRsonduringCrank;turnoffSCRdrivesothatonlyapulseisgenerated(SCR'slatchon)PC—NonnS^TMMInt,Flags2;teilBxitMainthiswastimerinteruptLDIA,2Ah;ddayforwidthofONpulsePC—dlyDECA;decrementAuntildelayhasexpiredJRNZPC—dly;delayliasexpiredwhenAisdownto0RESSCE^,DRBbuf;tumoffSCR's(inbuffer)CALLUpdatePB;updateportBfrombufferPCexitLDA,ATemp;restoreAregisterRETINON-MASKABLEINTERRUPTHANDLER**ThisistheNMIinterruptroutine.TheNMIisgeneratedonthefalling刮*edgeofthefoilwaverectifiedAClinevoltage.Aninterruptis**generated120timesp访second,onceevery8.333ms,AftereachNMI,*thisroutineperformsthefollowingsteps.**1.Resetthewatchdogtimerandsavetheregisters.**2.TurnofftheSCRs(unlessduringCrankONstate),**3,SettheinterrupttimeraccordingtoOFFSET.**4.ResetNMIntsoExitMainknowsit'sanNMI(nottimerint).*承5,Updatetheclocks,承*6.Restoretheregisters.**Ifturnedoff,theSCRswillremaino任foraperioddeterminedby**OFFSET,TheTimerwiilthentriggeraninterruptwhichtellsPwrCcm*toturntheSCRsbackonifnecessary.*IT一T臓RCALLRstWDR;resetwatchdogtimerLDATemp,A;saveAregisterLDA,X;getXregisterLDXTEMP,A;saveXregisterJ]RSCrnJkng,Fkgs4,IT一XLDA,OFFSET;getci^entoffsetLDTCR,A;loaiithecounterwithcurrentoffsetLDITSCR,01011101b;reloadprescaler(32〉andstarttimerRESSCRs,DRBbuf;turnoffSCR's(inbuffer)CALLUpdatePB;updateportBfrombufferIT一TMRrSs画lnt,Fkgs2;tellExitMainthiswas丽IinteruptCALLCLOCKS;updateclocksnop;LDIX,2Ah;delayfortruezerocrossLDIX,03h;delayfortruezerocrossIT一TJKNZIT一TNOP;adjustzerocrossdelayIT—XL5A,XTEMP;restoreregistersLDX,ALD人ATempRETI*A/DINTERRUPTHANDLER**ThisistheAtoDinterruptserviceroutine.Theonlythingitdoesis'*cleartheinterruptbitandwakestheprocessorupfromitswaitmode.ADINTRES7'ADCRLDA,ADRRETI*ROMDATAWINDOWforTHIRDVOLTSLEDDIGIT**Thefollowingbitpatternsareusedtodisplaytheindicatednumbersas*thethird(leastsignificant)digitofthevoltagedisplay..block16-$%16DigitsOVx;patternsforDigiDatl-Digit1(LSD)&decimalpoint.byteOOOlOOlOb;display一0for00h.byte01111110b;dispiay二lforOlh.byte01111110b;display一lfor02h.byte00110001b;displayfor03h.byte00111000b;display二3for04h.byte00111000b;display二3for05h.byte01011IOOb;display—4for06h.byte1001IOOOb;display=5for07h.byte10011000b;display—5for08h,byte10010000b;display—6for09h.byte00111110b;display—7forOAh.byte00111110b;display_J7forOBh.byteOOOlOOOOb;cKsplay—8forOCh.byte00011000b(display—9forODh.byte00011000b;displayforOEb;*ROMDATAWINDOWforTHIRDLEDDIGIT*;*Thefollowingbitpatternsareusedtodisplaytheindicatednumbersas*;*thethird(leastsignificant)digitonthel6d,*:blockl6-$%16DigitsOOx;patternsforDigiDat〗-Digit1(LSD)&decimalpoint;segmentbaQ)edgc,byteOOOlOOlOb;bitpatterntodisplay一0byte0111111Ob;bitpatterntodisplay—1,byte00110001b;bitpatterntodisplay_J2.byte00111000b;bitpatteratodisplay_^byte01011100b;bitpatterntodisplay__4.byte10011000b;bitpatterntodisplay—5,byte10010000b;bitpatterntodisplay—6.byte00111110b;bitpatterntodisplay=7,byteOOOlOOOOb;bitpatterntodisplay一8.byte00011000b;bitpatterntodisplay^9;*ROMDATAWINDOWforSECONDLEDDIGIT*;*Thefollowingbitpatternsareusedtodisplaylheindicatednumbersas:;*thesecond(middlesignificant)digitontheLED.:blockI6-$%I6Digits0x0;patternsforDigiDat2-Digit2(middledigit)andMS1.byteOOOOOIOlb;bitpatterntodisplay—0_.byte1100111lb;bitpatterntodisplay—1—,byte00100011b;bitpatterntodisplay—2—,byte10000011b;bitpatterntodisplay—3—,byte11001001b;bitpatterntodisplay—4一byte10010001b加tpatterntodisplay—5—,byte00010001b力itpatteratodisplay丄.byte11000111b;bitpatteratodisplay=7二byte00000001b;bitpatterntodisplay—8—,byte1000000lb;bitpatterntodisplay—9二*ROMDATAWINDOWforAlternatorChargeinPercent*:*ThefollowingvaluesarethePercentvaluesforthealternatorvoltages;*listedbelow.Thesenumbersareonlyusedwhenthechargerisin*;*Testermode.Voltageslowerthanthefirstentryaredisplayedas0%;*charged.Voltagesabovethelastentryaredisplayedas199%charged.:blook32-$%32MLvls;%VoltsHex.byte0;13.53CBred.byte12;13.60CC|,byte25;13.67CD|.byte38;13.73CEred.byte50;13.80CFyellow.byte62;13.87DO|.byte75;13.93Dlyellow.byte85;14.00D2green.byte92;14.07D31.byte97;14.13D4i.byte100;14.20D5|.byte100;14.27D6|.byte100;14.33D7j.byte100;14.40D8j.byte100;14.47D9j.byte100;14.53DA|.byte100;14.60DB|.byte103;14.67DC|.byte110;4.73DD|byte120j14.80DEgreen.byte130;14.87DFyellow.byte140;14.93EO|.byte150;15.00Elyellow.byte160;15.07E2red.byte170;15.13E3|.byte180;15.20E4|bytel卯;15.27E5j.byte196;15.33E6red■byte199;15.40E7red;*ROMDATAWINDOWFORSlow迈ode*;*Thesearetheoffsetstocontrolthecurrentoutput.*:block64-$%64Of阔SIo;OffsetBADhi;DecHexIndexVoltsHexDec.byte130;82010.0096150.byte129;81110.0797151byte129;81210.1398152.byte129;81310.2099153.byte129;81410.279A154.byte129;81510.339B155.byte129;81610.409C156.byte128;80710.479D157.byte128;80810.539E158.byte128;80910,609F159.byte128.byte128.byte127,byte127.byte127.byte127,byte127.byte127.byte126.byte126.byte126.byte126.byte126.byte125.byte125.byte125.byte125.byte124.byte124.byte124.byte124.byte124.byte123.byte123.byte123.byte123.byte123.byte122.byte122.byte122.byte122.byte122.byte122.byte121.byte121.byte121.byte121.byte120.byte120,byte120,byte120.byte120.byte119.byte119.byte119.byte119.byte119.byte118.byte118byte118/bytel18.byte117.byteU7.byte11680船0.(57A0160801110.73Al1617F1210.80A21627F1310.87A3163,7F1410.93A4164,7F1511.00A51657F1611.07A6说:7F1711.13A7167,7E1811.20A8168:7E19U.27A9169:7E201U3AA〗70.7E2111.40AB1717E2211.47AC172:7D2311.53AD1737D2411.60AE174:7D2511.67AF175,7D2611.73BO1767C2711.80Bl177:7C2811.87B2178,7C2911.93B3179,7C3012.00B41807C3112.07B5817B3212.13B6182,7B3312.20B71837B3412.27B8184■7B3512.33B91857B3612,40BA186:7A3712.47BB187,7A3812.53BC1887A3912,60BD1897A4012.67BE1907A4112.73BF1917A4212.80CO192794312.87Cl193,794412.93C2194794513.00C3195794613.07C4196784713.13C5197784813.20C6198,784913.27C7199■785013.33C8200785113.40C9201775213.47CA202775313.53CB203775413.60CC204,775513.67CD205,775613.73CE206■765713.80CF207765813.87DO208765913.93D1209766014.00D2210756114.07D3211756214.13D4212746314.20D5213*ROMDATAWINDOWFOJRFast咖de**Thesearetheoffsetstocontrolthecurrentoutput.;.block64-$%64OffAdjFst;OffsetBADhi;DecHexIndexVolteHexDec,bytel03;67010.0096150.byte103;67110,0797151.byte103;67210.1398152.byte103;67310.2099153.byte103;67410.279A154.byte103;67510.339B155.byte103;67610.409C156.byte103;67710.479D157.byte103;67810.539E158.byte103;67910.609F159.byte103;67100.67AO160byte103;671110.73Al161.byte103;671210.80A2162.byte102;661310.87A3163.byte102;661410.93A4164byte102;661511.00A5165byte102;66161L07A6166byte102;661711.13A7167.byte102;661811.20A8168.byte102;661911.27A9169.byte102;662011.33AA170.byte101;652111.40AB171.byte101;652211.47AC172.byte101;652311.53AD173byte101;652411.60AE174.byte9S;622511.67AF175.byte98;622611.73B0176.byte98;6227IU0BI177.byte97;612811.87B2178.byte97;612911.93B3179.byte97;613012.00B4180.byte96;603112.07B5181.byte96;603212.13B6182.byte96;603312.20B7183.byte96;603412.27B8184.byte95;5F3512.33B9185.byte95;5F3612.40BA186.byte95;5F3712,47BB187.byte94;5E3S12.53BC188.byte94;5E3912.60BD189.byte94;5E4012.67BE190.byte93;5D4112.73BF191,byte93;5D4212.80CO192.byte93;5D4312.87CI193,byte93;5D44〗2.93C2194.byte93;5D4513,00C3195:5C4613.07C41965C4713.13C5197:5C4813.20C6柳5B49〗3.27C71995B5013.33C8200'5B5113.40C920]5A5213.47CA202:5A5313.53CB203'5A5413.60CC204595513,67CD205595613,73CE206,595713,80CF207■595813.87DO208585913,93Dl20958船楊D2210586114.07D3211586214.13D421257(53*ROMDATAWINDOWFORRapidmode**Thesearetheoffsetstocontrolthecurrentoutput;.block64-$%64OffAdjRap;OffsetBADhi;DecHexIndexVoltsHexDec.byte74.byte74.byte74byte73.byte73byte73,byte73,byte73.byte73byte73.byte73.byte72.byte72.byte71.byte71byte71.byte71.byte70byte70.byte70.byte70.byte70.byte69.byte69.byte69.byte68.byte68:4A09.0087135;4A19.0788136;4A29.1389137;4939.208A138;4949.278B139,4959.338C140:4969.408DMl:4979.478E142;4989.538F143:4999.6090144,49109.6791145,48119.7392146;48129,8093147,47139.8794148,47149.9395149:471510.0096150;471610.0797151;461710.1398152461810.2099153,461910.279A154,462010.339B155462110.409C156,452210,479D157,452310.539E158452410.609F159;442510.67AO160442610.73Al161b,b_b.b,b,b.b.力bbbbbbbbb.byte68.byte67.byte67byte67.byte67.byte66.byte66.byte66.byte65.byte64.byt"3.byte62.byte61.byte60.byte59.byte58.byte57.byte56.byte55.byte53.byte52.byte50.byte48.byte47.byte46.byte45.byte44.byte42.byte41.byte40byte39.byte37.byte36.byte34.byte33.byte31.byte304427■4328;4329■4330;4331,4232;42334234413540363F37犯38:3D393C403B4■3A4239433844:3745:35463447:32483049,2F502E51:2D52:2C53,2A542955:285627572558:2459:22602161IF62IE6310.80A2—f10.87A316310.93A416411.00A516511.07A61661U3A716711.20A816811.27A916911.33M17011.40AB17111.47AC172H.53AD17311.60AE17411.67AF17511.73BO7611.80Bl17711.87B217811.93B317912.00B418012.07B518112.13B618212.20B718312.27B818412.33B918512.40BA18612.47BB18712.53BC18812.60BD18912,67BE19012.73BF19112.80CO19212.87CI19312.93C219413.00C319513.07C419613.13C519713.20C6198;*ROMDATAWINDOWFOR6V2amp咖de;*Thesearetheoffsetstocontrolthecurrentoutput.;.block32-$%32OfAd6Sl。;OffsetVolts;DecHexIndexDecHex.byte137;8905.004B.byte137;8915.074C.byte137;8925.134D.byte137;S935.204E.byte137;8945.274F.byte137;8955.3350.byte137;8965.4051.byte137;8975.4752.byte137;8985.5353.byte137.byte137.byte137byte137.byte137.byte137.byte137.byte137.byte137.byte137.byte137.byte137.byte137.byte137.byte137.byte137.byte137.byte37.byte137.byte137.byte137.byte137.byte13795-6054105.6755115.7356125.8057135.8758W5.9359156.005A166.075B176.135C186.205D196.275E206.335F216.406089226.476]89236.536289246.606389'256.676489266.736589276.806689286.876789296.936889307.006989317.076A89898989898989898989898989ROMDATAWINDOWFOR6V15ampmodeThesearetheoffsetstocontrolthecurrentoutput.;.block32-$%32OfAd6Fst;O飽etBADhi;DecHexIndexVoltsHexDec.byte107邻05.004B75.byte107邻15.074C76.byte107邻25.134D77.byte.107邻35.204E78.byte107;6B45.274F79,byte107邻55.335080.byte107邻65.405181.byte107邻75.475282.byte107邻85.535383.byte107;6B95.605484.byte107;6B105.675585.byte107邻115.735686.byte107邻125.805787.byte107邻135.875888.byte107邻145.935989.byte107邻156.005A卯.byte107;6B166.075B91.byte107邻176.135C92.byte107;6B186.205D93byte107;6B196.275E94.byte107邻206.335F95.byte107邻216.406096.byte107;6B226.476197.byte107.byte107.byte107byte107.byte107.byte107.byte107.byte107.byte106邻236.53邻246.60邻256.67;6B266.73;6B276.80;6B286.87;6B296,93;6B307,00;6A317,07629863996410065101661026710368104691056A106;*ROMDATAWINDOWFORW60ampmode;*Thesearetheoffsetstocontrolthecurrentoutput.;.bk>ck32-$%32apBADbiIndexVoltsHexDec5205.004B755215.074C765225.134D775235.204E785145.274F795155.3350805165.4051815175.4752825085.53.53835095.60548450l'O5.67558550115.7356864F125.8057874F135.8758884F145.9359894F156,005A卯4F166.075B914F176.135C924F186.205D934F196.275E944E206.335F954E216.4060964E226.4761974E236.5362984E246.6063994E256.67641004E266.73651014E276.80661024E286.87671034E296.93681044E307.00691054D3f7.076A106<image>imageseeoriginaldocumentpage217</image>.org0EP0hADC3pADINTTIMERJPPwrConint2nopretiINTlNOPRETI■orgOFFChNMIjpit—timerrstJPRESET.END----------------------------------------------------------------------------------------------7W24D.asm;Checksum;Ra邻Code:71808;WithInfo:6FF42;*COPYRIGHT2004SCHUMACHERELECTRIC*;*ALLRIGHTSRESERVED*;*DigitalDieHard712242/15/50/125ACharger/Starter/Tester*;*ThiscodeisfortheSGS-THOMPSONmicTO-coiitrolar*;*PartnumberST62T25/ST62E25*title"DigitalDieHard71224ChargerVer.CU9".LINESIZE131.vers"ST6225".romsize4.w—onDE5UG.SET0;1->normal,0->IgnoreTypeandRateswitchesafterss5ShoOff.SET0;1->normal,0->ShowOFFSETinAlt%modeduringchargingFastCP.SET1;1->normal,0->3minChkProgintervalinsteadof60minShoADC.SET1;1->normal,0->Use3PB2toindicateA/DactivityLongTst.SET1;1->nonnal,0->Setm咖al咖defor255(not1)hoursAdjOff.SET1;1->normal,0->AllowmanualadjustmentofOFFSET(SSI5)Definetheporthardwarelocations*Attimes,the.defstatementisfollowedbyavalueand"!m",The!m**isusedbythesimulator/emulatorfordebugging.Thissymboltellsthe**equipmentwhatregisterstheuserwantstomonitorduringdebuging.*X.def80h!mY,def81hV,def82hW,def83h;Indexregister;Indexregister;Shortdirectregister;ShortdirectregisterAtdefOffh!m;AccumulatorDRA*defOcOh!mDRB,defOclh!mDRC,def0c2h;Portadataregister;Portbdataregister;PortcdataregisterDDRA.defOc处DDRB'def0c5hDDRC.def0c6h;Portadirectionregister;Portbdirectionregister;PortcdirectionregisterORA,defOcgIiORB.defOcdhORC.defOceh;Portaoptionregister;Portboptionregister;PortcoptionregisterADR.defOdOh!mADCR,defOdlhjA/Ddataregister-;A/DcontrolregisterPSC,defO咖TCR.def0d3h!mTSCR,defO她;Timerprescalerregister;Timercounterregister;TimerstatuscontrolregisteWDR,def0d8h;WatchdogregisterIOR,def0c81i!mDRWR.def0c9h;Interruptoptionregister;DataromwindowregisterJDRAbuf,def0她;sliadowramforportAdataregisterDRBbuf,def085h;shadow憩iforportBdataregisterDRCbuf.def086h;shadowramforportCdataregisterATemp.def087h;Accumu〗atortemporarystorageXTEMP.def088h;XregistertemporarystorageMSecsl.def089h;storageforS.333咖tics-countof〗20-1secSecsl.def08Ah;storagefortimerlsecondsMinsl.def08Bh(storagefortimerlminutesHrsl,def08Ch;storagefortimerlhoursTicFlagl.def08Dh;overflowflagsforSecsl,Minsl,andhoursMSecs2.def08Eh^millisecondonecounterSecs2,def08Fh;storagefortimer2secondsMins2.def090h;storagefortimer2minutesHrs2.def09lh;storageforthner2hoursTicFlag2.def092h;overflowflagsforSecsl,Mins2》andhourslTries.def093ii;鹏dbybatterydetectroutinesTEMP.def094h;scratchpadareaTEMPI.def095h;scratchpadareaT加p2.def096h;countusedforFreshBVCurV"olt.def097h;currentbatteryvoltageMaintVolt.def098h;storageforMAINTAINvoltagelevelOldVolt.def099h;previousbatteryvoltage,usedfordv/dtCCDcnt.def09Ah;displaycountdownduringcrankcooldownOldOff.def09Bh;oldvalueofOFFSETusedindl/dtBADlo.def09Ch;lowbitsbatteryvoltageaverageBADhi.def09Dh;hibitsbatteryvoltageaverageVmax.def09Eh;maximumbatteryvoltage(perBatteryType)Vref.def09Fh;refvoltagefordesufationOFFSET.def0A0h;storageforphasedelayvalueFreshBV.def0Alh;avgbattvoltusedfordi/dtrefFBVTotLo.def0A2h;lowbyteoftotalusedforFreshBVFBVTotHi.defQA3h;highbyteoftotal加edforFresKBVQirentSS.def0A4h;storescurrentchargerstateHags.def0A5h;chargerconfigurationstates;bit0(BatTypeA):0forReg,1forD/C;bit1(BatTypeB、0forNorm,1forAGM/GEL;bit2(Rate):0forS!ow,1forFast;bit3〖Cracic):1ifinBoostmode;bit4^CrankWait):1duringE/Scooldown;bit5(Started):1ifchargingstarted;bit6(MtrUnits):0forVolts,1for%;bit7(MtrScale)0forBatt,1forAltFlags2.def0A6h;storesthefollowingHags;5it0(Batt):1ifbatteryconnected;bit1(Rapid):IifsetforRapidchargerate;bit2(Bat6V):1ifsetfor6Vbattery;bit3(Powerj:1ifoutputison;bit4(NMInt):1ifNMIinterrupt0ifTimer;bit5(ChMode):1ifinChargerMode;bit6(WaitOP):1ifwaitingfor%tochangefrom0;bit7(Alert):1indicatesAlertconditionFlags3,def0A7h;storesthefollowingFlags;bit0(Rmplnt):1during1sthalfofeachRampinterval;bit1(Settle):1duringvoltagesettletime;bit2(HiEnd):1ifhighervoltageforEndCharge;bit3(Idle):1untilabuttonispressed;bit4(Hi6V):1ifbatteiy>8,5V;bit5(NxtCnt):1->1stsecondofcount;bit6(Manual):1ifinManualMode;bit7(Buniln):1ifinBurn-inModeSwDown.def0A8h;Indicatesstateofswitches(1->pressed);bit4=SwOffflag(debugging);bit5=Typeswitch;bit6=Rateswitch;bit7s2MeterswitcliDigiDat2、def0A9h;datafor8of16segmentsofdigitalLED(0->ON,l->ofi);bit0-digit3segmentsB&C;bit1-digit2segmentF;bit2=digit2segmentG;bit3digit2segmentA;bit4=digit2segmentB;bit5=digit2segtaetvtC;b"6=digit2segmentD;bit7=digit2segmentEDigiDatl.defOAAh;datafor8of16segmentsofdigitalLED(0->ON,I->off);Wt0=digit1segmentC;Wt1==digit1segmentG;bit2=digit1segmentD;bit3-digit1segmentE;bit4=digit2decimalpoint;bit5-digit1segmentF;bit6-digit1segmentA;Wt7=digit1segmentBSwData.defOABh;dataforthe3Rateand3TypeLEDs(0->ON,l->o坊;bit0-6VbatterytypeLED;bit1==RegbatterytypeLED;bit2-D/CbatterytypeLED;bit3=AGMbatterytypeLED;bit4=chargerateLED;bit5-15AchargerateLED;bit6-300AchargerateLED;bit7=2AchargerateLEDBitCnt,defOACh;indexofbitsenttodisplayBytCnt.defOADh;IudexofwordsenttodisplayDataBuf.defOAEh;TempstorageforDatabitsVttCnt.defOAFli;Counterforvoltagedisplayintent!TempOff,defOBOh;tempoffsetvalueRmpCnt.def0Blh;countsrampintervalsuntilnextra呵LEf)num.def0B2h;storesnumbertobeshownondigitalLEDPercent.def0B3h;storespercenttobeshownondigitalLEDIndex.def0B4h;usedforlookuptableaccessLowO任.def0B5h;minoffsetvaluefordi/dt(highestcurrent)VRcnt,def0B6h;Coun化rforvoltageregulationintervalPcntL.def0B7ii;NMIcounterforpercentdisplayupdatePcntH力ef0B8h;IntervalcounterforpercentdisplayupdateDspPcnt.def0B9h;storageforlastpercentdisplayedFlags4.defOBAh;storesthefollowingFlags;bit0(IdleSet):1if10minuteIdietimerwasstarted;bit1(NoR咖p):1duringMammiFastcharge;bit2(SOC):1ifatstartofcharge(1st5s);bit3^Cmkng):1ifcranking(State19);bit4(HiPwr):1ifchargerate>Fast;bit6(Restore):1ifindesulfationmode(SS9)乙astBatt,defQBBh;storesbatteryreadingusedtomonitorprogress;fi:ee,def0BCii;freeORBbuf.def0BDh;shadowRAMforORBregister;free.defOBBh;free;free,defOBFh;free;0BFh=lastRAMlocation;*Theseare也econstantsusedbythebatterycharger.*Volts005.equ008h;0.5VOLTSVolts0.equOOAh;0.7VOLTSVoltsOl.equOOFh;1.0VOLTSVolts016.equ017h;miminumvoltageforenginestart,I.5VVolts02.equ01Eh;2.0VOLTSVo脇.equ04Bh;5.0VOLTSVote06,equ05Ah;6.0VOLTSVolts066,equ061h;6.6VOLTSVolts075.equ071h;7.5VOLTSVolts09.equ087h;verydischargedbatteryvoltageVoltslO,equ096h;10,0VOLTSBattMin.equ0AFh',lo邻estvalueinBattery%LUTVoUsl2,equ0B4h;bwbatteryvoltageVo諸2.equOB7hVo諸5.equOBClxBattMax.equ0BDh;highestvalueinBattery%LUTVoltsl27.equOBEhVoltsl28.equ0C0h;goodbatterytestvoltageVottsl3.equ0C3hVoItsl32.equOC6hVoltsl35.equOCAhAltMin,equ0CBh;lowstvalueinAlternator%LUTVoitsD8.equOCFhVoltsl4.equOD2hVoItsl42.equ0D5h;startmonitoringdv/dtvoltageVoltsl435.equ0D7hVoltsl44.equ0D8hVoltsl46.equODAh;maximumallowedvoltageforreg/gelmodeVoltsl47.equ0DQi;starttrickletimervoltageVoltsH9,equ03B0h;14,87VVoltsl5.equOElh;maximumallowedvoltageforRV/DCMarineVoltsl5a.equOE2h;15.07VAltMax.equ0E7h;highestvalueinAlternator%LUTVoltsl55.equ0E9h;maximumallowedvoltageforAuto/MarineStartingVoltsl6.equOFOh;maximumallowedvoltageVoltsl65.equ<JF7h;服ximumallowedvoltagefordeepcycle2Voltsl7.equ0FCh;maximumallowedvoltageMaxVoits.equ0FFh;maximumvoltagereading、17.0VRCinitR,equ〗05;rampcountintervalsforRapidrateRCinitF,equ180;rampcountintervalsforFastrateRIinit.equ60;NMIinterruptsper1/2r咖pcountintervalMSINIT.equ078h;millisecondinitializationvahie(120)MS500,equ03Ch;milliseGondcountervaluefor500mS(60)MS200.equ018h;milHsecondcountervaluefor200mS(24)SecLiit,equ03Ch;secondinitiafeationvalue(60)Minlnit,equ03Ch;mimiteinitializationvalue(60)MaxHrs.equ25;maximumallowedchargehours+1CPint.equ60;mimitesperchargeprogressintervalHR.equ000h;hoursbitofTicFlaglandTicFlag2MIN.equ00lh;minutesbitofTicFlaglandTicFlag2SEC.equ002h;secondsbitofTicFlaglandTicFlag2MSEC.equ0咖;millise咖dsVLO.equ0C0h;kwlinelimit-100VACVffl.equOEBh;highlinevoltageimit-130VACBatLoSlo.equ096h;lowbatteryvoltagecurrentadjust-10.0VdcBatLoFst.equ096h;lowbatteryvotagecurrentadjust-IO,OVdcBatLoRap.equ096h;lowbatteryvoltagecurrentadjust-10,0VdcBat6LoSio.equ(MBh;lowbatteryvoltagecurrentadjust-5.0VdcBat6LoFst.equ043h;lowbatteryvoltagecurrentadjust-4,5VdcBat6LoRap.equ043h;〗owbatteryvoltagecurrenta^/ust-4,5Vdc;Ba沮iSlo.equOD5h;BatffiFst.equ0C6hPCint,equ06M;numberof1-secondintervalsbetween%updatesFULLTIME.equ0ADh;halfsecondwhejiACpowerisOFFSlowAmps.equ2;NominalampsoutatSlowrateFastAmps.equ15;NominalampsoutatFastrateRapAmps.equ40;NominalampsoutatRapidrateCrnkAmps.equ100;Nominalampsoutat亡rankrateCodeRev.equ0;softwarerevisionlevelOfELowSlo.equl32;Lowestcurrentin12V2AoffsettableO倒ow.equ126;Nominaloffsetforslowcharge(20%)O舰Slo,equ119;Cuirentin12V2Aoffsettablefor14.0VMinOffSlo,117;MaxCurrentfor12V2Arateduringdi/dtOfELowFst,equ107;LowestcurrentinIZVFastoffsettableOffFast,equ107;Nominaloffsetforfastc;harge(15A)OfBHiFst.equ99;Highestcuirentin12VFastoffsettableMinOfFst.equ88;MaxCurrentfor12VFastrateduringdi/dtOffRamp.equ76;offsetforFastoRapidtransitionOffRap.叫u80;Nominaloffsetforrapidcharge(-90%)OffLowRap.equ80;Lcvwestcurrentin12VrapidoffeettableOfiHiRap.equ30;Highestcurrentia12VrapidoffsettableOfPCrank.equ95;OFFSETforCrankstandbyOfF6LoSlo.equ135;Firstentryin6V2Ao怨ettableOff6Sk).equi36;Nominaloffsetfor6Vslowcharge(2A)O筋HiSlo,136;Currentin6V2Aoffsettablefor7.0VMin60ffSk).equ134;MaxCurrentfor6V2Arateduriiigdi/dtOff6LoFst.equ121;Lowestcurrentin6V15Aoffset"leOff6Fst,equi17;Nominaloffsetfor6Vfastcharge(15A)Off6HiFst.equ117;Highestcurrentin6V15AoffsettableMin60fFst.equ115;MaxCurrentfor6V15Arateduringdi/dtOff6Rap.equg8;Nominaloffsetfor6Vrapidcharge(60A)Off6LoRap.equ88;Lowestcurrentin6V^0AoffsettableOff6HiRap.equ82;Highestcurrentin6V60AoffeettableOf65Cmk.equ105;OFFSETfor6VCrankstandbyHiOff,equ140;highlimitforOFFSETvariableHiOff6.equ150;highlimitforOFFSETvariable(6Vmode)ABORT.equOOSii;abortstateLEDslow.equ007h;SlowLED-bitofSwDataLEDboost.equ006h;CrankLED-bitofSwDataLEDfast.equ005h;FastLED-bitofSwDataLEDrap.equ004Ii;RapidLED-bitofSwDataLEDgel.equ003h;AGM/GelLED-bitofSwDataLEDdeep.equ002h;DpCyclLED-bitofSwDataUEDreg.equ001h;RegalarUED-bitofSwDataLED6V.equOOOh;(SVRegLED-bitofSwDataLEDdone.equ000h;ChargedLED-PORTALEDchgng,equ00;ChargingLED-PORTALEDalert,equ002Ii;FaultLED-PORTALEDprcnt.equ003h;PercentLED-PORTALEDvolt,equ004h;VoltageUED-PORTALEDalt.equ005h;AltatrLED-PORTASerData.equ006h;SerialData-PORTACIrData.叫u007h;DataClear-PORTAShftClk,equ000h;ShiftClock-PORTBLtchClk.equ00〗h;LatchClock-PORTBESrly.equ003h;E/Srelay-PORTBDisable,equ006h;DisableCtrl-PORTBSCRs,equ0071i;SCRcontrol-PORTBFanCtl*equ004bi;Fancontrol-PORTCTypeSw.equ005h;Typeswitch-PORTCRateSw.equ006h;Rateswitch-PORTCMeterSw.equ007h;Meterswitch-PORTCSwOff.equ004h;bitinSwDownfordisabledType&RateswitchesBatTypeA.equ000h;bitinFlagsforbatterytype:0-Reg,1=D/CBatTypeB.equ001h;bitinFlagsforbatterytype:1-AGM/GelCellRate,equ002h;bitinFlagsforchargerate:0-Slow,1=FastCrank,equ0O3h;bitinFlagsthatindicatesenginestartCrankWait.equ004h;bitinFlagsthatindicatescooldownbetweencranksStarted,equo65h;bitinFlagsthatindicateschargestartedMtrUnits.equ006h;bitinFlagsformeterunits:0-volts,1=%MtrScale,equ007h;bitinFlagsformeterscale:0-batt,1-altrntrBatt.equ000h;bitinFlags2:1ifbatteryisconnectedRapid.equ001h;bitinFlags2:1ifchargerateisRapidBat6V.equ002h;bitinFlags2:1ifoutputis>10APower.equ003h〗bitinFlags2:1ifoutputisonNMInt,equ004h;bitinFlags2:1ifNMIinterrupt。ifTimerChMode.equ005h;bitinF(ags2:1ifinChargermode(notTester)Wait0P.equ006h;bitinFhgs2:1ifbattery>10VAlert.equ007h;bitinFlags2:1indicatestroubleRmplnt.equ000h;bitinFlags3:1during1sthalfeachRampintervalSettle,equ001h;bitinFlags3:1duringvoltagesettletimeHiEnd.equ002h;bitinHags3:1ifhighervoltageforEndChargeIdle.equ003h;bitinHags3:1untilabuttonispressedHi6V.equ004h;bitinFlags3:1ifbattery>8,5VNxtCnt.equ005h;bitinFlags3:0duringlasthalfofCCDcntintervalManual.equ006h;bitinFlags3:1duringManualmodesBurnln.equ007h;bitinFlags3:1duringBurn-InmodeIdleSet,equOOOli;bitinFlags4:1if10minuteIdletimerwasstartedNoRamp.equ001h;bitinFlags4:1duringmanualfastchargeSOC,equ002h;bitinJFJags4:1duringStartOfCharge(1st5sec)Crnkng.equ003h;bitinFiags4:1duringcranking(Statel9)HiPwr.equ004h;bitinFlags4:1ifchargerate>FastRestore.equ006h;bitinFiags4:1ifindesuifationroutineCrankOff,equ180;crankofftimeinsecondsCrankON,equ5;crankontimeinsecondsCCDint.equOOlh;crankcooldowndisplaycounterinterval(seconds)CrankSS.equOlOh;craakSSisstate16-10hexDecimal.equ004h;bitinDigiDatlfordecimalpointDigitl.equOOOh;bitinDigiDat2formostsignificant1SwsOff.equ1111111lb;bitpatternforallswitcheso任DigiOffa,equ11111111b;bitpatternforallsegementsoffDigiOffb.equ1111111lb;bitpatternforallsegementsoffDigiONa.equ00000000b;bitpatternforallsegementsONDigiONb.equOOOOOOOOb;bitpatternforallsegementsONDashesl.equ11111101b;bitpatterntodisplay一-Dashes2.equ11111011b;bitpatterntodisplay一-一DigiRevl.equOOOlOOlOb;bitpatterntodisplaf二0DigiRev2.equ0110000lb;bitpatterntodisplay—DigiMVl.equ1101001lb;bitpatterntodisplayDigiMV2.equOOOOOlOlb;bitpatterntodisplay^5—;.org0880h;forST6210/15.org0100h;forST6220/25RESETCALLRstWDR;resetwatotidogtimerClearTheRamAreaRAMCLRLDIX,084h;pointXto1stRAMLocationRAMCLR1CLRA;clearALD(X),A;storeAatlocationpointedtobyXINCX;incre迈entXLDA,X;getpointerinACPI入0C0h;testforendofRAMJRNZRAMCLR1;doagainifnotfinishedNowSetUpTheHardwareI/OPortsPORTA,Bit0=LED-Done(Ou中叫O-ON);Bit1=LED-Charging(Output,0=0^[);Bit2=LED-Alert(Output,0=ON)';Bit3=LED-Battery%(O牟t,0=ON);Bit4=LED-VolteDC^Output,0=ON);Bit5=LED-Altmtr%(Output,0=ON);Bit6=SerialData(Output,0=ON);Bit7=DisplayClear(Output,0=clear);B诚76543210LDIDD試llllllllb;SetallbitsasoutputsLDIORA,1lOOOOOOb;open-drainoutputs0-5;6-7push-pdlLDIDRA,1111111lb;Setinitialvaluesto1(ofi)LDIDRAbuf,l111111lb;storesettingsinshadowRAMPORTB;Bit0=Shiftclock(Output,0->l=Shift)<formula>formulaseeoriginaldocumentpage226</formula>JRSMeterSw,DRC,NoPOST;SIdpaheadifMeterModebuttonnotpressedJRSTypeSw,DRC,POST;SkiptoPOSTifTypebuttonnotpressedJPTes氾I"..otherwise,ski|)aheadtoBum-InsetupNoPOST孤RateSw,DRC,TESTl;CheckTypeswitchifRateswitchispressedJRSTypeSw,DRC,NoTest;gotoMAINif加switchispressed5SetforManualFastChargeSETHate,FI绍s;tunionFastLED,turnoffSlowLED鹏Rapi胡ags2;turnoffRapidLEDRESHiPwr,Flags4;turnoffhighpowermode;SETNoR咖p,Flags4;setforFastrateWorampuptoRapidLDIOFFSET,OfEFast;setforFastrateJPTestMMl;setforManualchargeNoTestJPMAIN;sldptestandgotoMAINTEST1;SetformanualSlowChargeJRRTypeSw,DHC/TEST2;ifTypeswitchispressed,setforFastTestCALLSetSlow;setforSlowRateCALLStartSlow;setOFFSETforSlo邻rate;LDIOKFSET,OfifSlow;setOffsetfor2AJPTestMMl;setforManualchargeTes氾I;Setfor60minuteBurn-InSETBumln,Flags3;SetforBura-InmodeLDI0鹏ET,02Fast;setforFastrateRESHiPwr,Flags4;tumoffhighpowerCALLSetRmpl)p;preparetorampfromFasttoRapidTEST2;setforManualRapidCharge;SETManual,Flags3;setforManualmodeSETRate,Hags;setfornon-SlcrwrateSETRapid,Flags2;tiimonRapidLED;RESNoRamp,Flags4;setforrampingJRSBurnln,Flags3,TestRap;don'tsetforrampdownifBum-InSETHiPwr,Flags4;turnonhighpowerLDIRmpCnt,RCinitR;setcounterforRapid;RESRampUp,Flags3;setforrampdownLDIOFFSET,O股ap;setOffsetforRapidChargeCALLSetRamp;setrampingparametersTestRapJPTestMMlisetforManualchargePOSTCALLResetLEDs;turnoffalltype,rate&StatusLED'sCALLMeterOff;turnoffallmetermodeLED'sCALLDigitsOff;turnoff3-digitLEDRESPower,Flags2;makesureoutputwillbeoff;showstatusLED'sCALLShowGreen;lightGreenLEDonlyCALLFi他Second;waitoneFifthsecondCALLShowChgng;lightChargingLEDCALLFi他Second;waitoneFifthsecondCALLAIertON;turnonAlert(Red)LEDCALLR他Seccmd;waito肪FifthsecondCALLResetLEDs;turnoffalltype,rate&StatusLED's;showchargerateLED'sSETChMode,Flags2;mustsetflagtoshowrateLED'sRESCranigFlags;turnoffCrankLEDCALLSetSlo邻;setforSlowRateLDILEDnum,SlowAmps;setdigitalLEDtoshowSlowrateCALLHoldRate;showRateandwaitaFifthsecondSETRate,Flags;tumonFastLEDLDILEDnum,FastAmps;setdigitaLEDtoshowfastrateCALLHoldRate;showRateandwaitaFifthsecondSETRapid,Flags2;turnonRapidLEDLDILEDnum,HapAmps;setdigitalLEDtoshowRapidrateCALLHoldRate;showRateandwaitaFi他secondRESChMode,Flags2;clearflagtodisableoutputLDILEDnum,CrnkAmps;setdigitalLEDtosbowCrankrateCALLSiiowNum;getdatatoshowtheLEDnumberCALLShowCrank;tumcmCrank(Boost)LEDCALLF她Second;waitoneFifthsecondCALLResetLEDs;turnoffalltype,rate&StatusLED'sCALLShowData;updatedisplay;showbatterytypeLED'sCALLSetl2V;setforRegular,12VbatteryLDIDigiDatl,DigiRevl;setdigitalLEDtoshowCodeRevisionLDIDigiDat2,DigiRev2;setdigitalLEDtoshowCodeRevisionCALLHoldType;showTypeandwaitaFifthsecondSETBatTypeA^Fkgs;turnonDeepCycle&turnoffRegularLEDCALLHoidType;showTypeandwaitaFifthsecondSETBatTypeB,Flags;tancmGel/AGMLEDRESBatTypeA^Flags;turnoffDeepCycleLEDCALLHoi^Type;showTypeandwaitafifthsecond;RESBatTypeB,FIags;tonoffGel/AGMLED;SETBat6V,Fiags2;turaON6VLED;CALLHoldType;showTypeandwaitaFifthsecondCALLResetLEDs;turaoffalltype,rate&StatusLED言s;RESBat6V,Fl昭s2;setfor12Vbattery(not6V);showdisplaymodeLED'sCALLS&owData;updatedisplaySETMtrUnits,Fkgs;setfor%LEDsON,voltsLEDoffRESMtrScale,Flags;setforAlternator%LEDoffCALLHoldMtrMd;showmetermodeandwaito加fifthsecondRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffCALLHoldMtrMd;slaowmetermodeandwaito加fifthsecondSETMtrUnits,Fiags;setfor%LEDsON,voltsLEDoffSETMtrScak,Flags;setforAlternator%LEDONCALLHoldMtrMd;sliow迈etermodeandwaitonefifthsecondCALLMeterOff;turnoffallmetermodeLED'sCALLResetLEDs;turnoffalltype,rate&StatusLED'sLDILEDnum,5;initializeto5toshow41stPOST2DECLEDnum;thenextnumberwillbe1lessCALLNumData;getdatafor,andshowLEDnumberCALLFi他Second;waitonefifthsecondLDA,LED加m;checkforlastnumberJRNZPOST2;loopbackandrepeatifnottherePOSTSADDIA,20jadding20changes2nddigitLDLEDimm,A;pr邻aretoshewnewnumberCALLNuraData;getdatafor,andshowLEDnumberCALLFifthSecond;waitonefi池secondLDA,LEDnum;checklatestnumberCPIA,100''comparetolastnumberJRNZPOST3;bopbackandrepeatifnotthereCALLResetKEDs;turnoffalltype,rate&StatusLED'sCALLInitState;resettoSlow,TypeAchargemodeRESChMode,Flags2;setforTestermodeJPTEST;repeatPOSTifnecessaryTestMMl;SetformanualchargeSETM咖al,Flags3;setforManualmodeSETChMode,Flags2;setforChargerMode(outputenabled)RESDisable,DRBbuf;咖bleoutputLDICurentSS,15;State15isManualchargeSETStarted,Flags;setFlagsforchargestartedSETPower,Flags2;tellPwrConchargerisonCALLIniTimel^initializeTimerl.IFCNELongTst;assemblenextlineonlyifnotdebuggingLDIHrsl,1;setTimerlfor1hour.ELSE;assemblenextlineonlyifdebuggingLDIHrsl,255;setTimerlfor255hours.ENDCJRRBumTn,Flags3,MAIN;skipnext2linesifnotBurn-inTestMM2GALLIniTims:2;resetTimedLDIMins2,1;settimerforcounterinterval(1minute)LDICCDcnt,60;setBurn-inminutecounterto60*BecausetheA/Dvotage:isbeingaveraged,itwouldtakeconsiderable**timetonoticethatabatter^hasbecomedisconnected.Toovercomethis**DELAYtheprogramwillmonitortheinstantaneousvoltageeachtimethru;*thelooptodetectthisconditioitThischeckwillbemadeonlyifthe*:*unitisinachargingmode.*MAINCALLRstWDR;resetwatchdogtimerLDA,CurentSS;getcurrentstateCPIA,ABORT;checkforabortJKNZMainMore;continueMainifnotAbortJPMAIN3;don'tcontinueMainifAbortMainMoreJRRManual,Flags3,MainAuto;continueMainifnotManualModeJPSS15;otherwise,gotoManualchargeMainAutoJRSCrankWait,Flags,MAINl;don'tcheckswitchesduringCrank*waitCALLCheckSw;checkifswitchisbeingpressedMAIN4JRSCrank,Flags,MA!NO;skipaheadifduringCrankCALLGetPercent;updatethepercentagereadingCALLUpdateBP;update%todisplayCALLGetMeter;updatedisplayJRRIdle;Flags3,MAIN0;skipaheadifnotidleJRRBatt,JFlags2,M細0;don'tcheckidletimelimitifnobatteiyJRSIdleSet,Flags4,MAIN5;don,tsetidletimerifalreadysetCALLIniTimel"..otherwiseinitializetimer1LD工Minsl,OAh;settimer1for10mimitesSETIdleSet,Fkgs4;Idletimerstarted,setflagMAIN5JRRMIN,TicFlagl,MAINO"..otherwise,checkidletimelimitRESDisable,DRBbuf;…enableoutputaileridletimelimitJPMAIN2;…andre-ioitializeifreachedMAIN0;notCrankycheckfor0or1JRSPower,Flags2,MAINl;chargerisON,goto0VcheckJRSLEDchgng,DRAbuf,MAIN3;chargernotalmoston,skip0VcheckMAIN1;CtieckfordisconnectedbatteryCALLCheckBatt;checkfordisconnectedbatteryJRSBatt,Flags2,MAIN3;skipaheadifconnectedMAJN2;0Vdetected,preparetostartoverfromstate0LDIDspPcn仁0;initializedisplayPercentto0CALLInitState;initializetoSlo邻RegularChargemodeMAJN3*SEQUENCESTATEJUMPTABLE**Determinewhatroutinetoexecuteonthispassthroughthetheloop.Only**oneroutineisexecutedeachtimethroughtheloop.*NSS0LDA,CurentSS脑ZNSSlJPSSO;*SSO-NSSlCPIA,OOlli则ZNSS2JPSSiSSI-NSS2CPIA'0021i则ZNSS3JPSS2SS2-NSS3CPIA,003h廳ZNSS4BATTERYDETECT*BATTEHYDETECTDELAY*AUTOMATICCHARGESTART*200680025856.8说明书第228/354页JPSS3;*SS3NSS4CPIA,004hJKNZ顺5JPSS4;*SS4顺5CPIA,005hJRNZ顺8JPSS5;*SS5鹏6;CPIA,006h;JRNZNSS7,'JPSS6;*SS6NSS7;CPIA,007hiJRNZNSS8;JPSS7;*SS7NSS8CPIA,008hJRNZ鹏9JPSS8;*SS8NSS9CPI入OO处JRNZNSSllJPSS9;*SS9NSS10;CPIAOOAh;IRNZNSSll;JPSS10,SSIO-RESTORECHARGE*NSS11CPI入OOBliJRNZNSSI2JPSSll;*SSli-dV他MONITOR*NSS12CPI拳ChJKNZNSS13JPSS12;*SS12-dl/dtMONITOR*NSS13CPI人OODhJKNZNSS14JPSS13;*SS13-ENDCHARGE*鹏14CH入OOEliJPSS14;*SS14-MAINTAIN*NSS15CPIA^OOFhJRNZNSS16JPSS15;*SS"-Manual*NSS16CPIA,OIOh3KNZNSS17JPSS16;*SS16-CRANK*NSS"CPI入OllJiJRNZNSS18-BELOW9Volts*-BELOW12Volts*-NORMALCHARGE*-緒MONITOR*NOTUSED-CHARGECOMPLETE*NOTUSED-ABORTCHARGE*-DESULFATION*JPSS17;*SS17鹏18CPIA,012hJRNZNSS19JPSS18;*SS18鹏19CPIA,013hJRNZNSS20JPSS19;*SS19NSS20CPIA,014hJRNZNSS21JPSS20;*SS20NSS2iLDIWDR,001hCRANK*-CRANK*一CRANK*CRANK*invalidsequencestate,reset*ENDOFMAIN**WaitforNMI,whichindicatesendofPETonperiod,beforemeasuring*batteryvoltage.*ExitMainXMainWAIT;waitforinteruptJRSNMLit,Fags2,XMain;timerinteruptKEADBATTERYVOLTAGE**Thisroutineisexecutedatornear2er0cross.Thecuirentvoltage**isstoredinCurVoltandthereadingisaddedtoBADhi(twolocations).*BADhiwillcontainarunningaverageofthelast256readings,*BADREAD.IFC]EQShoADC;assemblenext2linesonlyifdebuggingSET2,DRBbuf;set:PB2邻lienA/DsamplingstartsCALLUpdatePB;updateportBfrombuffer.ENDCLDA,BADlo;getaveragereadingSUBA,BADhi;subtractonereadingfromtherunningtotalJKNCBADREAD1;nocarry,goonDECBADhi;adjusthighorderbitsBADREAD1LDBADo,A;store加wvalueLDIADCR,OB0h;startA/DconversionLDIADCR,0B0h;doagaintoinsureavalidstartWAIT;lettheinteruptnotifyuswhendataisreadyLDCurVoit,A;savecurrentreadingADDA,BADlo;addintorunningaverageJHNCBADREAD2;加cany,goonINCBADhi;incrementhighbitsBADREAD2LDBADb,A;storenewlowbits,IFCEQShoADC;assemblenext2linesonlyifdebuggingMS2,DRBbuf;setPB2whenA/DsamplingstartsCALLUpdatePB;updateportBfrombuffer.ENDCLDIORB,01FhLDIORB,09Fh*維AVERAGECALCULATION**Forusebythedi/dt)aboutfourtimeseverysecondtheaverageofthe'*previouscurvoltreadingsisstoredinFreshBVforcomparisontoa:*readingtakenonceeverysecond.*DIDTAVGLDA'Temp2;ifTemp2=0thenfirstreadingJRNZDIDTAVGl;skipinitifnot1streadingLDITemp2,020h;initializeTemp2to32DIDTAVGlLDAFBVTofLo;ADDA,CurVolt;addcurrentvoltagetototalJRNCDIDTAVG2;don'tinchighbyteifnocanyINCFBVTotHi;inchighbyteDIDTAVG2LDFBVTotLo,A;updatetotalDECTemp2;updateTemp2JRZDIDTAVG3;co迈puteavgJPDIDTAVGX;exittoMainDIDTAVG3LDITe迈p2,003h;preparetoshift3timesDIDTAVG6LDA)FBVTo(Hi;loadhighbyteoftotalintoaccumulatorSLAA;shiftaccumulatorleftLDFBVTo瓶,A;邵datehighbyteoftotalLDA,FBVTotLo;loadlowbyteoftotalintoaccumulatorSLAA;shiftaccumulatorLDFBVTotLo,A;updatelowbyteoftotalJRNCDEDTAVG4;迈sbwaszero,skipnextlineINCFBVTotHi;DIDTAVG4DECTemp2;decloopcounterJRZDIDTAVG5;ifzero,finishaverageJPDIDTAVG6;notzero,shiftagainDEDTAVG5LDA^FBVTotHi;storeaverageinFreshBVLDFreshBV,ACLRFBVTotHiCLRFBVTcrtLoJRS7,FreshBV,DA7;skipaheadif>8.5V'RESHi6V':Flags3;clearHi6VflagJPDIDTAVGX;andskiptoendofroutineDA7SETHi6V,Hags3;setHi6VflagDIDTAVGXJPM細*Thisiswherethesequencestatesaredefined.Thenumberofagiven,sequencestatehasnorelevancetotheorderinwhichitisactually*;*executed.Anygivenstatecangivecontroltoanyotherstate.**BATTERYDETECT**Thisisthechargeridlestate,Theprogramremainshereuntilabattery**isdetected.Decteotionisdetermi加dbyfindingapositivevoltage**greaterthanonevolt尔sso.IFCEQDEBUG;assemblenextlineonlyifdebuggingRESSwOff,SwDown;settocheckTypeandRateswitches.ENDC;RESCrank,Fhgs;clearCrankbitofFlagsRESRestore,Fkgs4;clearRestorebitofFlags4CALLShutOff;low&highpower,fan,&crankoff;mindutyCALLShowRate;turnonchargerateLED(SloworFast)CALLShowType;turncmbatterytypeLED(Reg,D/CorGe);CALLChrgRly;changeE/SrelayifnecessaryJRSChMode,Flags2,Ready;continueroutineifinChargerModeCALLCheckBatt;…otberwise,cheekiftestershouldshowO'sJPSSOEXIT;...andexitReady7RRStarteci,Flags,SSOO,'sJdpifo啤utJi咖'tb鄉onRESStarted,Flags;setFlagsforchargenotstartedSSOOLDAFreshBV;c!iecklatestaveragevoltageIRNZRvrsBatt;Isit0(exactly)CALLShowRed;tunionRedLEDuntilbatteryisdetectedJPSSOEXIT;.,.Yes:mustberev.batt,sostopRvrsBattCPIA,VoltsO+l;No:otherwise,checkif>0.7VIRCPulse;no:trypulsingtheoutputJPSS0一1;yes:setupfornosparkdelayPulse;tunicmchargerfor1cydeeachsecondLDAjMSecsl;pulseoncepersecondCPIA^MSINIT;timetopulse-JRZPulseON;yes3gototopulsecodeRESPower,FIags2;otherwse,teiltimertoleavechargeroffJPSSOEXIT;andkeepwaiting(untilnextsecondstarts)PulseON;pulsechargerononcepersecondSETPower,Flags2;tellPwConchargerison;CALLSturwGr忧n;tumonGreenLED"气est承一JPSSOEXIT;nobattery,justexitSSO一lCALLIniTime〗;然tuptimerLDISecsl,002h;adjustfor2secondsLDITries,005h;5Triesfordebo咖eSETO,CurentSS;goontoBATTERYDETECTDELAYSSOEXITJPExitMainBATTERYDETECTDELAY*Thisstatechecksthatavoltageispresentfortwoseconds.Ifthe**voltagedropsbelow1Wc,dietimerisrestartedandthe"try"counter**isdecremented.Ifafter5Triesthevoltagehasnotbeenabove1Vdc**for2seconds,gobadetobatterydetect,Thisdelayhastheeffectof*<table>tableseeoriginaldocumentpage235</column></row><table>;LDA,Percent;getupdated%LDA,DspPcnt;comparetolast%displayed腿ZSS2—GP;if%previouslysliown,skipaheadCALLGetiPercent;updatePercentforinitialvoltageLDA,Percent;getlatest%LDDspiPcnt,A;storelatest%inDispkyPercentRESWaitOP,Hags2;setflagtoindicatenotwaitingJPSS2—BP;skipaheadSS2—CPIA,100;checkfor100%腦ZSS2—BP;contiimeState2ifnot100%CALLSetMinOff;limkoutputtomax2Acurrent)'LDILowOff,MinOffSlo;limitoutputtomax2Acurrent;JKRBat6V,Flags2,SS2—6S;skipnextlineifnot6Vmode;LDILowOff,Min60倒o;imitoutputtomax6V2acurrent;SS2j5SJPSS5—Maint"..otherwise,gotoMaintainSS2—CALLShowChgng;tumChargingLEDonCALLIniTimel;initializetimer1LDIMinsl,5;settimer1for5mkrutes;LDISecsl,0051i;settimer1for5secondsLDICCDcnt,MaxHrs;setintervalcountertoMaxHrsCLR_LastBatt;clearLastBatt(eiisurepass1sttest);SETSOCflags4;setStartOfChargeflagCALLIniTime2;initializetimer2LDISecs2,001ii;settimerfor1secondLDIMSecs2,MS500;settimerfor500milliseccmds(0,5secs)LDIMins2,006h;settimerfor5minutesand2secondsLDIHrs2,0(5fr;settimerfor4hours,5minutes<fe2secondsJRSRate,Flags,SS2Fast;skipaheadifnotsetforSlowotherwise,setforSlowchargeCALLStartSkw;setOFFSETforSlowrate;LDIOFFSET,O倒ow;setO飽etfor2A;JRRBat6V,Flags2,SS2Sl0;skipifnots改for6Vmode;LDIOFFSET,Off6Sk)""otherwise,adjustOFFSET;SS2S1。JPSS2—0a;skipaheadandreadvoltageSS2Fast》etforFastchargeLDIOFFSET,02Fast;setOffsetforFastrateJRRBat6V'Flags2,SS2Fst;skipifnotsetfor6VmodeLDIOFFSET,0,st;…othenvise:,adjustOFFSETSS2FstJRRRapid,Fkgs2,SS2Rap;skipaheadifrateisnotRapidCALL5etRmpUp;preparetorampfromFasttoRapidSS2Rap;setforRapidchargerateJPSS^Oa"..otherwiseskipaheadandreadvoltageSS2一0a一CAIlGetBatt;getIa化stvoitage&doubleif6VmodeCPIA,Volts09;verylowbatteryJRNCSS2—2;no,trynextlimitSS2J;BStery<9VLDfA,003ii;yes,serviceit,below9VOLTSSJPSS2—5SS2—2;Battery>9VCpf"A,Voits12;lowbatterystateIRNCSS2一4;no,gotoSS5SS2—3;97<Batteiy<12VLDrA,004ti;yes,serviceit'below12VOLTSSJPSS2一5SS2—4;Batoy>12V;JR^AleryF〗昭s2,SS2EXIT;doii,tstartchargeifAlertsetbyDouble6VLDI入005h;加rmalchargeSSSS2一5LDCurentSS,A;preparetogotothecorrectstate(3,4or5)SETStarted,Flags;setFlagsforchargestartedCALLTurnON;加moutput,F叫an5ChargingLEDonSETSettle,Flags3;initialchargevoltagesettlemodeSS2EXITJPExitMain*BELOW9Volts**Batteryisextremelydischargedandmaybebad.Chargeforamaxiirmm:*offiveminutes.Ifvoltagedoesnotcomeabove9Voltsinthistime**period,abortcharge.Otherwise,gotobeknv12Volts.*SS3CALLChkRapid;updateRamptimer,ifnecessaryJRRSEC,TicFlag2,SS3EXIT;exitifvoltagesettletime加texpiredRESSettle,Fl绍s3;clearsettleflagCALLIReg;regulatecurrenttillwegettodV/dtIRRMIN,TicFlag2,SS3一l;checkiftimehasexpiredCALLSetAbort;yes,timetoabortJPSS3EXITSS3—1CALLBattProg;chec3cbatteiyvoltageforchargeprogressCPIA,Vote09;isbatteryupto9VJRCSS3EXTT;contiimestate3if<9VINCCurentSS;…otherwise,gotostate4SS3EXITJPEdtMain*BELOW12Volts**Batteryisverylow.Allowamaximumof2hoursforthevoltageto*riseabove12volteundercharge.Ifvoltagedoes加tcomeup,goto*abortcharge.Otherwisegotonormalcharge.*SS4.CALLClikRapid;updateRamptimer,ifnecessaiySEC,TicFIag2,SS4EXIT;exitifvoltagesettletimenotexpiredRESSettle,Flags3"..otherwise,clearsettleflagCALLIReg;regdatecurrenttillwegettodV/dtJRRHR,TicFlag2,SS4—1;checkiftime(4hours)hasexpiredCALLSetAbort;yes,timetoabortJPSS4EXIT;exitroutineSS4JCAJXBattProg;checkbatteryvoltageforchargeprogressCPIA,Volts12;isbatteryupto12VJRCSS4EXTT;...if加t,justexitINCCurentSS-'...otherwise,gotostate5SS4EXITJPExitMain*NORMALCHARGE**Programstayshereuntilthevoltagereaches14,2voltsorthemaximum*chargetimeisexceded.Ifthevoltagelimitisreachedtheprogram**willtransferto:**A.SSB(dV/dt)ifthethebatteryhasbeenchargingmorethan5**minutesor**B.SS9(Desulfation)iftheOCVwaslessthan12.2voltsor**C.SS14(Maintain)iftheOCVwasmorethan12.2volts**Ifthemaximumchargetimeisexcededtheprogramwillabort*SS5CALLShowChgng;tumChargingLEDonCALLChkRapid;updateRamptimer,ifnecessary.IFCDEBUG;assemblenextlineonlyifdebuggingSETSw6ff,SwDown;settoignoreTypeandRates"witches.ENDCIRRSJEC,TicFlag2,SS5x;exitifvoltagesettletimenotexpiredRESSettle,Flags3;…otherwise,clearsettleflagCALLBattProg;checkbatteryvoltageforchangeprogressJRRHR,TicFlagl,SS5—0;skipnextlineifmaxtimenotexpired;NOTE:CurentSSsiitoABORTbyBattProg,ChkProgSS5xJPSS5EXIT;exit(andabort)ifmaxtimeexpiredSS5一0;IRSRate,Flags,SS5,0b;changedeltaifslowrateCPIA,Voltsl42+l^iieckifover14.2voltsyet;JPSS5—1SS5—Ob—,;CP亍A,Votel42+3;checlcifover14.2voltsyetSS5」JRNCSS5—2;yes,checkif>5minutesCALL1Reg;no,regulatecurrenttillwegettodV/dtJPSS5EXIT"..andjustreturnSS5—2LD;,CCDcnt;getCCDcnt(setbyBattPRogw/minutes)LDHrsJ,A;setTimerlhourstoCCDcntRESHiPwr)Flags4;setforlowpowermodeRESRmpInt,Flags3;clearflagbeforemovingon;RESSettle,Flags3;clearflagbeforemovingonJRSMIN,TicFlag2,SS5一3;if>5min,gotod微LDA^OlciVoit;othenvise,checkinitialvoltageCALLDouWe6V;doub〗eBatteryvoltageifsetfor6VCPIA,Vohsl22;initialvoltage<12.2VJRCSS5—5;Yes:thendesulfateJPSS5—^iaint;No:gotoMaintainSS5—5—LDfCurentSS,009h;batteryissulfatedLDIMaintVoh,"Volts16;trytoholdbatteryat16VLDIVref,Volts15;andseeifitdropsto15VCALLIniTime2;LDIHrs2,0021i;inlessthan2hoursSETRestore,Flags4;setRestoreflagJPSS5EXIT;SS5J3CALLSetMinOff;min2Aoffsetvalue(maxcurrent);LDILowOff'MinOffSlo;min2Aoffsetvalue(maxcurrent);IRRBat6V,Flags2,SS5—6V;skip加xtli加ifnot6Vmode;LDILowOff,Min60ffSb;min6V2Aoffsetvalue(maxcurrent);SS5一6VJRRRate^Flags,SS5—6;checkfor15AchargerateCALLSeiMioFst;minFastoffsetvalue(maxcurrent);LDILowOff,MmOfFst;min15Aoffsetvalue(maxcurrent);JRRBat6V,Flags2,SS5—6;skipnextlineifnot6Vmode;LDILowOff,Min60fFst;min6V15Aoffsetvalue(maxcurrent)SS5—6LDA,LowOff;LoadLowOffintoAfornextstepLDOldOff,A^initializeOWOfffordi/dttoLowOffLDICurentSS,00Bh;gotowaitfordv/dttripvoltageLDIPercentj77;setPercentto77CALLIniTime2LDIMins2,13;setto13minutesfordV/dtLDA3ADhi;getlatestbatteryvoltageSUBIA,4;preventmatch@1stdV/dtcheckLDMaintVoft,A;storeasmaintainvoltagefordi/dtLDI丁ries,004h;initializedV/dtfor4Tries(3intervals)JPSS5EXIT;SS5—Maint;gotoMAINTAIN,batteryisalreadychargedCALLSetl00p;setPercentto100LDIMaintVolt,Volts132;setmaintainvoltageto13,2V;CALLFanOff;tumcoolingfanoffJRRBatTypeB,Flags,SS5—7;skipaheadif加tGd/AGMLDIMaintVolt,Volts135;;etmaintainvoltageto13,5VforGel&AGMSS5一7LDrCurentSS,00Eh;Maintainisstate14(0Ehex)CALLSetON;tumcoolingfan&outputonCALLFanOff;turncoolingfanoffCALLSe氾iOff;MAXoffsetvalue陽>mindutycycleSS5EXITJPExitMain556557*SS8-ABOUTCHARGE牛承*;*TurnoffanLED's,BHnkTROUBLELEDathalfsecondinterval.If;*batterybecomesdisconnected,gotoBATTERYDETECT.*SS8SETAJert,Flags2;setAlertflag;CALLShutOff;low&highpower,fan,&crankoff;mindutyCALLSetOff;turnoffpowerandsetforminduty;CALLChrgRly;changeE/SrelayifnecessaryCALLBlinkAlert;blinkredLEDJRSBurnln,Flags3,SS8:X;don'tcheckforbatteryifBum-InCALLCheckOV;checkfordisconnectedbatteryJE5Batt,Flags2,SS8X;ifconnected^justexitRESAlert,Flags2"..otherwise,endabortroutineSS8rstJPMAIN2;re-initiali:zeSS8XJExitMain-SS9-DESULF八TION*&DesulfationModeisenterediftheinitialbatteryvoltageisless*^than12.2voltsandthevoltagereaches14,0voltswithinfive*-minutes,*eThechargertriestoholdthevoltageat16.0volts.Asthebattery**startstoconduct,thevoltagewillfalLIfthevoltagereaches14,0*11inareasonabletimelimit(10hours),wewilltransitiontothe*一normalchargingsequence(SS5).Ifthevoltagedoesn'tfallto14.0:voltswewilltransitiontotiieAJBORTsequencestate(SS8),SS9LDIPercent,15;settol5%CALLBlnkChrg;blinkChargingLEDCALLCheckBa忧;checkforconnectedbatteryJRRBattjFiags2,SS8rst;re-initializeifnotconnectedCALLVoitRegIRRSEC,TicFlag2,SS9X;wait1minuteJRR取TicFIag2,SS9—1;maximumtimeout(1or2hours)DECCurentSS;AB(5rtstateSS9exitJPSS9X;doneSS9一1CALLGe氾att;getlatestvoltage&doubleif6VmodeCPA,Vref;arewethereIRNCSS9改it;ifno伫titienexitDECVref;1countis0.0667voltsDECVref;red腦Vrefby0.133voltsLD入Vref;seeifbattisdesulfatedyetCPIA,Volts14;isVref<14.0VoitsJRCSS9一2;yes:skipnextlineJPSS9—3;no:tryanotherhourSS9一2一LDICurentSS,005h;preparetogotonormalchargeRESRestore,Flags4;abouttofinishRestoremodeLDA,Vmax;setMaintVolttoV迈axLDMaintVolt,A;maintainvoltageforstate5CALLIniTime2^initializetimer2LD工Secs2,002h;settimerfor2seconds(voltagesettletime)JPSS9X;SSS>—3CALLIniTime2;resettimerLDIHrs2,001h;setmaxtimefor1hourSS9XJPExitMainSS10;*麵tMONITOR*;*Thisstateislookingforoneofthreeconditions:*;*'1.Maximumtimeisexceded-setforcheckbatteryandturnoffcharger.*;*2.NochangeindV/dtfor45minutes陽batteryisabout80%charged.*;*3.MAXvoltageisreached-GOTOdl/dt.*SSllJRRHR,TicFlagl,SSllJ;Ifnotmaxtimeout,gotoSSll—1CALLSetAbort;otherwise,gotoabortJPSS11XSSll一lCAliShcwChgng;lightChargingLEDCALLGetBatt;getlatestvoltage&doubleif6VmodeCPA,Vmax;isbattvoltage<MAXvoltageJRCSSIl一2;yes:continueloopSETHiEn5,Flags3;no:settoboostduringD/CEndChargeJPSSI1—6;...andpreparetoGOTOdl/dtSSI1—2—JRRMIN,TicFlag2,SSlIX;exitifnottimefordv/dttestLDA,Percent;getPercentCPIA,84;isPercent<84JRNCSS11—3;...ifnc^skipaheadINCPercent".otherwise,increasePercentSSI1—3LDA,BADhi;getbatteryvoltageDECA;limhfor6Vbatteriesis1countJRSBat6V,Flags2,SSll一3a;leavelimitat1for6VbatteriesDECA;limitfor12Vbatteriesis2countsSSll一3aCPA,MaintVolt;testforupperlimitchangeJRCSSI1—4;lessthan1countup,testdownchangeJPSSI1_7''otherwise,skipahead&updateMaintVoltSSIl一4_DECTries;decrementcounterJRZSS11—6''alldone,GOTOdl/dtLDA,Percent;getPercentCPIA,87;isPercent<88JKNCSSIl一5;...ifnot,skipaheadINCPercent;…otherwise,increasePercentSSI1—5JPS§11—8;no,reloadtimerSSll—6—INCCurentSS;GOTOdl/dtnextLDIPercent,88;setPercentto88-NOTEmustalwaysbeeven]RSH正nd,FIags3,MntMx;skipaheadifVmaxreachedCALLGetBatt;getlatestvoltage&doubleif6VmodeLDMaiirtVo!t,A;saveBADhiasmaintainvoltageJPSSI1—9;initializeTriesandTimer2fordi/dtMntMxLDAjVmax;otberwise,setMaintVolttoVmaxLDMaintVolt,A;MaintVoltusedfordi/dtJPSSI1_9^initializeTriesandTimer2fordi7dtSS11_7;updateMaintVoltLDA,BADloi;getcurrentbatteryvoltageLDMaintVolt,A;updateMaintVoltfordV/dt&di/dtSS11J*LDITries,004h;resetcounter(4matches=3intervals)SSll一SCALLIniTime2;initializetimerLDIMins2,009h;...fbr9minutesSS11XJPExitMain*齒MONITOR**Indi/dttheOFFSETvalueisadjustedtoholdthevoltageatthedV/dt**value.TheOFFSETvaluewillincreaseandstabilize.**Thisstateislookingforoneoftwoconditions:**1.Maximumtimeis,exceded-setforcheckbatteryandturnoffcharger.**2.NochangeinOFFSETvaluefor39minutes-currentstabilizedata**lowvalue.Batteryisabout97%charged.GotoSSI3(EndCharge)for**1hour.*SS12CALLVoltReg;regulatebatteryvoltageatMaintVoltLDA,DspPcnt;getlast%displayedCPIA,IOO;has%displayedreached100JEZSS12一14;…ifso,turnongreenLEDCALLShowYellowotherwise,turnonyellowLEDJPSS12—15;...andskipahead(leavegreeno均SS12—14—CALLShowDone;turaonchargecompleteLEDSS12J5JRRl^TicFlagl,SS12一l;maximumtimeoutJRSAlert,Flags2,SS12_0;If2ndmaxtimeout,gotoSSI2一0SETAlert,Flags2;If1st迈axtime,setAlertflagCALLIniTimel;andresettimerLDIHrsl,004h;toalow4morehoursSS12—10LDX,MaintVolt;andgetMaintainvoltageSUBI入007h;thensubtract~0.5VLDMaintVolt,A;andupdateMaintainvoltageJPSS12EXIT;thenrestart磁'SS12一0CALLSetAtiort''gotoabortRESAlert,Flags2;resetAlertflagforAborttimerJPSS12EXITSS12—1JRRMIN,TicFlag2,SS12EXIT;timefordi/dttestLDA,Percent;getPercentCPIA,100;isPercent<100JRNCSS12一2;…if加t,skipaheadINCPercent;...otherwise,increasePercentLDAjPercent;getpercentCPIA,IOO;Ispercent=100JRZSS12—2;YES,don'tincreaseanymoreINCPercent;No,increaseby2SS12—2CAliCMcHiOff;checkformaxOFFSET(PWMMloff)JRNCSS12—13;ifso,finishdi/dtDECA;ensurecarryifequalCPA,OWOff;testforlowerlimitchangeJRCSS12一4;offsetwithin1,finishdi/dtJPSS12—7一;offsettoohigh,tryagainSS12—13JPS§"l2—6SSI2_4DECTries^decrementcounterIRZSS12—13;ifO,thenprepareforEndCharge(SS13);JRNZSSi^一5;Arewedone;JPSS12一6;yes,alldone,cleanupandexit;SS12一5;no'continueLDA,Percent;getPercentCPI乂99;isPercent<100JRNCSS12一3;...ifnot,skipaheadINCPercent"..otherwise,increasePercentJPSS12—8;reloadtimer&checkagainlaterSS12一3—LDA,Tries;gtthecurrenttriesCPIA,03;Istrieslessthan3JENCSSI2_11;No,justexitCALLSetl6bp;Yes,show100%anddoneSS12—11IPSS12—8;reloadtimer&checkagainlaterSS12—6一INCCurentSS;GOTOEndCharge(SS13)CALLIniTime2;initializeTimer2LDIHrs2,001h;chargefori!morehour(EndCharge)LDIMins2,00Hi;chargeforonly15minutes(EndCharge)JRRBatTypeA,Flags,SS12一9;skipifnotDeepCycle(Voyager)JRRHiEnd,Flags3,SS12—9;skipifnotusinghigherEndChargevoltageINCHrs2;otherwise,changeHrs2from1to2LDA,MaintVolt;also,storeMaMVoltiaAADDIA,04h;increaseAby4counts~0.267VLDMaintVo比A;storeupdatedvalueinMaintVoItSS12_9JPsSl2EXITSS12一7LDX,OFFSET;setnewbaseoffsetLDOldOff,A;saveinOldOffLDITries,004h;resetcounter(4matches-3intervals)SS12—8CAlXlniTime2^initializeTimer2LDIMins2,009h;setTimer2for9minutesLDA,OFFSET;GetcurrentoffsetCP入LowOff;IsRESHiEnd,Fkgs3;YES,don'tboostvoltageforEndChargeJPSS12_10;CurrentnotMing,reducevoltageby1/2VSS12EXfiIPEx馳in*ENDCHARGE**Chargefordesiredhoursafterdl/dtatdV/dtvoltage.*SS13CALLSetlOOp;setPercentto100LDA,DspPcnt;getlast%displayedCPIA,100;has%displayedreached100JRNZSS13—2;...ifso,turnongreenLEDCALLShowDone;turnonchargecompleteLEDSS13_2CALLVoltReg;regulatebatteryvoltageatMaintVoltCALLChkHiOff;checkformaxOFFSET(PWMfoilofi)JRZSS13—1;exitifmaxOFFSETreachedJRR眠T^Flag2,SS13EXIT;exitif1hourtimenotupSSI3」JPS"^5一Maint—.otherwise,GOTOMAINTAINSS13E35TJPExitMain*MAINTAIN**BatteryhasreachedMlcharge.Stayhereandmaintainbattery*at13.2voltsuntilbatteryisdisconnected.*SS14CALLSetlOOp;setPercentto100CALLVoltReg;regulatebatteryvoltageatMaintVoltLDA^DspPcnt;getlast%displayedCPIA,100;has%displayedreached100JRZSS14一1;...ifso,turnongreenLEDCALLShowYellow"..otherwise,turnonyellowLEDJPSS14一2;…andskipakead(leavegreenofi)SS14—1—CALLShowDone;toraonchargecompleteLED.IFCEQDEBUG;assemblenextlineonlyifdebuggingRESSwOff,SwDown;settocheckTypeandRateswitches.ENDCSS14一2CAllChkHiOff;checkformaxOFFSET(PWMfoiloff)JKNCSS14—3;.響.ifso'shutofffanJRSBat6V,Flags2,SS14—5;skipaheadif6VmodeCPIA,HiOff-4;checkforsustainedoutputJPSS14—7SS14一5JRNCSS14_4;...ifnot,leavefanoffSS14—6CALLFanON""otherwise,turnfanonJPSS14—4;,..andskipaheadSS14—3CALLFanOff;turncoolingfanoffSS14一4CALLCheckBatt;checkforbatteryJRSBatt,Flags2,SS14EXIT;,,.connected:continueJPMAIN2"..disconnected:startoverfromstate0SS14EXITJPExitMain,SS15MANUAL*;*Regulatecurrent.Novoltagelimit.Resetafter1hour.*『S15JRRPower,Flags2,SS15—2;poweroffindicatescompletedBurn-InCALLShowRate;turnonthe2Aor5ALED;NOTE:outputalreadyon,butTurnONsavescodespaceCALLTurnON;turnoutput^Fan,andChargingLEDon,IFCEQAdjOff;assemblenextlineonlyifdebuggingJRRBurnln,Flags3,SS150K;don'tregulateif加tB咖-in咖de.ENDCCALLIReg;regulatecurrentatselectedrate;CALLCheckl7v;checkfordisconnectedbattery;JT^NZSS150K;if17V,tbencontinue;LDICur6iitSS,ABORT;…othejrwis6,Abort;RESMamial,FlELgs3;...endManualMode;JPSS15EXIT;,.,andskiprestofState15SS150KJRSBurnln,Flags3,SS15BI;skipaheadifBum-inmode,IFCNEAdjOff;assemblenextlinesonlyifnotdebuggingRESMtrScale,Flags;setforAlternator0/oLEDoffRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffCALLShowMeter;updatemeterLEDs.ENDCJPSS15nnpdumptorampcheckSS15BIJRRMIN;ncFlag2,SS15b;skipaheadifnottimetoupdatecounterDECCCDcnt;decreasedisplaycountby1CALLIniTime2;resetTimer2LDIMins2,1;settimerforcounterinterval(1minute)SS15bLDA^CCDcnt;getlatestcountdownvalueLDLEDmim,A;storeinLEDimmCALLShowNum;displaycountondigitalLEDCALLMeterOff;turnoffallmetermodeLED'sSS15rmp.IFCEQAdjOff;assemblenextJinesonlyifdebuggingCALLCheckSw;checkifswitchisbeingpressedCALL(3dMeter;updatemeterLEDsJPSS15一1;skipnextthreelines,ENDC一CALLShowData;updatedisplayJRRRapidflags2,SS15一l;don'trampifRapidisnotsetCALL5hkRapid;updateRamptimer,ifnecessarySS15JIRR^[R,TicFlagl,SS15EXIT;coiitinueifnot迈axmanualchargetimeJRSBumln,Flags3,SS15一2;sldpaheadiffinishedBurn-InJPRESET".otherwise:resetSS15—2CAliDigitsOff;turnoff3-digitLEDCALLResetLEDs;tumoffalltype,rate&StatusLED'sCALLShowGreen;lightGreenLEDonlyCALLSetoff;resetPower&Crankingflags;setrain,duty.SS15EXITJPExitMain^BOOSTMODE*:Firstsetthechargeroffsetvaluefor2ampcharging,Next,"wait*:forthevoltagetostabilize'Thenwaitforthevoltagetodrop*:abouttwovolts.Whenthevoltagedrops,gofiillonfor5seconds,*:Afterfivesecondsofcranking,waitfor4minutesandstartover.*;CommenttheCALLandthefollowingtwoLDI'sfortest.Alsoloadoffset;:邻他PHASE15insteadofTHAZBOST*SS16.IFC£QDEBUG;assembenextlineonlyifdebuggingRESSwbff,SwDown;settocheckTypeandRateswitches.ENDCCALLVoltMtr;setforvoltmeterandupdatedisplayCALLCbeckBatt;makes"urebattis>1.6VIRRBatt,F!ags2,SS!6—1;skipaheadifnotconnectedJRSSEC,TicFlag2,BaSOK;skipif>2secondssinceBoostselectedJPSS16Exit;if<2seconds,thenstayoffSS16一1CALLTumO任;low&highpowerandfanoff,mindutyCALLShowRed;tumonAlertLEDJPSS16Exit;ifbatt<1.6V,thenstayoffBattOKCALLShowCrank;turnONCrankLED&turnAlertLEDoffCALLTuniON;turnoutput,F叫andChargingLEDonCALLSetHiOff;setformindutycycleSETStarted,Flags;setFlagsforchargestartedQALLIniTime2;resettimer2LDIMSecs2,MS200;setTimer2for200msINCCurentSS;setstateto17SS16ExitJPExitMain;gotoendofloop*DELAYFORVOLTREADING*SS17JRSMSEC,TicFlag2,SS17—1;Is200msupJPSS17EXIT;no,justre^irnSS17一1CALLGetMeter;updatedisplay<formula>formulaseeoriginaldocumentpage247</formula>LDLEDnum,A;storeinLEDnumCALLMeterN咖;showLEDoumandturnoffmetermodeLED'sJRRSEC,TicFl昭2,SS19EXIT;ifcrankingnotfinished,thenexitRESSCRs,DRBbuf;turnoffSCRs(inbuffer)CALLUpdatePB;updateportBfrombufferCAllResetStatus;turnoffChargingLEDRESCrnkng,Flags4;indicatefinishedcrankingRESPo邻er,Flags2;tdltimertoleavechargeroffINCCurentSS;justwaitfortimetoexpireCALLSetoff;turnoffpowerandsetformindutySETCrankWait,Flags;indicatescrankcool-downtimeCALLIniTimsl;resetTimer!LDISecsl,CCDint;settimerforcounterinterval(seconds)LDICCDcnt,CrankOff;setcrankcooldowncountertoCrankOffseesSS19EXITJPExitMain*INTER-CRANKDEIAY**Stayhereuntilthe4minutetimerhasexpiredthengobacktoBOOST,*ifswitchstillengaged,elsegoto2Aauto(default)*SS20CALLFanON;tumcoolingfanONJRRSEC,TicFlagl,SS20—0;skipaheadifnottimetoupdatecounterDECCCDcnt;decreasedisplaycountby1JRNZSS20—1;finislistate20ifcountdownto0RESCrank^ait,Flags;resetCrankWaitbitofFlagsLDICurentSS,010h;s改stateto16toCrankagainSETSEC,TicFlag2;tellState16thatE/SalreadyrunningJPSS20EXTT;andexitState20SS20—1CAlLIniTimel;resetTimerlLDISecsl,CCDint;settimerforcounterinterval(seconds)SS20一0LDA,CCDcnt;getlatestcountdownvalueLDLEDnum,A;storeinUEDnumCALLMeterNum;showLEDnumandturnoffmetermodeLED's;RESRmpng,Flags3;clearflagforCheckBattRESSettle,Flags3;clearflagforCheckBattCALLBlitikCrank;blinktheCrankLEDSS20EXITJPExitMainSUBROUTINESSTARTHERE*;*Initializestate(Slowcharge,Regularbatt,State0)InitStateCLRFags3;settoindicatenoRapidtoFastchangeCLRTEMP;initializeCLRCCDcnt;initialize鹏Disable,DRBbuf;enableoutput;SETChMoJe,Flags2;setforChargerMode(chargermode);RESESrly,DRBbuf;setE/Srelayforcharge(notboost)LDIOFFSET,HiOff-1;setformimimumoutputcurrentLDILowOff,OffRap;lhnitmaxratetofoU60AoffsetLDISwData,Ol111101b;MtializeswitchLEDsfor2八RegLDIVraax,Volts155;VmaxforRegularbatteriesLDVhCnt,001h;initializeVltCntto1LDIVRcnt,001h^initializeVRcntto1LDIPcntL,001h;initializePcntLto1LDIPcntH,001h;initializePcntHto1LDICurentSS,OOOli;setchargerstateto0LDISecsl,SecJnit;restartTIMERsecondcounterLDISecs2,SecInit;restartTMER2secondcounterRET*ResetWatchdogRegister**ThisroutinesimiplyresetstheWatchdogregister,RstWDRwas**onlytosaveprogramspace(LDIrequire3bytes,CALLrequiresonly2).RstWDRLDIWD民0FEH;resetwatchdogtimerRET*SetAbortState**ThisroutinesimiplysetsCurentSStoABORTsothatthecodewillgo'*totheAbortstateafterthenextNMLSetAbortwaswrittenonlyto**saveprogramspace(LDIrequire3bytes,CALLrequiresonly2).*SetAbortLDICurentSS,ABORT;setcurrentstatetoAbortRET*Set100Percent**ThisroutinesimipiysetsPercentto100.Setl00pwaswrittenonlyto:*saveprogramspace(LDIrequire3bytes,CALLrequiresonly2).*Setl00pLDIPercent,100;setPercentto100RET永GlsarPsrcent承*ThisroutinesimiplysetsPercentandDspPcntto0.ClrPcntwas**writtenonlytosaveprogramspace(CLRrequire3bytes,CALLrequires*only2).SetOpisthesecondhalfofClrPcnt.*Set0Percent*:Thisroutinesi边iplysetsPercentto0.SetOpwaswrittenonlyto51'saveprogramspace(JLDIrequire3bytes,dALLrequiresoi]iy2).ClrPcntCLRDspPcnt;setDisplayPercentto0SetOpLDIPercent,O;setPercentto0RET*UpdatePortA**ThisroutineupdatesPortAwiththecontentsoftheDRAbuffer.*UpdatePAwaswrittenonlytosaveprogramspace,*UpdatePALDA,DRAbuf;updateAccumulatorfrombufferLDDRA^A;updateportfromAccumulatorRET*UpdatePortB**ThisroutineupdatesPortBwiththecontentsoftheDKBbuffer.*UpdatePBwaswrittenonlytosaveprogramspace.*UpdatePBLDA^DRBbuf;邵dateAccumulatorfrombufferLDDRB,A;updateportfromAccumulatorRET*UpdatePortBOptions**ThisroutineupdatesthePortBoptionswiththecontentsoftheORB*buffer.UpdateORBwaswrittenonlytosaveprogramspace.*UpdateOEBLDA,OKBbuf;updateAccumulatorfrombufferLDORB,A;updateoptionsregister:froniAccumulatorRET*WaitaFifthSecond**Thisroutinecausestheprogramtowaitooefifthsecondbywaiting*for24interrupts.*FifthSecondCALLIniTimelLDIMSecsl,MS200;settimerfor1/5secondWFS—1WASCALLRstWDR;resetwatctidogtimerJRRMSEC,TicFIagl,WFS_l;waituntiltimergoesto0RET一SetRampUp**Thisroutinesetstheparametersnecessarytochangethedutyfromthe*举fastratetotherapidrate.ItisusedbeforeBum-InandAutomatic**Rapidcharge.**SetRamp**Thisroutinesetstheparametersnecessarytochangethedutybetween**thefastandrapidrates.ItisactuallythelastpartofSetRmpUp.*SetRmpUpLDIRmpCnt,RCinitF;setcounterforFast.RESUiPwr,Fkgs4;setforlowpowerSetRampLDITEMP,RIinit;120NMIinterruptsyields1.5secondsSETRmpInt,Flags3;counting1stoftwo180cycleperiodsRET*CHECKRAPID**Thisroutinedetermineswhethertoreduceorincreasethechargerate*fromRapidtoFastorvicaversa,ifnecessary.Itsetstheflags**usedbyRampOSappropriately.*ChkRapidJRRRapidjFlags2,ChkRapX;ifnotRapidchargerate,thenexitDECTEMP;otherwise,updateramptimerIRNZChekRapX;exitifnottimetoupdatecountLDITEMP,RIinit;count180morecycles(1.5sec)JRRRmpInt,Flags3,RmpCtr;skipaheadifjustcounted1sthalfRESRmplnt,Flags3"..otherwise,startcounting2ndhalfChekRapXJPChkRapX;…andexitRmpCtrSETRmpInt,Flags3;counting1stoftwo180cycleperiodsDECRmpCnt;checkiftimetorampJRNZChekRapX;exitifnottimetorampJRRHiPwr,Flags4,StRmpUp;skipaheadifchangingtohigherrateRESHiPwr,Fiags4;setfornot腿w(changetolowerrate)LDIRmpCnt^RCinitF"..otherwise,setforFastrate;LDIOFFSET,OfERamp;setforbetweenFast&RapidratesJPChkRapRStRmpUpSETHiPwr,Flags4;setflagsfor>FastrateLDIRmpCnt,RChiitR;setcounterforRapidrateChkRapRLDIOFFSET,OffRamp;setforbetweenFast<&RapidratesChkRapXRET*SHOWNUMBER**ThisroutinedetermineswhatthreedigitstodisplayonthedigitalLED'*torepresentthenumberstoredinLEDNum.Tiethreedigitswillbe**displayed加xttimetheShowDataroutineiscalled.*ShowNumCLRIndex;initializeLUTIndexto0CALLDigiOff;sdregistersforallsegmentsoffLDA,LEDnum;storeLBDnuminaccumulatorCPIA,IO;dieckforsingledigitnumberIRNCChkMaxNum;,,,ifnot,checkfor迈axnumberJPNextOOlotherwiseskipto3rddigitChkMaxNmn.IFCNBAdjOff;assemblenextlinesonlyifnotdebuggingCPIA,199;checkforhighestdisplayablenumberJRCCheckl00;ifless,checkvalueLDIAS199""otherwise,display199.ENDCCheckl00CPIA,100;clieckwhethertoshow咖stsignificant1JRCCheckOlO;ifnot,checkfor10RESDigitl,DigiDat2;otherwise,turnONmostsignificant1SUBIA,IOO;,"andsubtract100fromaccumulator.IFCEQAdjOff;assemblenextlinesonlyifdebuggingJPCheckl00;checkwhethernumberwasgreaterthan200,ENDCCheck010CPIA,IO;checkif<10JRCCheck001;...ifso,skipaheadanddieck3rddigitINCIndex;…otherwise,shownexthighervalueSUBIA,IO;…andsubtract10:fromAcumulatorJPCheck010;…andcheckfornexthighervalueCheckOOlLDIDRWR,Digits0xO,w;lookuptable(LUT)for2nddigitLDIX,Digits0x0.d;initializeLUTLDATemp,A;saveAccumulatorLDA,Index;getindexfromstartofLUTANDIA,03Fh;IimittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAAND人DigiDat2;…setbitsinAforseconddigitLDDigiDat2,A;…storeAintoDigiDat2LDA5ATemp;restoreAccumulatortoremainderofLEDnumNextOOlLDIDRWR,Digits00x,w;lookuptable(LUT)for3rddigitLDIX,DigitsOOx.d;initializeLUTANDIA,03Fli;limittowindowADD入X;addbaseaddressoftableLDX,A;storeaddressofvalueinXIvDA,(X);storevalueatXintoAANDA3DigiDatl;...setbitsinAforsegmentsLDDigiDatl,A;.'.storeAintoDigiDatlRETGETVOLTDIGITS*;*Thisroutinedetermineswhatthreedigitstodisplayonthedigital*;*LEDtorepresentthebatteryvoltage(^ADhi).Ge飼tsDECVltCnt;decrementintervalcounterJRZNe邻Volt;if0,readytoupdatedisplayJPGetVexit;.,.otherwise,justexitNewVotLDIVltCnt,MS500;re-initializeintervalcounterJRRCfaMode,Fiags2,GVT;ifTestermode,useFreshBVLDA,BADhi;getlatestavgbattvoltageJPGV10GVTLD入FreshBV";GetlatestaveragebatteryvoltageGV10CALLDjgiOff;setregistersforallsegmentsoffCLRIndex;initializeLUTIndexto0CPIA,MaxVolts;checkformaxvoltreadingJRCGV17;skipaheadiflessthanmaxLDIDigiDatl,DigiMVl;setfordigit1ofmaxvoltdisplayLDIDigiDat2,DigiMV2;setfordigit2ofmaxvoltdisplayJPGetVexit;exitGetVoltsGV17CPIA'Volts10;cheekfor雨JRCChecklV;ifnot10VthenskipaheadRESDigitl,DigiDat2;otherwise,turnONmostsignificant1SUBIA>Volts10;.,,andsubtract10VfromaccumulatorChecklVCPIA,VoltsOl;chedcif>l,O"VJRCCtieck01V;…ifso,skipaheadandcheck3rddigkINCIndexotherwise,sho"WnexthighervalueSUBIA,Volts01;...andsubtract1,0VfromaccumulatorJPChecklV;".andcheckfornexthighervalueCheck01VLDATemp,A;saveAccumulatorLMDRWR,DigitsQxO.w;lookuptable(LUT)for2nddigitLDIX,Digits0x0.d;initializeLUTLDA,Index;getindexfromstartofLUTANDIA,03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAANDA力igiDat2;…setbitsinAforbottomsegmentsLDDigiDat2,A;…storeAintoDigiDat2LDA^Temp;restoreAccumulatortoremainderofLEDn咖ShowVOOlLDIDRWR,DigitsOVx.w;lookuptable(LUT)for3rdvoltsdigitLDIX,Dig歸Vx,d;initializeLUTANDIA,03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoAANDA,DigiDatl;".setbitsinAforbottomsegmentsLDDigiDatl,A;,"storeAintoDigiDatlRESDecimal,DigiDatl;turaONdecimalpointGetV战itRETVoltMeter*:Thisroutinesetsthedisplaytoshowvolts'thencallsSliow^Teterand:ShowDatatoupdatethedisplaywiththecurrentbatteryvoltage.*GetMeter*ThisroutinecallsShowMeterandShowDatatodisplaythelatest*voltageorpercentage(determinedbyMtrScale&liltrUnits)onthe*3-digitLEDdisplay.detMeteris也elastsectionofVoJtMtr.*Vol餘RESMtrScale,Flags;setforAlternator%LEDoffRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffGetMeterCALLShowMeter;updatemeterLEDsCALLShowData;updatedisplayRET*GETPERCENT**Thisroutinedetermineswhatvaluetouseforthepercentageof**chargebeforethechargestatehasreachedthedv/dtstate.The**percentiscalculatedbyreadingthebatteryvoltage(BADhi)and*performingthefollowingcalculations:**AsTester**1.0V<BADhi<11.6VDC=>Percent-(BADhi/16)+1**11,61V<BADhi<12.8VDC=>Percent-(BADhi-175)*5+15*12,80V<BADhi=>Percent-100**AsCharger**lVolt<BADhi<12Volts^=>(BADhi/4)+15-Percent**12Volts<BADhi<dv/dt=>(BADhi/2)-30-Percent*GetPercentJRRChMode,Flags2,TstrBP;jumptoTester%ifnotchargingIRSRestore,Flags4,GPend;don'tget%inRestoremodeLDA,CurentSS;getcun"entprogramstateCPIA,11;haschargingreacheddV/dtIRCCalcPrcnt;…ifnot,calculatepercentageGPendJPGetPctEnd;...otherwise,donothingCalcPrcntLDA,Percent;getPercentCPIA,76;checkforhighestcalculated0/0JKNCGPend;exitifalreadythereJRSHiPw,Flags4'GPend;exitifinHighPowermodeLDA,RmpCnt;getRampintervalcounter;NOTE:RmpCntwillbe0ifnotsettorampatallCPI入5;isitalmosttimetorampupJRNCGPend;don'tupdate%untilendoflowpowerintervalCALLGe氾att;getlatestvoltage&doubleif6VmodeCPIA,Volts12;isthebatteryvoltagelessthan12VJENCFonnula2;…No,gotoForamla2CPIA,Vo醒;Isbattery>1JRNGGPfoiml;...ifso,skip加xUi加JPGPz咖;…if加t,setforzero%GPfonnlCALLDivide4;…Yes,usefirstformulaADDIA,15;Addl5and..,JPGetPcffixitstoreintoAFormula2CALLDivide2;Divideby2andSUBIA,30""subtract30JPGetPctExit;skipaheadandfinishroutineTstrBPLDA,FreshBV;getlatest(avg)batteryvo〗tageCALLDouble6V;doubleBatteryvoltageifsetfor6VCPI入Voltsl28;Isbattery>12.8VJRCTstrlOO;...ifnotskipaheadCALLSe麵p;."otherwise,Percent100JPGetPctEnd;,..andendroutineTstrlOOCPIA3attMin;Isbattery>BattMinJRNCTstrBPhi;…ifso,jumpaheadCPIA,VoltsOl;Isbattery>1JRNCTstrBPmed;…ifso,jumpaheadGPzeroCALLSet0potherwisesetPercentto0JPGetPctEiid;..,andendroutineTstrBPhiSUBIA,BattMin;subtractminimumhighvoltageCALLATknes5;咖,yby5ADDIA,15;addl5JPGetPctExit;...storeintoATstrBPmedSUBIAJ5;A-battery-15CALLDivide4;A=(battery-15)/4CALLDivide4;A-(battery-15)/l6INCA;A=(batey-15)/16+1GetPctExitLDPercent^;storeintoPercentGetPctEndRET;*UPDATEBATTERYPERCENT*;*Thisroutinecontrolshowthebatterypercentagedisplayedisupdated.;*UpdateBPensuresthatundernormalcircumstances,thebattery%dis-;*playedisupdatedaccordingtothefollowingtworules.*;*.The%displayeddoesn'tchangebymorethan1%atatime*;*2.The。/。displayedisnotupdatedtwicein<PChitseconds*Thereareafewexceptions.*;*1,The0/odisplayedcanjumpupmorethan1ifitwas0*;*2,The%displayedwilldropto0immediatelyfordisconnectedbatt.**3.The%displayedcanchangebymorethaii1ifthescale**changes:*承***Scalereferstothe%scale,whichiseitherbatteryoralternator*UpdateBPli>A^Percent;checkwhether%is0JRNZUBPO;...ifnot,waitforupdateintervalJPUBPfinish;…otherwisefinishroutineUBPOLDA,DspPcnt;getlast%displayedJRZUB勵;GontinueifO%JPUBPI;skipaheadifnot0%UBPOOJRSMtrScale,Flags,UBPl;alsoskipaheadifAlternator%JRSWait0P,Fiags2,UBPz;skipaheadifWakOPflagalreadysetSETWaitOP,Fkgs2;…otherwise,setflagtowaitCALLIniTime2;ioitiaiizeThner2LDISecs2,3;setTimer2for3secondsJRRChMode,Flags2,UBPz;skipaheadifintestermodeLDISecs2,5;setTimer2for5secondsinchargermodeUBPzJRRSEC,TicFlag2,UBPx;skipaheadifstillwaitingUBPOaRESWaitOP,Flags2;setflagtoindicatenotwaitingLDAJPercent"..otherwise,get加w%JPUBPfinish;,..anddon'twaittodisplayitJPUBPexit;...aadjustexitDECPcntL;decrement%interruptcounterJRNZUBPx;ifnot0thenjustexitLDIPcntL,MSINIT;re-initialize%interuptcounterDECPcntH;decrementintervalcounterJRNZUBPx;ifnotdownto0,thenjustexitLDIPcntHJPGint;re-initializs%intervalcounterLDA^DspPcnt;getlast%displayedJRNZUBP2;skipaheadifnot0%LDA,Percent;getnew%JPUBPfinish;andfinishroutineUB2CPA,Percent;compareto加west%JRZ^JBPexit;ifequal,donothingJRCIncBP;ifless,increasedisplay%by1JRSChMode,Flags2,UBPexit;don'tdecrease%ifchargingDECA"..otherwise,decrease%by1JPUBPfinishandfinishIncBPINCA;increasedisplay%by1UBPfbishLDDspPcmt,A;storeupdateddisplay%UBPexitRET;*MeterNum;*ThisroutinecallsMeterOff,ShowNum,andShowDatatoturnoffthe*;*displaymodeLED'sanddisplayLEDnumonthe3-digitLEDdisplay.*,**;*NumData*;*ThisroutinecallsShowNumandShowDatatodisplayLEDnumonthe*;*3-digitLEDdisplay.NumDataisthelastsectionofMeterNum,*MeterNhmCALLMeterO任;turnoffallmetermodeLED'sNumDataCALLShowNum;getdatatoshowthenumberCALLShowData;showthenumberRET;*SHOWDATA*;*ThisroutineupdatesthedigitalLEDand6switchLEDscontrolledby;*也eserialtoparallelshiftregisters.ItsendsthebitsofSwData*;*andDigiDatatotheregistersbitbybitfromLSBtoMSBusing*,*SerData.Aftereachbitissent,ShftClkistoggledtoshiftthebit*;*tothenextposition.Afterall24bitshavebeensent^LtchClkis**usedtoup5atetheoutputs,whichupdatestheLEDs'*ShowDataCALLRstWDR;resetwatchdogtimer;RESClrData,DRAbuf;clearshiftregister;CALLUpdatePA;updateportAfrombuffer;SETClrData,DRAbuf;preparetoacceptdata;CALLUpdatePA;updateportAfrombufferIX>IBitCnt,008h;initializebitcounterto8LDIBytCnt,003h;initializiebytecounterto3LDA,DigiDatl;getfirst8bitsofdigitdataGetBitRLCA;sendMSBofAcumulatortoCarryJRCSetBit;ifCarry=lthendatabitis1RESSerData,DRAbuf;…otherwisesetSerDatato0JPSendBit;skdpaheadtoSendBitSetBitSETSerData,DRAbuf;setSerDatato1SendBitLDDataBuf,A;storeshifteddatafromACALLUpdatePA;updateportAfrombufferRESShftClk,DRBbuf;setShiftClocklowRESLtchClk,DRBbuf;setLatchClocklowCALLUpdatePB;updateportBfrombufferSETShftCUgDRBbuf;setShiftClockhighCALLUpdatePB;updateportBfrombufferDECBitCnt;updatebitcountJRZNextData;ifallbitssentthenskipaheadLDA,DataBuf;storeshifteddatabackinAJPGetBit;otherwise,getnextbitNextDataDECBytCnt;updatebytecountJRNZNextByte;getnextbyteiscountisnot0JPLatchData"..otherwise,donesendingbitsNextByteLDIBitCnt,08h;setbitcoimtfor8morebitsLDA,BytCnt;whichbyteisnextCPIA,02h;checkfor2ndbyteisnextJRZScndByte;skipaheadifequalLD入SwData;get8bitsofswitehLEDdataJPGetBit;sendbitsofsecondbyteSondByteLDA,Digat2;getlast8bitsofdigitdataJPGe氾it;sendbitsofse咖dbyteLatchDataSETLtohCIfe;DRBbuf;updateiatehesCALLUpdatePB;updateportBfrombufferRETShowMeter*;*ThisroutinesetsthedigitalLEDtoshoweitherthecurrentvoltage*;*orlastpercentbasedonFlagsandCurentSS.DuringEnginestart,it*;*willcountdownsecondsofeitherremainingcranktimeorcooldowntime.*ShowMeterJRSAlert,Flags2,SMeXit;exitifabortmodeJRSMtrUnits,Fkgs,GetPrcnt;skipaheadandsetfor%CALLGetVolts"..otherwise,getvoltsJRSChMode,Flags2,SMl;skipaheadifnotinTestermodeCALLShowStatus;…othenvise,updateStatusLEDsSMIJPShowMtrX;…andskiptoendorroutineGetPrcntJKRChMode,Flags2,TstMtr;ifintestermode,get%JPSho"wPrcnt;..,otiierwise,skipahead&show%ShowOCALLSetOp;settoshow0%ShoPerJPShowPrcnt;andskipaheadTstMtrLDA,FreshBV;getlatestBatteryvoltageJRZSIaowO;if0V,show0%JRRMtrScale,Flags,ShoPer;showBattery%ifnotsetforAlt%CALLDouble6V;doubleBatteryvoltageifsetfor6VCPIA,AltMin;checkfor<1stLUTvalueJRCShowO;ifso,show0%CPIA,AltMax;checkfor>lastLUTvalueJRCAltVal;ifnot,skipaheadandcheckLUTLDIPercent,199otherwise,settomaxvalueJPShowPrcnt;andskipaheadAltValLDIDRWR,AltLvls.w;LUTforalternator%LDIX,AltLvls.d;initializeLUTSUBIA,AltMin;diffenceisindexiniookuptableANDI乂03Fh;UmittowiMowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoALDPercentjA;storevalueintoPercentShowPrcntCALLShowPercent;otherwise,showpercentageCALLShcwStatus;turnonappropriatestatusL£DShowMtrXCALLShoMtrMode;tumonappropriatemeterLEDSMeXitCALLRstWDR;resetwatchdogtimerRET*SHOWMETERMODE**ThisroutineturnsononeofthemeteruniteLED'sbasedonFhgsand**Flags2,IftheunitisinTesterMode(ChModeK)),theroutinewill**alsolighttheappropriatestatusLEDbasedcmthevoltageatthe*承clamps,*ShoMtrModeSETLEDvoit,DRAbuf;turaoffDCVoltageLEDSETLEDprcnt,DRAbuf;turaoffBatteiy%LEDSETLEDalt,DRAbuf;turaoffAlternator%LEDShowVoltsJRSMtrUnits,Flags,ShoPrcnt;gotoShoPrcntifs改RESLEDvoIt,DRAbuf;tumonVoltageLEDJPShowMMXShoPrcntJRSMtrScale,Flags,ShowAlt;gotoShowAltifsetRESLEDprcnt,DRAbuf;tanonBattery%LEDJPShowMMXShowAltRESLEDalt,DRAbuf;tumonAlternator%LEDShowMMXCALLUpdatePA;updateportAfrombufferRET*HoldMeterModeLED(dependingonmode)**ThisroutineturnsontheBattery%,VoltsDC,orAlternator^LEDbased*onFlags&Flags2andkeepsthatLEDonforonefi他second,*Ho画trMdCALLShoMtrMode;tumonMeterModeLEDCAULFifthSecond;waitonefifthsecondRET*SHOWSTATUS**ThisroutineturnsononeofthethreestatusLED'sbasedonthe*batteryvoltage.Thisroutineisforuseinthetestermode.*SliowStatusJRSChMode,Flags2,ShoStatX;exitifnotTester迈odeJRRBatt,Fiags2,RedStat;siiowredLEDifnobatteryJRRMtrUnits,Flags,ClrStat;turno任StatusLED'sifvoltsmodeLDA,FreshBV;getlatestBatteryvoltageJRSMtrScale,Flags,TestAlt;skipah的difsetforAlternatorLDA,DspPcnt;getlast0/oAispkyedCPIA,IOO;IsiU00%JRZGxnBatt;…ifso5showgreenLEDCALLResetStatusotherwise,turnStatusLED'soffJPShoStatX;...andskiptoendGrnBattCALLShowGreeii;turnonGreenLEDJPShoStatX;skiptoendTestAitCALLDouble6V;doubleBatteryvoltageifsetfor6VCPIA,Voltsl5a;Isalternatoratleast15.07VJRNCRedStat;…ifso,skipaheadandshowredCPIA,Volts138;isalternatoratleast13.80VJRCRedStat;,.,ifnot,skipaheadandshowredCPIA,Volts14;Isalternator<14,0VJRCClrStat;".ifso>skipaheadandshowyellowCPIA,Volts149力alternatoratleast14.87VJRNCClrStat;…ifso,skipaheadandshowyellowCALLShowGreen"..otherwiseturnonGreenLEDJPShoStatX;…andskiptoendRedStatCALLShowRed;turnonRedLEDJPShoStatX;skiptoendClrStatCALLResetStatus;turnStatusLED'soffShoStatXRET*METEROFF=*=*ThisroutineturnsoffthethreemetermodeLED's.MeterOffSETLEDvolt,DRAbuf;turnoffDCVoltageLEDSETLEDprcnt,DRAbuf;tumoffBattery%LEDSETLEDalt^RAbuf;turaoffAlternator%LEDCALLUpdatePA;updateportAfrombufferRET*DigiOff**Thisroutinesettheregisterstoturnoffthethree-digitLED,申DigiOffLDIDigiDatl,DigiOffa;turnoff8of16digitalsegmentsLDJDigiDat2,DigiOffb;turnoffother8of16digitalsegmentsRET*DIGITSOFF**Thisroutineturnsoffthethree-digitLED.DigitsOffCALLDigiOff;setregistersforallsegmentsoffCALLShowData;updatedisplayRET*DIGITSON**TtisroutineturnsONallsegmentsofthethree-digitLED.DigitsONLDIDigiDatl,DigiONa;turnON8of16digitalsegmentsLDIDigiDat2,DigiONb;tumONother8of16digitalsegmentsCALLShowData;updatedisplayRET*SHOWPERCENT**ThisroutineturnsONtheBattery%LED.SbowPercentSETMtrUnits,Flags;setFlagsfor%(notvolts)IRRWaitOP,Fkgs2,SPl;skipaheadifnotwaitingfrom0LDIDigiDatl,Dasheslotherwise,showdasheswhilewaitingLDIDigiDat2,Dashes2"..otherwise,showdasheswhilewaitingJPShowPxLDA^DspPcnt;getPercentvaluetodisplay.IFCEQAdjOff;assemblenextlineonlyifdebuggingLDA,^ADhi;settodisplaylatestbatt.volt,.ENDCIRRMtrScale^Fkgs,SP2;don'tuseDisplay%forAlteraator%LDAJPercent;,.'useactualPercentfordisplay-IFCEQShoOff;assemblenextlineonlyifdebuggingIRRChMode,Flags2,SP2;skipahead**DEBUG**LDA^OFFSET;diplayOFFSET**DEBUG**.ENDCSP2LDLEDnum,A;...andstoreitinAccumulatorCALLShowNum;setdigitalLEDforLEDnumSETDecimal,DigiDatI;tumOFFdecimalpointShowPxRET*RESETLEDS**ThisroutineturnsofftheType,Rate,andStatusLED'sResetLEDsCALLResetStatus;turnoffallthreestatusLEDsClrLEDsLDISwData,SwsOff;tumoffTypeandRateLED言sRET*ResetStatus**ThisroutineturnsofftheLED'sintheStatusarea.ResetSta加sSETLEDchgng,DRAbuf;tumoffChargingLEDSETLEDdone,DRAbuf;tunioffChangedLEDSETLEDalert,DRAbuf;tumoffFault(red)LEDRET*BLINKChargingLED**ThisroutineblinkstheChargingLEDatarateofoncepersecond.BlnkChrgLDA,MSecsl;getMSecscountCPIA'MS500;testfor>1/2secJKNGBIinkCM;ifso,skipaheadCALLResetStatus"..otherwise,turnoffstatusLEDsJPBlinkChX;.andexitroutineBlinkCMCALLShowChgng;TumonChargingLEDBlinkChXRETShowCharging*:ThisroutineturnstheChargingLEDonandtherestoff.*ShowYellow*:ThisroutineturnstheChargingLEDonanddoesnotaffecttheCheck*:andChargedLEDs.ShowfellowisactuallythelastpartofShowChgng:ShowChgngCALLResetStatus;turaoffallStatusLEDsSho邻YellowRESLEDchgng,DRAbuf;turnONChargingLEDCALLUpdatePA;updateportAfrombufferRET*BLINKAlertLED**ThisroutineblinkstheAlertLEDatarateofoncepersecond.BlinkAIertLDA,MSecsl;getMSecscountCPIA,MS500;testfor1/2secJENCBkikAlrt;ifso,skipaheadCALLResetLEDs"..otherwise,turnoffallLEDsJRSBurnln'Flags3,BBI;skipaheadifnotBum-InCALLDigitsON;...turnonalldigitalLEDsegmentsJPBAeXit;…andexitroutineBBICALLNumData;getdatefor,andshowLEDnumberJPBAeXit;...andexitroutineBbkAlrtCALLAlertON;TurnonAlertLEDCALLDigitsOff;Tumoff3-digitLEDBAeXitRET;*AlertLEDON*;*ThisroutineturnsontheAlert(red)LEDandturnstheothermeter**LEDsoff.NOTE:itdoesnotaffecttheRateandTypeLEDs.*AlertONCALLMeterOff;TurnoffMeterModeLEDsShowRedCALLResetStatus;TumoffStatusLBDsRESLEDalerymAbuf;T咖onAlertLEDCALLUpdatePA;updateportAfrombufferRETShowDoneLED**ThisroutineturnsontheDone(green)LEDandturnsalltheother*LEDsoff.NOTE:itturnsofftheRateandTypeLEDs.*ShowDoneCALLResetLEDs;TumoffallLEDsLDISwData,S柳Off;setType&RateLED'soffCALLShowType;showBatteryType&updatedisplayShowGreenCALLResetStatus;turnoffallthreestatusLEDsRESLEDdone,DRAbuf;TurnonDoneLEDCALLUpdatePA;updateportAfrombufferRET;*BLINKCrankLED*;*ThisroutineblinkstheCrankLEDatarateofoncepersecond.BlinkCrankLDA,MSecs2;getMSecscountCPIA,MS500;testfor>1/2secIRNCBlinkES;ifso,skipaheadSETLEDboost,SwData"..otherwise,tumoffCrankLEDJPBCeXit;...andexitroutineBl磁SCALLShowCrank;turnonCrankLEDBCeXitRET*SkwCrank**ThisroutineturnstheEngineStart(Crank/Boost)LEDonandturns:*theTypeandotherRateLEDsoff.**NOTE:The6VLEDwillbeleftonifappropriate.*ShowCrankCALLOrLEDs;tumoffallRate&TypeLEDsJRRBat6VJFlags2,ShoES;skipaheadifnot6VRESLED6V,SwData;tumonRegular6VLEDShoESRESLEDboost,SwData;tumONCrankLEDCALLShowData;updatedisplayRET*SetSlow**ThisroutinesetsthechargerfortheSlowratebysettingtheappro-*priateflags,*SetSlowRESRate,Flags;tumonSlowLEDRESRapid,Flags2;turno任RapidLEDRETSetSlow*ThisroutinesetstheOFFSETforthecorrect(12or6V)Slowrate.StartSlowLDIOFFSET,OffSlow;setOffsetfor2AJRRBat6V,Flags2,StrtSloX;skipifnotsetfor6VmodeLDIOFFSET,OfiKSlo;...otherwise,adjustOFFSETStrtSloXRET*SetMinOff**ThisroutinesetstheOFFSETforthecorrect(12or6V)maximumSlow:*rate(minimumOFFSET).*SetMinOffLDILowOff,MinOffSlo;limitoutputtomax2AcurrentJRRBat6V,Flags2,SetMOx;skipnextlineifnot6VmodeLDILowOff,Min60ffSlo;limitoutputtomax6V2acuirentSetMOxRET*SetMinFst*:*ThisroutinesetstheOFFSETforthecorrect(12or6V)maximumFast*rate(minimumOFFSET).*SetMinFstLWLowOff,MinOiFst;KmitoutputtomaxFastcurrentJRRBat6V,Flags2,SetMFx;skipnextlineifnot6VmodeLDILowOff,Min60fFst;limitoutputtomax6VFastcurrentSeiMFxRETShowChargeRateLED(dependingonmode)**ThisroutineturnsontheSlow,Fast,orRapidLED,basedonFlags.Sho邻RateSETLEDboost,SwData;tumoffBoostLEDSETLEDrap,SwData;加moffRapidLEDSETLEDfast,SwData;tumoffFastLEDSETLHDslow,SwData;tumoffSlowLEDJRRChMode,Flags2,ShoRateX;exitifinTesterModeShowRapIRRRapid,Flags2,ShowSlow;gotoShowSlowifnotRapidRESLEDrap,SwData;turnonRapidLEDJPShoRateXJRSRate,Flags,ShowFast;gotoShowFastifsetRESLEDsbw,SwData;turnonSlowLEDJPShoRateXSticwFastRESLEDfast,SwData;turnonFastLEDShoRateXRETSetl2V*:Thisroutinesetsthechargerforthe12VRegularbatterytypeby*;resetting&e6V,AGM/Gel,andDeepCycleflags,*:SetReg承:ThisroutinesetsthechargerfortheRegularbatterytypebyreset-*:tingtheDeepCycleandAGM/Gelflags.SetRegisactuallypartof:Setl2V"*Setl2VRESBat6V,Flags2;turnoff6VLEDSetRegRESBatTypeA,Flags;turaonRegularLEDRESBatTypeB,Flags;tumoffGel/AGMLEDRET*ShowChargeTypeLED(dependingonmode)*:*ThisroutineturnsoneithertheRegu〗ar,DeepCycle,Gel/AGM,or6V*LEDbasedonFlags.TheroutnealsosetsVmaxtomatch.*ShowTypeSETLEDreg,SwData;setRegularLEDtooffSETLEDdeep,S"wData;setDeepCycleLEDtooffSETLEDgd,SwData;setGd/AGMLEDtooffSETLED6V,SwData;set6VLEDtooffJRRBat6V,Fkgs2,ShowTl;skipaheadifnot6VRESLED6V,SwData;tornonRegular6VLEDJPShowT2a;setV迈axforregular(15.5V)ShowTlJRRBatTypeB,Flags,SkwT2;skipaheadifnotGel/AGMRESLEDgd,SwData;tarnonGel/AGMLEDLDIVmax,Volts144;Vmax=14.4VforGel/AGMMODEJPShoTypeXShowT2JRSBatTypeA,Flags,ShowT3;gotoShowT3ifsetRESLEDreg,SwData;turnonRegularLEDShowT2aLDIVmax,Vots155;Vmax-15.5VforRegularMODEJPShoTypeXShowT3RESLEDde邻,SwData;tumonDeepCycleLEDLDIVmax^Vote16;Vmax=16VforDe邻CyclebatteryShoTypeXRET*HoldChargeTypeLED(dependingonmode)**ThisroutineturnsontheRegular,DeepCycle,orGel/AGMLEDbasedon:*FlagsandkeepsitonforerneF跑second.HoldTypeCALLShowType;turnonBatteryTypeLEDCALLShowData;updatedisplayCALLFi他Second;waitoneFifthsecondRET*HoldChargeRateLED(dependingonmode)**ThisroutineturnsontheSlow,Fast,orRapidLEDbasedonFlagsand*keepsitonforoneFifthsecond.HoldRateCALLShowRate;tononChargeRateLEDCALLNumData;getdatafor,andshownominalrate(amps)CALLFifihSecond;waitoneFifthsecondRET*CheckHighOffset**ThisroutineisusedtocheckwhetherthelatestOFFSETisequaltothe**maximumvalue,HiOff.WhenOFFSET=HiOff,thechargerateis0,*ChkHiOffLDA,OFFSET;getcurrentOFFSETJRSBat6V,Flags2,CH06;skipnextlineifnot6VmodeCPIA,HiOff-2;hasOFFSETreachedmaximum(outputo均?IPCHOxCH06CPIA,HiOff6-2;hasOFFSETreachedmaxfor6V(outputoff)CHOxRET*CheckOV45*Thisroutinechecksthelatestrunningaverageofthebatteryvoltage,*andsetstheCarrybitifit'slessthanVoltsO+1DACcount.This**routineisusedtocheckwhetherabatteryisconnected,*Chec證CheckBa忧SETBatt,Flags2;setflagforconnectedbatteiy;LDA,FreshBV;testlatestaveragevoltageLDIAjVolts(H1;check比higherthanzeroJRRCmkng,Flags4,ChkBat;sldpnextlineifnotcrankingLDIA,1;checkfortrue0ifcrankingC腿atCPA,FreshBV;testlatestaveragevoltageJRNCNoBa汰;Ifnot>0,battery加tconnectedIPChkBattX;,..otlierwise,justexitNoBattRESBatt^P"kgs2;setforbatteiynotconnectedCALLShowRed;tumonAlert(Red)LEDCALLChPcnt;clearPercentandDisplayPercentCLRBADhi;dearpreviousvoltagereadingCLRFreshBV";dearpreviousvottagereadingChkBattXRET*GetBatteryVoltage**ThisroutinegetsthebatteryvoltagestoredinBADhiandsaveditin**theaccumulator.Italsodoublest&eresultifsetfor6Vbattery.****Double6V**Thisroutinedoublestheaccimmlator,A,iftheBat6Vflagisset.This,*routineiscaltedbeforetheaccumulatoriscomparedtooneofthe**constantsoriginallyassignedfor12vbatteries.*承承*NOTE:IftheBat6Vflagisset,andtheaccumulatoris>8.5V,the*;Hi6VFlagissetinstetadofdoublingA.GetBattLDA,BADhi;getlatest(ayg)batteiyvoltageDouble6VJRRBat6V,Flags2,D6VX;skipaheadifnotsetfor6VJRRHi6V,Flags3,D6V;doubleif6VBatt<8.5VLDIA,MaxVoks"..otherwise,setAtoMaxVote;JRRChMode,Fiags2,D6VX;checkforChargeorTestmode;CALLSetAbort;…setforAbortstateifChargemode;SETAlert,Flags2;...setAlertFlagJPD6VX;..,andskiptoendofroutineD6VSLAA;doubleAD6VXRETCheckProgress*Thisroutineisusedtoensurethatthechargerwillabortifthe**batteryvoltagedoesnotincreasethroughoutthecharge.Itchecksthe*voltageeveryCPintminutesforameasurableincreasesincethe**previouscheck.Ifthereisn'仁thechargeisaborted.*ChkProg'JRRMIN,TicF〗agl,ChkProgX;exitifnottimetocheckforprogressChkProgOIRRSOC,SwDown,ChkProgl;skipaheadifnotStartOfChargeRESSOC,SwDo戰"..otherwise,clearSOCflagCALLIniTimel;initializeTimerlLDIMinsl,5;…setTimerlfor5minutesCLRLastBatt;clearLastBatt(ensurepass1sttest)JPChkProgX;...andexit;ChkProglLDAjBADhi;getlatestbatteiyreadingSUBIA,l;subtractonecountCPAjLastBatt;checkforincreaseJRCChkProgA;settoabortifnoincreaseLDA,BADhi;setAbacktoBADMLDLastBatt,A;updateLastBattCALLIniTimel;initiaHzeTimerl.EFCNEFastCP;assemblenextlineonlyifnotdebuggingLDIMins1,CPint;setTimerlfor60i^iimites.ELSE;assemblenextlineonlyifdebuggingLDIMinsl,3;setTimerlfor3mins.ENDCDECCCDcnt;updateintervalcountJRNZChkProgX'justexitifnotzeroSET眠TicFlagl;ifzero,setfortimeexpiredChkProgACALLSetAbort;settostartAbortmodeChkProgXRET*BatteryProgress**ThisroutineisusedtoensurethatChkProgandCheckBattarecalled**onlywhenthechargerateisabouttorampuporisn'tsettorampat**all.Thatway,thebatteryvoltageusedtocheckchargingprogress**won'tbeaffectedbythehighercurrentBattProgworksbychecking**RmpCnttomakesureit'slessthan5.Ifthestartofchargeflag(SOC)**isset,BattProgdoesnotcheckRmpCnt.*BattProgJRRRmpng,Flags3,BtPrgO;skipaheadifnotRapid->FasttransitionCALLRampOS;otherwise,graduallyreducedutycycleBtPrgOCLRA;setAto0toensure<(9,12,or14.2V)JRSHiPwr,Flags4,BtPrgX;exitifhighpowermodeJRSSOC3SwDown,BtPrg2;skipaheadifStartOfCharge<formula>formulaseeoriginaldocumentpage269</formula>200680025856,8说明书第267/354页,IFCEQDEBUG;assemblenextlineonlyifdebugging;JRRSwOff,SwDovm,SkpSw;skipRateandTypeswithifSwOffisset;JPChkSwRET;Otherwise,justexitJRSSwOff,SwDowo^ChkSwX;skipRateandTypeswithifSwOffisset;SkpSw.ENDCJRRRateSw,DRC,RateDown;Ifswitchisbeingpressed,skipaheadRESRateSw,SwDown;setforRateswitchnotpressed(up)ChekTypeJPChkType;Rateswitchnotpressed,socheckTypeRateDownRESIdle,Flags3;setfornotMeJRSRateSw,SwDown,CliekType;Ifswitchwasn'treleased,don'tcheckitSETRateSw,SwDown;setforRateswitchpressed(down)ChkCM.IFCEQAdjOff;assemblenextlinesonlyifdebuggingJRRManual,Flags3,ManRate;debugonlyinmanualmodeINCOFFSET;increaseOFFSET(decreaseoutput)JPChkSwRET;exitCheckSwitchroutine.ENDCManRateIRRCrankjFlags,ChkSkw;ifnotsetforCrank,checkforSlowCALLTurnOff;low&highpowerandfanoff,mindutyRESChMode,Flags2;setforTester(notCharger)ModeSETDisable,DRBbuf;disableoutputifRatewasBoostJPModeChange;gotoendofQieckSwChkSlowIRSChMode,FIags2,ChkFast;skipaheadifalreadyCharger迈odeSETChMode,Flags2;setforCharger(nottester)ModeRESDisable力RBbuf;enableoutputafterRateispressedRESMtrScale,Flags;setforBatt%(notAlt%)whennottesterRESRate,Flags;wasCrankysosetforSlowJPModeChange;gotoendofCheckSwChkFast;ifsetforSlow,thensettoFastJRSRate,Flags,ChkRap;IfnotSlow,thenmustbeFastSETRate,Flags;setChargerateforFastJPModeChange;gotoendofCheckSwChkRap;ifsetforFast,thenchangetoRapidJRSRapid,Flags2,ChkES;IfnotRapid,thenmustbeFastSETRapid,Flags2;setChargerateforRapidJPModeChange;gotoendofCheckSwChkES;wassettoRapid,changetoBoostCALLSetSlow;setforSlowRateSETCrank,Flags;setChargerateforBoost;CALLSetReg;setbatterytypeforRegularCALLShowCrank;tumONCrankLEDCALLTumOff;Iow&highpowerandfanoff,mindutyLDICurentSS,CrankSS;setChargestatetoCrankCAIXIniTime2;resettimer2LDISecs2,003h;setTimer2for3secondsJPChkSwRETChkType;ifGel/AGM,也ensetforRegularIRRTypeSw,DRC,TypeDown;IfSwitchisbeingpressed,skipaheadRESTypeSw,SwDown;setforTypeswitchnotpressed(up)ChkSwXJPChkSwRET;Typeswitchnotpressed,soexitCheckSwTypeDownRESIdle,Flags3;setfornotidleJRSTypeSw,SwDown,ChJkSwX;IfSwitchwasn'treleased,don'tcheckitSETTypeSw,SwDown;setformodeswitchpressed(down).IFCEQAdjOff;assemblenextlinesonlyifdebuggingJRRManual,Flags3,ManType;debugonlyinmanualmodeDECOPFSET^decreaseOITSET(increaseoutput)JPChkSwRET;exitCheckSwitchroutine.ENDCManType;XRRBat6V,Hags2,C鹏Tl;Ifnotsetfor6V,checkforRegularChkBT0;ifsetfor6V,changeto12Vregular;RESHi6V,Flags3;clear6Vovervoltageflag;CALLSetl2V;setforRegular,12Vbattery;CALLCkPcnt;clearPercentandDisplayPercent;JPTypeChange;gotoendofCheckS邻ChkBTi;ifsetforAGM/Gel,changeto6VJRRBatTypeB,Flags,ChkBT2;IfnotsetforGel/AGM,checkforRegular;JRSHi6V,Flags3,ChkBT0;don'tsetto6Vifbatt>8.5VCALLSetReg;setbatterytypeforRegular;SETBat6V,Flags2;setfor6Vbattery;CALLClrPcnt;clearPercentandDisplayPercentJPTypeChange;gotoendofCheckSwChkBT2;ifRegular,tiieiisetforDeepCycleJRSBatTypeA,Flags,ChkBT3;IfnotsetforRegular,迈ustbeDeepCycleSETBatTypeA'Flags;setbatterytypeforDeepCycleRESBatTypeB,Flags;setbatteryty^efornotAGM/GelJPTypeChange;gotoendofCheckSwChkBT3;mustbeDeepCycle,sosetforGel/AGMSETBatTypeB,Flags;setbatterytypeforGel/AGMRESBatType入Flags;setbatterytypefornotDeepCycleTypeChangeI^ESCrankjFlags;setchargeratefornon-BoostCALLShowType;turnonBatteryTypeLEDModeChangeRESCrank,Flags;clearCrankbitofFlagsLDICurentSS,000h;restartchargingChkSwRETRET;*FANON*;*ThisroutineturnsthecoolingfanON.FanONiscalledduringoneofthefollowingconditions:*;*1.Startofcharge(endofState2)*;*2.Startofboost(State16)*;*3.IfOFFSET<HiOff-3inMaintain(State14)*;*4.ManualMode(State15)*;*5,States4,5,11,12,and13*FanONLDATemp,A;saveAccumulatorLDIA,OOO1OOOOb;updateAccumulatorfrombufferLDDRC,A;updateportfromAccumulator<formula>formulaseeoriginaldocumentpage272</formula>TurnONCALLShowChgng;turnChargingLEDonSe画CALLFanON;turncoolingfanonSETPower,Flags2;tdlPwrConchargerisonRET*ChargeRelay**ThisroutineswitchestherelayfromStarttoChargeifnecessary.**ChrgRlywaits200mSbeforeswitchingtherelay.Theoutputshould*beforeturnedoffbeforecallingChrgRly.*ChrgRlyJRRESriy,DRBbuf,CIigRlyX;skipaheadifrelayalreadysetforchargeCAIXFi他Second;wait200mSRESESrly,DRBbuf;setE/SrelayforchargeChgRiyXRET*Updatetheclocksandsetoverflowflagsasnecessary.*TicFlagl(s)bit0-hourswenttozero**TicFlaglfs)bit1-minuteswenttozero**TicFlagl(s)bit2-secondswenttozero**TicFlagl(s)bit3-milisecondswenttozeroCLOCKSDECMSecsl;decrementmillisecondcounterJKNZClksl;skiptoclock2ifMSECsoODo一MSecsLDIA)MSINIT;restartmillisecondcounterLDMSecsl,A;SETMSEC,TicFlagl;setmiliisecflagDECSecsl;decrementsecondcounterJRZDo—MinsClksl—JPCLOCKS1Do—MinsS^TSEC,TicFl绍l;setsecondexpiredflagLDISees1,Seclnit;restartsecondcounterDECMinsl;decrementminutecounterJRNZCLOCKS1;skipHRslifMINsldowntozeroDo一HrsS^i1MIN,TicFlagl;setminuteexpiredflagLDIMinsl,MMnit;restartminutecounterDECHrsl;decrementhourcounter,ZCLOCKS1;checkforoverflowSETHR,TicFlag1;sethourexpiredflagCLOCKS1DECMSecs2;decrementmillisecondcounterJRZDOMSecs2ClkExitJPCLOCEXTTDOMSecs2LDI入MSINIT;restartmillisecondcounter;LDMSecs2,A;SETMSEC,窗lag2;setmillisecflagDECSecs2;decrementsecondcounterJRNZC腿xit;exitifnotdowntozeroDo一Mins2SJSlrSEC,TicFlag2;setsecondexpiredfl昭LDISecs2,SecInit;restartsecondcounterDECMins2;decrementminutecounterJRNZCLOCEXIT;exitifnotdowntozeroDo一Hrs2SEiMIN'TicFlag2;setminuteexpiredflagLDIMins2,Minlnit;restartminutecounterDECHrs2;decrementhowcounter腳ZCLOCEXIT;checkforoverflowSETHR,TicFlag2;sethourexpired迈agCLOCEXITRETINITIALIZETIMERl*SubroutinetoinitializetimerlIniTimelLpiMSecsl,MSINITLDISecsI,SecInitLDIMinsl,MinMtCLRHrslCLRTicFlaglRETINITIALIZETMER2*SubroutinetoinitializeTimer2IniTime2LDIMSecs2,INTTLDISecs2,SecInitLDIMias2,MinlnitCLHHrs2CLRTicFlag2RET*ShiftA7**Subroutinetoshifttheaccumulatorleft7times.UsedbyDivide2:*andDivide4.Writtenonlytosavecodespace.*ShiftA7SLAA;s础left-RLCA;rotateleftthroughCARRYbit6timesRLCARLCARLCARLCARLCARETDIVIDEBY2*1SubroutinetodividethenumberinAby2.Theremainder,ifany:willbeavailableinthecanybituponreturn.*Divide2CALLShiftA7;shiftleftoncethenrotateeft7timesRLCA;rotateleft7thtimeRET*DIVIDEBY4**SubroutinetodividethenumberinAby4.Divide4CALLShiftA7;shiftleftoncethenrotateleft7timesANDIA,011imib;dropMSBRETATimes5**Subroutinetomultiplytheaccumulator(A)by5.*Atimes5multpliesAby4byshiftinglefitwicethenaddingtheoriginalvalueofA:(A*4)+A=A*5ATimes5LDATemp,A;ATemp=AADDA,A;A=A+A=A*2ADDA,A;A=A+A=ATemp*4ADD入ATemp;A=A+ATemp=ATemp*5RET*CURRENTREGULATION*:*ThisroutinereducestheoutputcurrentbyincreasingtheOFFSET*;*valuewhenthevoltageisbelow14.2volte(thruSS5).Anoffsetinto*:*anLUTisdeterminedbasedonthebatteryvoltage.Thevalueisloaded,*intoOFFSETwhichisusedtocontrolstheoffti边eoftheSCR's.*IRegLDA,BADhi;getvoltage;LDA,FreshBV;getvoltageJRSBat6V,Fi:ags2,IR—6V;skipaheadif6VmodeJRSRate,Flags,PH一l;skipaheadif15ampmodeLDIDRW艮OffAd了Slo.w;lookuptableforI2V2ampLDIX,OfEAdjSlo.d;initializelookuptableLDITempOf^'OfiLowSlo;highest2Aoffset-lowestcurrentSUBIA,BatLoSlo;submkdnum12V2amptableentry(10V)JKNCP一A14;donePA15—LDA'TempOffJPP—A12P—A14,iblTempOff,OffHiSlo;lowest12V2Ao飽et-highestcurrentCPIA)040h;lasttableentry-highestindexJRNCP一A15;do加JPPH—2—;donewith12V2ampPH—1_JRSRapid,Flags2'IR_rap;skipaheadifRapidrateIR—1_L5lDRWR,OffAdjFst.w;lookuptablefor12V15ampLDIX,OffAdjFst.d;initializelookuptableLDITempOff,OffLowFst;highest15Ao飽et-lowestcurrentSUBIA,BatLoFst;submininura15amptableentry厕CP一A17、doneP一A16P—A15TempOff,OffHiFst;lowest12V15Aoffset-highestcurrentCPIA,040h;lasttableentry-highestindexJRNCP一A16;do加JPPH—2一;donewith12V15ampIR_rap—J^kHiPwr,Flags4,IR一l;use12V15AtableiflowpowermodeLDIDRWI^OfEAxljR^p.w;lookuptablefor60ampLDIX,OflEAdjRap.d^initializelookuptableLDITempOi^O虹cwRap;highest60Aoffset-lowestcurrentSUBIA,§atLoRap;submininum60amptableentryJRNCIR—ip2;doneIR_rpl—IPP—A15IR一ip5L5lTempOff,OffffiRap;lowest60Aoffset-highestcurrentCPIA,040h;lasttableentry-highestindexIRNCIR—ipl;donePH一2一ANDIA,03Fh;limitto64bytewindowADD入X;addtablebaseaddressLDX,A;LDAj(X);getvaluefromtableJPP一A12;skipaheadandupdateoffetvalueIR一6VJRSRate,Flags,IR6—3;skipaheadif15ampmodeLDIDRWR,OfAd6"Slo.w;lookuptablefor6V2ampLDIX,OfAd6Slo.d^initializelookuptableLDITempOff,Off6LoSb;highest2Aoffset-lowestcurrentSUBIA^at6LoSl0;submininum6V2amptableentry(5V)IRNCIR6_2;do加IR6一1一LDA'TempOffJPP—A12IR6—5LDfTempOff,Of細Slo;〗owest6V2Aoffset-highestcurrentCPIA,020h;lasttableentry-highestindexJRNCIR6一1;doneJPIR6—10;donewith6V2ampIR6一3JRSRapid,Flags2,IR6_7;skipaheadifRapidrateIR6—4_LDfDRWR,OfAd6Fst,w;lookuptablefor6V15ampLDIX,OfAi6FsU;initializelookuptableLDITempOff'Off6LoFst;highest15Aoffset-lowestcurrentSUBIA力at6LoFst;subminin咖6V15amptableentryJRNCIR6一6;doneIR6—5—JPlR6_lIR6—6LDTTempOff,Off6HiFst;lowest6V15Aoffset-highestcu订entCPI入020h;lasttableentry-highestindexJRNCIR6一5;doneJPIR6—10—;do加with6V15ampIR6—7一IR]EHiPwr,Flags4,IR6_4;use6V15AtableiflowpowermodeLDIDRWR,OfAd6Rap.w;lookuptablefor60ampLDIX,OfAd6Rap.d^initializelookuptableLDITe啤Off'Off6LoRap;highest6V60Aoffset-lowsstcurrentSUBIA,Bat6ILoRap;submininum6V60amptableentryJRNC;doneIR6—8—JPlR6_lIR6一9LD亍TempOff,Off6HiRap;lowest6V6QAo伤et-highestcurrentCPIA020h;lasttableentry-highestindexJRNCIR6—8;doneIR6—10一Al^IA,01Fh;limitto32bytewindowADDA,X;addtablebaseaddressLDX,A;LDA,(X);getvaluefromtableP—A12;XDDA,FUDGE;debugfodgefactorLDOFFSET,A;savenewoffsetvalueP—A13*VOLTAGEREGULATION**ThissubroutinewilladjustthevalueofOFFSEToncepersecondto81*controlthecurrentandmaintainthevoltagedeterminedbyMaintVolt.Vo败eg;LDA,MSecs2;MSec2=MSInitoncepersecond;CPIA,MSINIT;IsMSEC1=MSINIT;JRZVRegJ3;Yes:thentimetoadjust;VReg一X_;JPVReg—3;No:thennottimetoadjust;VReg一0;adjustoffsetDECVRcnt;decrementintervalcounterJRZVReg一0;Yes:thentimetoadjustJPVoltRegX;No:thennottimetoadjustVReg_0''adjustoffsetLDI^^Rcnt'MSINIT;re-initializeinitervalcounter(1sec)LDA,FreshBV;getbatteryvoltageCALLDouble6V;doubleBatteryvoltageifsetfor6VDECACPA,MdntYolt;comp咖withsetvalue+1JRNCVReg—6;greaterthan,increaseOFFSETJPVReg—1;notgreaterthan,testiflessthanVReg_6LDjS,OFFSET;greaterthan,getphasedelayvalueINCA;JRSBat6V,Flags2,VReg^2CPIA,HiOff;testifathighlimitJPVReg_5VReg一2CPIX,HiO筋VReg_5JRN(JVReg一3;atthelimit,don'tchangeOFFSETVReg一4一LDOFFSET,A;updateOFFSETVReg一3JPVoltRegX;doneforthispassVReg一lCPAMaintVolt;comparewithsetvalueJRNCVoltRegX;notlessthan,justexitLDA,OFFSET;lessthan,getphasedelayvalueDECA;CPA,LowOff;testifatlowlimit扁CVReg—4;notatthelimitupdateOFFSETVoltRegX—RET;*TIMERINTERRUPTHANDLER*;*ThisroutineturnstheSCRsonifthepowerflagsare加n-zeraand;*inhibitsthetimer.*PwrConLDATemp,A;saveAregisterJRSPower,Flags2,PCon;chargeron,tumonSCRsJPPWREXIT;notchargingjustexitPConSETSCRs,DRBbuf;turaontheSCRs(inbuffer)CALLUpdatePB;updateportBfrombufferPWREXIT;LDITSCR,015h;inhibittimerCALLRstWDR;resetwatchdogtimerLDIA,FULLT謹;TCRisreloadedherefor1&11cycleLDTCR,A;LDITSCR,05dh;reloadprescalerandstarttimerJRRCmkng,Flags4,PC一NormPC—CrankC厄LCLOCKS;updateclocksRESNMInt^lags2;tellExitMainthiswasNMIinteruptIPPCexit;leaveSCRsonduringCrank;turnoffSCRdrivesothatonlyapulseisgenerated(SCR'slatchon)PC—NormNMInt,Flags2;tel1ExitMainthiswastimerinterupt;RESSCRs,DRBbuf;otherwise,turnoffSCR's(inbuffer);CALLUpdatePB;updateportBfrombufferPCexitLDA,ATemp;restoreAregisterRETI;*NON-MASKABLEINTERRUPTHANDLER*;*ThisistheNMIinterruptroutine.TheNMIisgeneratedonthefalling*;*edgeoftheiUllwaverectifiedAClinevoltage.Aninterruptis*generated120timespersecond,onceevery8.333ms.AftereachNMI,thisroutineperformsthefollowingsteps,*1.Resetthewatchdogtimerandsave&eregisters.*2.TurnofftheSCRs(unlessduringCrankONstate),*;*3.SettheinterrupttimeraccordingtoOFFSET.*;*4.ResetNMIntsoExitMainknowsit'sanNMI(nottimerint),*;*5.Updatetheclocks,*;*6.Restoretheregisters.*;*Ifturnedoff,theSCRswillremainoffforaperioddeterminedby*;*OFFSET.TheTimerwillthentriggeraninterruptwhichtellsPwrCon*;*toturntheSCRsback:onifnecessary.*,**IT—TIMERCALLRstWDR;resetwatchdogtimerLDATemp,A;saveAregisterLDA,X;getXregisterLDXTEMP,A;saveXregisterJRSCrnkag,Flags4,IT—XIT—Normn"5p;LDIX,2Ah;delayfortruezerocrossLDIX,03h;delayfortruezerocrossIT—TD!CX厕ZIT—TNOP;adjiistzerocrossdelayLDA,OFFSET;getcurrentoffeetLDTdR,A;loa(ithecounterwithcurrentoffsetLDITSCR,O1011101b;reioadprescaler(32)andstarttimerRESSCRs,DRBbuf;tumoffSCR's(inbuffer)CALLUpdatePB;updateportBfrombufferIT—TMRR^SNMInt,Flags2;tellExitMainthiswasNMIinteruptCALLCLOCKS;updateclocksIT一XA,XTEMP;restoreregistersLDX,ALDA^ATempRETI<formula>formulaseeoriginaldocumentpage280</formula>.byte00010000b;bitpatterntodisplay—8.byte00011000b;bitpatterntodisplay;*ROMDATAWINDOWforSECONDLEDDIGIT*;*Thefollowingbitpatternsareusedtodisplaytheindicatednumbersas:;*thesecond(middlesignificant)digitonlieLED.*:block16-$%16Digits0x0patternsforDigiDat2-Digit2(middledigit)andMS1byteOOOOOlOlb;bitpatterntodisplay—0—,byte1100111lb;bitpatterntodisplay—1—,byte0010001lb;bitpatterntodisplay一2一■byte10000011b;bitpatterntodisplay—3—.byte11001001b;bitpatterntodisplay丄■byte10010001b;bitpatterntodisplay—5—byte00010001b;bitpatterntodisplay_6一byte1100011lb;bitpatterntodisplay—7—■byte00000001b;bitpatterntodisplay二8—■byte10000001b;bitpatterntodisplay一9_*ROMDATAWINDOWforAlternatorChargeinPercent**ThefollowingvaluesarethePercentvaluesforthealternatorvoltages对*listedbelow.Thesenumbersareonlyusedwhenthechargerisin**Testermode.Voltageslowerthanthefirstentryaredisplayedas0%**charged.Voltagesabovethelastentryaredispiayedas199%charged.,block32-$0/032AltLvls%VoltsHex■byte0;13.53CBred■byte12;13.60CC|byte25;13.67CD|■byte38;13.73CEred■byte50;13.80CFyellow,byte$2;13.87DO1■byte力;13.93Dlyellow.byte85;14.00D2green.byte92;14.07D31,byte97;14.13D4i,byte100;14.20D5,byte100;14.27D6byte100;14.33D7byte100;14.40D8byte100;14.47D9byte100;14.53DA|byte100;14.60DB|byte103;14.67DCjbyte110;14.73DD|byte120;14.80DEgreenbyte130;14.87DJFyellowbyte140;14.93E0|.byte150;15.00Elyellow.byte160;15.07E2red.byte170;15,13E3i,byte180;15.20E4j.byte190;15.27E5j.byte1%;15.33E6red.byte199;15.40E7red;*ROMDATAWINDOWFORSlewmode*;*Thesearetheoffsetstocontrolthecurrentoutput,block64-$0/o64;OffsetBADhi;DecHexIndexVoltsHexDec.byte132;84010.0096150byte132;84110.0797151byte132;84210.1398152.byte132;84;310.2099153byte132;84410.279A154.byte131;83510.339B155.byte13183.byte13183710.479D157byte13183810.539E158.byte13183910.609F159byte130821010.67AO160.byte130821110.73Al161byte130821210.80A2162.byte130,821310.87A3163.byte130,821410.93A4164byte129,811511.00A5165byte129,811611.07A6166.byte129811711.13A7167.byte129;811811.20A8168.byte129;811911.27A9169.byte128;802011.33AA170.byte128;802111.40AB171.byte128,802211.47AC172.byte128;802311.53AD173byte128;802411.60AE174.byte128;802511.67AF175.byte127;7F2611.73BO176.byte127;7F2711.80Bl177.byte127;7F2811.87B2178.byte127;7F291I.93B3179.byte127;7F3012.00B4180.byte127;7F312.07B5181.byte126;7E3212.13B6182.byte126;7E3312.20B7183.byte126;7E3412.27B8184.byte126j7E3512.33B9185.byte126;7E3612.40BA186.byte125;7D3712.47BB187.byte125;7D3812.53BC188.byte125.byte125.byte124.byte124.byte124.byte124.byte124.byte124byte123.byte123.byte122.byte122byte122.byte122byte122.byte122.byte121.byte121.byte121.byte121.byte120.byte120.byte120.byte]20.byte1197D3912.60BD1897D4012.67BE柳,7C4112.73BF1917C4212.80CO1927C4312.87CI1937C4412.93C21947C4513.00C31957C4613.07C41967B4713.13C51977B4813.20C6198,7A4913.27C7199■7A5013.33C82007A5113.40C9201■7A5213,47CA2027A5313.53CB2037A5413.60CC204795513.67CD205■795613.73CE206,795713.80CF207795813.87DO208;785913.93Dl2097860R00D221O786114.07D3211:786214.13D4212,776314.20D5213*ROMDATAWINDOWFORFastmode**Thesearetheoffsetstocontrolthecurrentoutput.;.block64-$。/064OffAdjFst;OffsetBADhi;DecHexIndexVoltsHexDec.byte107;6D010.0096150110.0797151210.139815210.2099153410.279A15410.339B155610,409C156710.479D157810.539E158910.609F1591010.67八O1601110.73Al1611210.80A21621310.87A31631410.93A41641511.00A51651611.071661711.13A71671811.20A81681911.27A9169.byfe107;6D.byte107;6D.byte107.byte107.byte107.byte107.byte107.byte107.byte107.byte107.byte106.byte106.byte106.byte106.byte105.byte105.byte105.byte104.byte104'6D;6D,6D,6D《D:6D6D6D6C6C6C6C6B6B6B6A6A.byte103;6S>2011.33AA170.byte103邻2111.40AB171.byte103;692211.47AC172.byte103;692311.53AD173.byte102;682411.60AE174.byte102;682511.67AF175.byte102;682611.73BO176.byte101;672711.80Bl177byte101;672811.87B2178.byte101;672911.93B3179byte101;673012.00B4180.byte101;673112.07B5181.byte100;663212,13B6182.byte100;663312.20B7183.byte100;663412.27B8184.byte99.byte99.byte99byte98-byte卯byte98■byte98.byte97.byte97.byte97.byte96■byte96.byte96.byte95.byte95.byte95.byte95.byte94.byte94.byte94.byte93.byte93.byte93.byte92.byte92.byte92byte91.byte91.byte90653512.33B9185653612.40BA186653712.47BB187■643812.53BC188643912.60BD189644012.67BE190644112.73BF191634212.80CO192634312.87CI193634412.93C2194624513.00C3195624613.07C4196624713.13C5197614813.20C6柳,614913,27C7199,615013.33C8200,615113.40C9201:605213.47CA202,605313.53CB203605413.60CC204,5F5513.67CD2055F5613.73CE206:5F5713.80CF2075E5813,87DO208:5E5913.93D12095E6014.00D2210,5D6114.07D3211■5D6214.13D42125C6314.20D5213;*ROMDATAWINDOWFORRapidmode*;*Thesearetheoffsetstocontrolthecurrentoutput.;.block64-$%64O腿jRap;OffsetBADhiSDecHexIndexVolteHexDec.byte80;50010.0096150.byte80;50110.0797151.byte80;50210.1398152byte80;50310.2099153.byte80;50410.279A154.byte80;50510.339B155.byte79;4F610.409C.156.byte79;4F710.479D157.byte78;4E810.539E158.byte78;4E910.609F159.byte77;4D1010,67AO160.byte77;4D1110.73Al161.byte77;401210.80A2162.byte77;4D1310.87A3163.byte77;4D1410.93A4164.byte76;4C1511.00A5165.byte76;4C1611,07A6166.byte76;4C1711.13A7167.byte75邻1811.20A816S.byte75邻1911.27A9169.byfe74;4A2011.33AA170.byte73;492111.40AB171.byte73;492211.47AC]72.byte73;492311.53AD173byte72;482411.60AE174byte71;472511.67AF175.byte70;462611.73BO176.byte69;452711.80B1177byte68;442811.87B2178.byte67;4329〗1.93B3179.byte67;433012.00B4180.byte66;423112.07B5181byte65;413212.13B6182.byte65;413312.20B7183.byte64;403412.27B8184,byte63;3F3512.33B9185.byte63;3P3612.40BA186.byte62邻3712.47BB187.byte61;3D3812.53BC188.byte61;3D3912.60BD189.byte60;3C4012.67BEl卯.byte59;3B4112.73BF191byte58;3A4212.80CO192.byte57;394312.87CI193.byte55;374412.93C2194.byte53;354513.00C3195.byte51;334613.07C4196.byte49;314713.13C5197.byte47;2F4813.20C6198.byte45;2D4913.27C7199,byte44;2C5013.33C8200.byte42;2A5113.40C9201.byte41;295213.47CA202,byte40;285313.53CB203.byte39;275413.60CC204.byte38;265513.67CD205.byte37;255613.73CE206.byte36;245713.80CF207.byte35;23.byte34;22.byte33;21byte32;20.byte31;IF.byte30;IE5813.87DO2085913.93Dl2096014.00D22106114.07D32116214.13D42126314.20D5213ROMDATAWINDOWFOR6V2ampmodeThesearetheoffsetstocontrolthecurrentoutput.;.block32-$%32OfAd6Sb;OffsetVote;DecHexIndexDecHex.byte135.byte140;.byte140;.byte140;.byte140;.byte140;.byte140;.byte140;力yte140;.byte140;.byte140;.byte140;.byte140;.byte139byte139;.byte139:.byte139:.byte139;.byte139:.byte139.byte138.byte138;.byte138:.byte138:.byte137:.byte137;.byte137;.byte137;.byte137;byte136;.byte136;.byte136:;8A05.004B;8A15.074C;8925.134D;8935.204E;8945.274F,8855.3350,8865.4051,8875.47528785.5353879'5.605487105.675586115.735686125.805786135.875885145.935985156.005A85166.075B84176.135C84186.205D84196.275E83206.335F83216.406083226.476182236.536282246.606382256.676481266.736581276.806681286.876780296.936880307.006980317.076A;*ROMDATAWINDOWFOR6V15ampmode;*Thesearetheoffsetstocontrolthecurrentoulput.;.block32-$%320仪d6Fst;OffsetVoltsDecHexIndexDecHex04.47437B14.54447024.60456A34.67466744.7454.8064.8774,9485.0095.074767486749664A664B664C65105.14橋5115.204E64125.274F64135.345064145.405163155.475263165.545363175.605462185.675562195.745662;205.805761215.875S6i,225.945961,236.00246.07:256.14266.20276.27:2S634,296.40,306.47316.545A605B605C5F5D5F5E5F5F5E605E615E625E;*ROMDATAWINDOWFOR6V60ampmode;*Thesearetheoffsetstocontrolthecurrentoutput.;.Wock32-$%32OfAd6Rap;OffsetVolts;DecHexIndexDecHex.byte88;8A04.8749.byte88;8A14.944A.byte87;8A25.004B.byte87;8A35.074Cbyte87;8945.134D.byte86;8955.204E.byte86;8965.274F.byte86;8875.3350.byte85;8885.4051.byte85;8895.4752.byte85;87105.5353byte85.byte85.byfe85.byte85,byte85.byte85.byte84.byte84.byte84.byte84.byte84.byte84.byte84.byte83.byte83.byte83.byte83.byte83.byte83.byte83.byte82;87;87;86;86;S<5;85;85;85;84115.6054125.6755135.7356145.8057155.8758165.9359176.005A186.075B196.135C;84206.205D;84216.275E;83226.335F236.4060246.4761256.5362266.6063276.6764286.7365296,8066306.8767316.9368;83;83;82;82;82;81;81;81;80Interruptvectors.orgOFFOhADCJPADINTTIMERJPPwrConINT2NOPRETIINTlNOPRETI.orgOFFChNMIJPIT一TIMERRSTJPRESET■END30060.asmChecksum.,RawCode:70A45W他Info:70A45*COPYRIGHT2004SCHUMACHERELECTRIC**ALLRIGHTSRESERVED**WRITTENBY**THOMASF,JOHNSON****LinearPSW-30060ACharger/Starter/Tester**TWscodeisfortheSGS-THOMPSONmicro-controler*PartnumberSTC2T25/ST62E25*.title'TroSeries300-60-15-2AWheeledLinearChargerVer.0.21".LINESIZE131.vers"ST6225".ro咖ize4.w一oiiSho5ff.SET0;1->normal,0->ShowOFFSETinAlt%modeduringchargingFastCP.SET1;1->normal,0->3minChkProgintervalinsteadof60minShoADC.SET1;1->normal,0->UsePB2toindicateA/DactivityDefinetheporthardwarelocations*Attimes,the.defstatementisfollowedbyavalueand"!迈".The!m'*isusedbythesimulator/emulatorfordebugging.Thissymboltellsthe*equipmentwhatregisterstheuserwantstomonitorduringdebuging.X.def80h!mY.def81hV.def82hW.def83hk.defOffli!mi)RA.defOcOWmDRB.defOclh!mDRC.def0c2h1dDRA.def0c4hDDKB.def0c5hDDRC.def0c6hORA.defOcchORB.defOcdhORC.defOcehXdR.def0d0h!m;Indexregister;Indexregister;Shortdirectregister;ShortdirectregisterjAccumulator;Portadataregister;Portbdataregister;Portcdataregister;Portadirectionregister;Portbdirectionregister;Portcdirectionregister;Portaoptionregister;Portboptionregister;Portcoptionregister;A/DdataregisterADCR.defOdlh;A/DcontrolregisterPSC,def0d2hTCR.def0d3h!mTSCR,def0d4hTimerprescalerregister;Timercounterregister;TimerstatuscontrolregisterWDR.def0d8h;WatchdogregisterIOR.def0c8h!mDRWR.def0c9h;Interruptoptionregister;DateramwindowregisterThesearetheramequatesusedbythebatterycharger.DRAbuf.def084h;shadowramforportAdataregisterDRBbuf.def085h;shadowramforportBdataregisterDRCbuf.def086h;shadowr咖forportCdataregisterATemp.def087h;AccumulatortemporarystorageXTEMP.defO88I1;XregistertemporarystorageMSecsl.def089h;storagefor8.333mstics-cxmutof120=1secSecsl.def08Ah;storagefortimerlsecondsMinsl.def08Bh;storagefortimedminutesHrsl.def08Ch;storagefortimerlhoursTicFlagl.def08Dh;overflowflagsforSecsl,Minsl,andhoursMSecs5,def08Eh;millisecondonecounterSecs2.def08FtL;storagefortimer2secondsMins2.def090h;storagefortimer2minutesHrs2,def09lh;storagefortimer2hoursTicFlag2.def092h;overflowflagsforSecsl,Mins2,andhourslTries,3ef093ti;usedbybatterydetectroutinesTEMP,def094h;scratohpadareaTEMPI,def095h;scratchpadareaTemp2.def096h;countusedforFreshBVCurVolt.def097h;currentbatteryvoltageMaMVolt.def098h;storageforMAINTAINvoltagelevelOldVolt.def099ti;previcmsbatteryvoltage,usedfordv/dtCCDcnt.def09Ah;displaycountdownduringcrankcooidownOldOff.def09Bh;oldvalueofOFFSETusedindl/dtBADlo.def09Ch;lowbitsbatteryvoltageaverageBADhi.def09Dh;hibitsbatteryvoltageaverageVmax.def09Eh;maximurabatteiyvoltage(perBatteryType)Vref.def09Fh;refvoltagefordesulfationOFFSET.def0A0h;storageforphasedelayvalueFreshBV.def0Alh;avgbattvoltusedfordi/dtrefEBVTotLo.def0A2h;lowbyteoftotalusedforFreshBVFBVTotHi.def0A3h;highbyteoftotalusedforFreshBVCurentSS.def0A4h;storescurrentchargerstateFlags,def0A5h;chargerconfigurationstates;bit0(BatTypeA):0forReg,1forD/C;bitI(BatTypeB、0forNorm,1forAGM/GEL;bit2(Rate):0forSlow,1forFast;bit3(Crank):1ifinBoostmode;bit4(CrankWait):1duringE/Scooldown;bit5(Started):1ifchargingstarted;bit6(MtrUnits):0forVolts,1for%;bit7(MtrScal^:0forBag1forAltFlags2.def0A6h;storesthefollowingFlags;Git0(Batt):1ifbatteryconnected;bit1(Rapid):1ifsetforRapidchargerate;bit2(Bat6V):1ifsetfor6Vbattery;bit3(Power〗1ifoutputison;bit4(NMInt):1ifNMIinterrupt,0ifTimer;bit5(ChMode):1ifinChargerMode;bit6(WaitOP):1ifwaitingfor0/。tochangefrom0;bit7(Alert):1indicatesAlertconditionFlags3.def0A7h;storesthefollowingFlags;bit0(Rmplnt):1during1sthalfofeachRampinterval;bit1(Settle):1duringvoltagesettletime;bit2(HiEnd):1ifhighervoltageforEndCharge;bit3(Idle):1imtilabuttonispressed;bit4(Hi6V):1ifbattery>8,5V;bit5(NxtCnt):1->1stsecondofcount;bit6(Manual):1ifinManualMode;bit7(Burnln):1ifinBurn-inModeSwDown.def0A8h;Indicatesstateofswitches(l->pressed);bit4=SwOffflag(debugging)力it5=Typeswitch;bit6-Rateswitch;bit7=Meters"witchDigiDat2.def0A9h;datafor8of16segmentsofdigitalLED(0->ON,l->off);bit0=digit3segmentsB&C;bit1-digit2segmentF;bit2=digit2segmentG;bit3=digit2segmentA;bit4=digit2segmentB;bit5=digit2segmentC;bit6=digit2segmentD;bit7=digit2segmentEDigiDatl.defOAAh;datafor8of16segmentsofdigitalLED(0->ON,l->off)jbit0=digit1segmentC;bit1=digit1segmentG;bit2=digit1segmentD;bit3=digit1segmentE;bit4=digit2decimalpoint;bit5-digit1segmentF;bit6=digit1segmentA;bit7=digit1segmentBSwData,def0ABh;dataforthe3Rateand3TypeLEDs(0->ON,1->off);bit0=6VbatterytypeLED;bit1=RegbatterytypeLED;bit2=D/CbatterytypeLED;bit3=AGMbatterytypeLED;bit4=60AchargerateLED;bit5=15AchargerateLED;bit6=300AchargerateLED;bit7=2AchargerateLEDBitCnt.defOACh;Indexofbitsenttodi邻layBytCnt,def0ADh;IndexofwordsenttodisplayDataBuf.def0AEh;TempstorageforDatabiteVltCnt.defOAFh;CounterforvoltagedisplayintervalTempOff.def0B0h;tempoffsetvalueRmpCnt.defOBlh;countsrampintervalsuntilnextrampLEf)num.def0B2h;storesnumbertobeshownondigitalLEDPercent,def0B3h;storespercenttobeshownondigitalLEDIndex.def0B4h;usedforlookuptableaccessLowOff.def0B5h;minoffsetvaiuefordi/dt(highestcurrent)VRcnt.def0B6h;CounterforvoltageregulationintervalPcntL.def0B7h;NMIcounterforpercentdisplayupdatePcntH.def0B8h;IntervalcounterforpercentdisplayupdateDspPcat.def0B91i;storageforlastpercentdisplayedHags4.defOBAh;storesthefollowingFlags;bit0(IdleSet):1if10minuteIdletimerwasstarted;bit1(NoRamp):1duringManualFastcharge;bit2(SOC):1ifatstartofcharge(1st5s);Wt3(Cmkng):1ifcranking(State19);bit4(HiPwr):1ifchargerate>FastLastBatt.defOBBh;storesbatteryreadingusedtomonitorprogress;free.defOBCh;freeORBbuf.defOBDh;shadowRAMforORBregister;free.defOBEh;free;fi:ee,defQBFh;firee;OBFh=lastRAMlocation*Thesearetheconstantsusedbythebatterycharger.Volts005.equ008h;0.5VOLTSVolts0.equOOAh;0.7VOLTSVoltsO1.equOOFh;1.0VOLTSVolts016.equ017h;mimi加involtageforenginestart,1.5VVolte02.equOlEh;2.0VOLTSVolts05.equ04Bh;5.0VOLTSVolts06.equ05Ah;6.0VOLTSVolts066.equ061h;6.6VOLTSVolts075.equ071h;7.5VOLTSVolte09.equ087h;veiydischargedbatteryvoltageVoltelO.equ096h;10.0VOLTSBattMin.equOAFh;lowestvalueinBattery%LUTVoltsl2.equ0B4h;lowbatteryvoltageVoltsl22.equOB7hVoltsl25.equOBChBattMax.equOBDh;highestvalueinBattery%LUTVolts127.equOBEhVolts128.equ0C0h;goodbatterytestvoltageVoltsl3.equOC3hVoltsl32.equOC6hVoltsl35.equOCAhAltMin.equ0CBh;bwestvalueinAlternator%LUTVoltsl38.equOCFhVoltsl4.equOD2hVoltsl42.equ0D5h;startmonitoringdv/dtvoltage292Voltsl435.equOD7hVoltsl44.equOD8hVoll;sl46.equODAh;maximu迈allowedvoltageforreg/gelmodeVoltsl47.equ0DCh;starttrickletimervoltageVoltsl49,equ0E0li;14'87VVoItsl5.equOJElh;咖ximmnallowedvoltageforRV/DCMarineVoltsl5a.equOE2h;15.07VAtMax.equ0F7h;highestvaueinAlternator%JLUTVoltsl55.equ0E9h;咖ximumallowedvoltageforAuto/MarineStartingVoltsl6.equ0F0h;maxim咖allowedvoltageVoltsl65.equ0F7h;maxi咖边allcwedvoltagefordeepcycle2Volts17,equ0FCh;maximumallowedvoltageMaxVolts.equOFFh;maximuravoltagereading-17,0VRCinit.equ180;1801-secondintervalsyields180secondsRCinitX2.equ180;1801-secondintervalsyields180secondsRJinit.equ65;60NMIinterruptsyields0,5secondsMSINIT.equ078h;millise咖dinitializationvalue(120)MS500.equ03Ch;milUsecondcomtervaluefor500mS(60)MS200.equ0i8h;miHiseconcicountervaluefor200mS(24)Seclnit.equ03Ch;secondinitializaticmvalue(60)Minlnit.equ03Ch;minuteinitializationvalue(60)MaxHrs,equ25;maximumallowedchargehours+1CPint.equ60;minutesperchargeprogressintervalHR.equ000h;hoursbitofTicFlaglandTicFlag2MIN.equ00lh;minutesbitofTicFlaglandTicFlag2SEC.equ002h;secondsbitofTicFlaglandTicFiag2MSEC.equ003h;millisecondsYLO.equ0C0h;iowlinelimit-100VACVHI.equ0EEh;highlinevoltagelimit-130VACBatLo2.equ0961i;lowbatteryvoltagecurrentadjust-IO'OVdcBatLo15,equ087h;lowbatteryvoltagecurrentadjust-9,0VdcBatLo60.equ093h;lcnvbatteryvoltagecurrentadjust-9.8VdcBat6!Lo2'equ04Bh;lowbatteryvoltagecurrentadjust-5,0VdcBat6Lo15.equ043h;lowbatteiyvoltagecurrentadjust-4.5VdcBat6Lo60.equ049h;lowbatteryvoltagecurrentadjust-4.9Vdc;BalHi2,equ0D5h;BatHil5.equOC6hPCint.equOOAh;numberofI-secondintervalsbetween%updatesFULLTIME.equ0ADh;halfsecondwhenACpowerisOFFSlowAmps.equ2;NomiaalampsoutatSlowrateFastAmps.equ15;NominalampsoutatFastrateRapAmps,equ60;NominalampsoutatRapidrateCrnkAmps.equ103;NominalampsoutatCrankrateCodeRev.equ0;softwarerevisionlevelOffLow2,equl28;Lowestcurrentin12V2AoffsettableOffSlow.equ117;"Nominaloffsetforslowcharge(20%)OffHi2.equ117;Currentin12V2Aoffsettablefor14,0VMinOfE2.equ115;MaxCurrentfor12V2Arateduringdi/dtOffLowl5,equ112;Lowestcurrentin12V15AoffsettableOffFast.equ^9;Nominaloffsetforfastcharge(15A)OFF15AMP.equ99;offeetvaluefor12V15ampmode0舰15.equ99;Highestcurrentin12V15AoffsettableMinOffl5,equ97;MaxCurrentfor1TV15Arateduringdi/dtOffRap.equ,7;Nominaioffsetforrapidcharge(~900/o)OffLow60.equ77;Lowestcurrentin12V60人offsettable0細60,equ48;Highestcurrentin12V60AoffsettableOfiECrank.equ95;OFFSETforCrankstandbyOff(5Lo2.equl35;Firstentryin6V2AoffsettableO筋Slo,equl36;N。minaloffsetfor6Vsowcharge(2A)Off6Hi2.equ136;Cuirentin6V2Aoffsettablefor7.0VMin60ff2,equ134;MaxCurrentfor6V2Arateduringdi/dt0^5Lol5.equ121;Lowestcurrentin6V15AoffsettableOff6Fst.equl17;Nominaloffsetfor6Vfastcharge(15A)OfffiHi15.equ117;Highestcurrentin6V15AoffsettableMin60ffl5.equ115;MaxCurrentfor6V15Arateduringdi/diOf舰ap.equ88;Nominaloffsetfor6Vrapidcharge(60A)Off6Lo60.equ88;Lowestcurrentin6VoffsettableOff6Hi60.equ82邻ghestcurrentin6V60Ao飽ettableOff6Crnk.equ105;OFFSETfor6VCrankstandby扭Off.equ140;highlimitforOFFSETvariableHiOff6.equ150;highlimitforOFFSETvariable(6Vmode)ABORT.qu0081i;abortstateLEDslow:equ007h;S;iowLED-bitofSwDataLEDboost.equ006h;CrankLED-bitofSwDataLEDfast.equO05h;FastLED-bitofSwDataLEDrap.equ004t;RapidLED-bitofSwDataLEDgel.equ003h;AGM/GelLED-bitofSwDataLEDdeep.equ002h;DpCyclLED-bitofSwDataLEDreg.equ00lh;RegularLED-bitofSwDataLED6V.equ000h;6VRegLED-bitofSwDataLEDdone.equ000h;ChargedLED-PORTALEDchgng.equOOlti;ChargingLED-PORTALEDalert.equ002h;FauItLED-PORTALEDprcnt.equ003h;PercentLED-PORTALEDvolt.equ004h;VoltageLED-PORTALEDalt.equ005h;AltatrLED-PORTASerData.equ006h;SerialData-PORTAClrData.equ007h;DataClear-PORTAShfiClk.equOOOh;ShiftClock-PORTBLtchClk.equOOlh;LatchClock-PORTBESriy.equ003h;E/Sre!ay-PORTBDisable.equ006h;DisableCtrl-PORTBSCRs.equ007h;SCRcontrol-PORTBFanCtI.equ004h;Fancontrol-PORTCTypeSw.equ005h;Typeswitch-PORTCRateSw.equ006h;Rateswitch-PORTCMeterSw.equ007h;Meterswitch-PORTCBatTypeA.equOOOh;bitinFlagsforbatteiytype:0=Reg,1=D/CBatTypeB.equ0Qlh;bitinFlagsforbatterytype:1=AGM/GelCellRate.equ005h;bitinFlagsforchargerate:0==Slow,1=FastCrank.equ003h;bitinFlagsthatindicatesenginestartCrankWait.equ004h;bitinFlagsthatindicatescooldownbetweencranksStarted.equ055h;bitinFlagstWindicateschargestartedMtrUnits.equ006h;bitinFlagsformeterunits:0=volts,1=%MtrScale.equ007h;bitinFlagsformeterscale:0=batt,1=altrntrBatt.equ000h;bitinFkgs2:1ifbatteryisconnectedRapid.equOOlh;bitinFlags2:1ifchargerateisRapidBat6V.equ002h;bitinFlags2:Iifoutputis>10APower.equ003h;bitinFlags2:1ifoutputisonNMInt.equ004h;bitinFlags2:1ifNMIinterrupt,0ifTimerChMode.equ005h;bitinFkgs2:1ifinChargermode(notTester)Wa加?.equ006h;bitinFlags2:1ifbattery>10VAlert.equ007h;bitinFlags2:1indicatestroubleRmplnt.equOOOh;bitinFlags3:1during1sthalfeachRampintervalSetife,equ001h;bitinFlags3:1duringvoltagesettletimeHiEnd,equ002h;bitinFlags3:1ifhighervoltageforEndChargeIdle.equ003h;bitinFlags3:1untilabuttonispressed扭6V,equ004h;bitinFkgs3:1ifbatteiy>8.5VNxtCnt.equ005h;bitinFlags3:0duringlasthalfofCCDcntintervalM卿al.equ006h;bitinFlags3:1duringManualmodesBurnln,equ0071i;bitinFlags3:1duringBurn-InmodeIdleSet.equOOOh;bitinFfags4:1if10minuteIdletimerwasstartedNoR咖p.equ00lh;bitinFlags4:1duringmanualfastchargeSOC.equ002h;bitinFlags4:1duringStartOfCharge(1st5sec)Crnkng,equ003h;bitinFlags4:1duringcranking(Statel9)HiPwr,equ004h;bitinFlags4:1ifchargerate>》astCrankOff.equ180;crankofftimeinsecondsGrankON,equ3;crankcmtimeinsecondsCCDint.equ00111;crankcooldowndisplaycounterinterval(seconds)GrankSS,equOlOh;crankSSisstate16==10hexDecimal.equ004h;bitinDigiDatlfordecimalpointDigitl.equOOOh;bitinDigiDat2formostsignificant1SwsOff.equ1111111lb;bitpatternforallswitchesoffDigiOffa.equ11111Ulb;bitpatternforallsegementsoffDigiOfib.equ1111111ib;bitpatternforallsegementsoffDigiONa,equOOOOOOOOb;bitpatternforalls邻e迈entsONDigiONb.equOOOOOOOOb;bitpatternforallsegementsONDashesl.equIinn(Ub;bitpatterntodisplay_^Dashes2.equ1111101lb力itpatterntodisplay—-—DigiRevl.equ00010010b;bitpatterntodisplay一ODigiRev2.equ01100001b;bitpatterntodisplay—P一DigiMVl.equOOOOlOOOb;bitpatterntodisplay—.9—DigiMV2'equlOOOOOOOb;bitpatterntodisplay了9—,.org0S80h;forST6210/15.org0100h;forST6220/25RESETCALLRstWDR;resetwatchdogtimerRAMCLRLDIX,084h;pointXto1stRAMLocationRAMCLR1CLRA;dearALD(X),A;storeAatlocationpointedtobyXINCX;incrementXLDAjX;getpointerinACPIA,0C0h;testforendofRAMJRNZRAMCLIU;doagainifnotfinished<formula>formulaseeoriginaldocumentpage296</formula>;ThenextthreelinessettheunitforTester(notCharger)迈odeRESChMode,Fkgs2;setforTesterModeCALLShowData;initializedisplayINIT—01;JPlS層;debug;*TestRoutines*;*Thisroutinecheckstheswitchesatpoweruptodeterminewhetherto*;*enteroneofthetestmodes.Thepossibletestmodesandtheswitch*;*combinationsthattriggerthemareasfollows.*,**;*MeterRateTypeTestMode*;*YxNPowerOnSelfTest(POST):LED,slightinsequence*1STYNManualSlowCharge(1hourmaxforallmanualmode)*;*NNYManualMediumCharge(Fastforboostmodels)*;*NYYManualFastCharge(Fast-Rapidforboostmodels)*;*YxYBurn-InMode:Fast/kapidChargefor60minutes*承;*Y->pressed,N->notpressed,x->either(notchecked)*,承承VestJRSMeterSwJ)RC,NoPOST;SkipaheadifMeterModebuttonnotpressedJRSTypeSw,DRC,POST;SkiptoPOSTifT}/pebuttonnotpressedJPTes&I;…otherwise,skipaheadtoBura-InsetupNoPOSTJRRRateSw:DRC,TESTl;CheckTypeswitchifRateswitchispressedJRSTypeSw,DRC,NoTest;gotoMAINifnoswitchispressed;SetforManualFastChargeSETRate,Flags;turaonFastLED,turnoffSlowLEDRESRapid,Flags2;turnoffRapidLEDRESH^wr,Flags4;turnoffhighpowermode;SETNoRamp,Flags4;setforFastratew/orampuptoRapidLDIOFFSET,OffFast;setforFastrateJPTestMMl(setforManualchargeNoTestJPMAIN;skiptestandgotoMAINTEST1;SetformanualSlowChargeJRRTypeSw,DHC,TEST2;ifTypeswitchispressed,setforFastTestCALLSetSlow;setforSlowRateCALLStartSlow;setOFFSETforSlowrate;LDIOFFSET,OffSlow;setOffsetfor2AJPTestMMl;setforManualchargeTestBI;Setfor60minuteBura-InSETBurnln,Flags3;SetforBurn-InmodeLDIOFFSET,OfBFast;setforFastrateRESHiPwr,Flags4;turnoffhighpowerCALLSetRmpUp;preparetorampfromFasttoRapidTEST2;setforManualR邻idCharge;SETManual,Flags3;setforManualmodeSETRate,Flags;setfornon-SlowrateSETHapid,Flags2;tumonRapidLED;RESNoRamp,Flags4;setforrampingJRSBumln,Flags3,TestRap;don'tsetforrampdownifBurn-InSETHiPw,Flags4;turnonhighpowerLDIRmpCnt,RCinit;1000,75-secondintervalsyields75sees;RESRampUp,Flags3;setforrampdownLDIOFF犯T,OffRap;s改OffsetforRapidChargeCALLSetRa边p;setrampingparametersTestRapJPTestMMl;setforManualchargePOSTCALLResetLEDs;turaoffalltype,rate&StatusLED'sCALLMeterOff;tumoffallmetermodeLED'sCALLDigitsOff;tumoff3-digitLEDRESPower,Flags2;makesureoutputwillbeoffCALLSetl2V;setforRegular,12VbatteryCALLHoldType;showTypeandwaitaFifthsecondSETBatTypeA,Flags;tumonDeepCycle&turnoffRegularLEDCALLHoldType;showTypeandwaitaFifthsecondSETBatTypeB,Flags;turaonGeJ/AGMLEDRESBatTypeA,Flags;tonoffDeepCycleLEDCALLHoicJType;showTypeandwaitafifthsecondRESBatTypeB,Hags;tunioffGel/AGMLEDSETBat6V,Flags2;turnON6VLEDCALLHoldType;showTypeandwaitaFifthsecondCALLResetLEDs;turnoffalltype,rate&StatusLED'sRESBat6V,F!ags2;setfor12Vbattery(not6V)SETChMode^Flags2;mustsetflagtoshowrateLED'sRESCra昧Flags;turno任CrankLEDCALLSetSlow;setforSlowRateLDILEDnum,SlowAmps;setdigitalLEDtoshowSlowrateCALLH。ldRate;showRate叫dwaitaFifthsecondSETRate,Flags;tunionFastLEDLDILEDnum,FastAmps;setdigitalLEDtoshowFastrateCALLHoldRate;showRateandwaitaFifthsecondSETRapid,Flags2;turnonRapidLEDLDILEDnum,RapAmps;setdigitalLEDtoshowRapidrateCALLHoldRate;showRateandwaitaFifthsecondRESChMode,Flags2;clearflagtodisableoutputLDILEDnum-CrakAmps;set出gitalLEDtoshowCrankrateCALLShowNura;getdatatosSowtheLEDmimberCALLShowCrank;turaonCrank(Boost)LEDCALLFi他Second;waitoneFifthsecondCALLResetLEDs;tumoffalltype,rate&StatusLED'sCALLShowData;updatedisplaySETMtrUnits,Flags;setfor%LEDsON,voltsLEDoffRESMtrScaleJlags;setforAlternator%LEDoffLDIDigiDatl,DigiRevl;setdigitalLEDtoshowCodeRevisionLDIDigiDat2,DigiRev2;setdigitalLEDtoshowCodeRevisionCALLShowData;updatedisplayCALLHoldMtrMd;showmetermodeandwaitonefifthsecondRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffCALLHoldMtrMd;showmetermodeandwaitonefifthsecondSETMtrUnits,Flags;setfor%LEDsON,voltsLEDoffSETMtrScale,Flags;setforAlternator%LEDONCALLHoldMtrMd;showmetermodeandwaitonefifthsecondCALLMeterOff;tunioffallmetermodeLED'sCALLAlertON;tumonAlert(Red)LEDCALLFi他Second;柳itoneFifthsecondCALLShowChgng;lightChargingLEDCALLFi他Second;柳itoneFi他secondCALLResetLEDs;tumoffalltype,rate&StatusLED'sCALLShcwGreen;lightGr鄉LEDonlyCALLFifthSecond;waitoneFifthsecondCALLResetLEDs;turnoffalltype,rate&StatusLED'sLDILEDnrai,5^initializeto5toshow41stPOST2DECLEDmim;thenextnumberwillbe1lessCALLNumData;getdatafor,andshowLEDmunberCALLHfthSeco";waitonefifthsecondLDA,LEDnum;checkforl朋tnumberJRNZPOST2;loopbackandrepeatifnottherePOST3ADDIA,20;adding20changes2nddigitLDLEDnum,A;preparetoshownewnumberCALLNumData;getdatafor,andshowLEDnumberCALLF她Second;waitonefifthsecondLDA'LEDnum;checklatestnumberCPIA,IOO;comparetolastnumberJRNZPOST3;loopbackandrepeatifnotthereCALLResetLEDs;turnoffa2I—e,rate&StatusLED'sCALLInitState;resettoSlow,TypeAchargemodeKESChMode,Flags2;setforTestermodeJPTEST;repeatPOSTifnecessaryTestMMl;SetformanualchargeSETManual,Flags3;setforManualmodeSETChMode,Flags2;setforChargerMode(outputenabled)RESDisable,DR3buf拜bleoutputLDICurentSS,15;State15isManualchargeSETStartedjFlags;setFlagsforchargestartedSETPower,Flags2;tellPwConchargerisonCALLIniTimel;initializeTimerlLDIHrsl,l;setTimerlforihourJURBurnli^Flags3,MAIN;skipnext2linesifnotBurn-inTestMM2CALLIniTime2;resetTimer2LDIMins2,1;settimerforcounterinterval(1minute)LDICCDcnt,60;setBurn-inminutecounterto60*BecausetheA/Dvoltageisbeingaveraged,itwouldtakeconsiderable**timetonoticethatabatteryhasbecomedisconnected.Toovercomethis**DELAYtheprogramwillmonitortheinstantaneousvoltageeachtimethru**thelooptodetectthiscondition.Thischeckwillbemadeonlyifthe**unitisinachargingmode,*MAINCALLRstWDR;resetwatchdogtimerLDA,CurentSS;getcurrentstateCPIA,ABORT;clieckforabortJRNZMainMore;continueMainifnotAbortJPMAIN3;don,tcontinueMainifAbortMsinMoreJRRManual,Flags3,MainAuto;continueMainifnotManualModeJPSS15;otherwise,gotoManualchargeMsinAutoJRSCrankWait,Fags,MAINl;don'tcheckswitchesduringCrankwaitCALLCheckSw;checkifswitchisbeingpressedMAIN4JRSCrank,FIags,MAINO;sWpaheadifduringCrankCALLGetPercent;updatethepercentagereadingCALLUpdateBP;update°/DtodisplayCALLGetMeter;updatedisplayJHRIdle,Flags3,MAIN0;skipaheadifnotidleJRRBatt,Flags2,MAIN0;don'tcheckidletimelimitifnobatteryJRSIdleSet,Flags4,MAIN5;don,tsetidletimerifalreadysetCALLIniTimel""otherwiseinitializetimer1LDIMinsl,0Ah;settimer1for10minutesSETIdleSe仁Flags4;Idletimerstarted,setflagMAIN5JRRMIN,TicFlagl,MAINO"..otherwise,checkidletimelimitRESDisable,DRBbuf;".enableoutputafteridletimelimitJPMAIN2;",andre-initializeifreachedMAIN0jnotCrankycheckfor0or1JRSPower,Flags2,MAINl;chargerisON,goto0VcheckJRSLEDchgug,DRAbuf;MAIN3;chargernotalmoston,skip0VcheckMAIN1;Checkfo;disconnectedbatteryCALLCheckBatt;checkfordisconnectedbatteryJRSBatt,Fags2,MAIN3;skipaheadifcoxmectedMAIN2;0Vdetected,preparetostartoverfromstate0LDIDspPcnt^O;initializedisplayPercentto0CALLInitState;initializetoSlowRegularChargemodeMAIN3*SEQUENCESTATEJUMPTABLE**Determinewhatroutinetoexecuteonthispassthroughthetheloop.Only**oneroutineisexecutedeachtimethroughtheloop,*NSS0LDA,CurentSSJRNZNSSlJPSSO;*SSO-BATTERYDETECT*NSSlCPIA,001h廳ZNSS2JPSSI;*SSI-BATTERYDETECTDELAY*NSS2CPIA,002hjenz:nss3jpss2;*ss2-automaticchargestart*NSS3CPIA,003hJRNZNSS4JPSS3;*SS3-BELOW9Volts*NSS4CPIA,004hJRNZNSS5JPSS4;*SS4-BELOW12Volts*NSS5CPIA,005hIRNZNSS8JPSS5SS5-NORMALCHARGE*鹏6;CPIA,006h;JRNZNSS7;JPSS6;*SS6-dv/dtMONITOR*NOTUSED鹏7;CPIA,007h;则ZNSS8;JPSS7;*SS7-CHARGECOMPLETE*NOTUSEDNSS8CPIA,008hJKNZNSS9JPSS8;*SS8-ABORTCHARGE*NSS9CPIA,009h厕ZNSSllJPSS9;*SS9-DESUtFATION*NSS10;CPI入00Ah;厕ZNSSll;JPSSIO;*SSIO-RESTORECHARGE*NSS11CPIA,OOBhJRNZNSS12JPSSll;*SSll-dV/dtMONITOR*NSS12CPI、00ChJRNZNSS13JPSS12;*SS12-dl/dtMONITOR*NSS13CPIA,OODhJKNZNSS14JPSS13;*SS13-ENDCHARGE*NSS14CPIA,OOEhJRNZNSS15JPSS14;*SS14-MAINTAIN*NSS15CPIA,OOFh歷ZNSS16JPSS15;*SS15-Manual*NSS16CPIA,010hJRNZNSS17JPSS16;*SS16-CRANK*NSS17CPIA,Ollh厕ZNSS18JPSS17;*SS17-CRANK*NSS18CPIA,012hJKNZNSS19JPSS18;*SS18-CRANK*NSS19CPIA,013hJRNZ:NSS20JPSS19;*SS19-CRANK*NSS20CPIA,014hIRKZNSS21JPSS20;*SS20-CRANK*NSS21LDIWDR,OOlh;invalidsequencestate,reset*ENDOFMAIN**WaitforNMI,whichindicatesendofFETonperiod,beforemeasuring*batteryvo肚age.*ExilMainXMainWAITjwaitforinteruptJRS丽I賊Flags2,XMain;timerinterupt*READBATTERYVOLTAGE**Thisroutineisexecutedatornearzerocross.Thecurrentvoltage**isstoredinCurVoltandthereadingisaddedtoBADhi(twolocations).*BADhiwillcontainarunningaverageofthelast256readings,*BADREAD.IFCEQShoADC;assemblenext2linesonlyifdebuggingSET2,DRBbuf;setPB2whenA/DsamplingstartsCALLUpdatePB;updateportBfrombuffer,ENDCLDA,BADlo;getaveragereadingSUBA,BADhi;subtractonereadingfromtherunningtotalJRNCBADREAD1;nocarry,goonDECBADhi;adjusthighorderbitsBADREAD1LDBADlo,A;storenewvalueLDIADCR,0B0h;startA/DconversionLDIADCRjOBOh;doagaintoinsureavalidstartWAIT;lettheinteruptnotifyuswhendataisreadyLDCurVolt,A;savecurrentreadingADDA,BADlo;addintorunningaverageJRNCBADREAD2;nocarry,goonINCBADhi;incrementhighbitsBADREAD2LDBADlo,A;storenewlowbits.IFCEQShoADC;asseniblenext2linesonlyifdebuggingRES2,DRBbuf;setPB2whenA/DsamplingstartsCALLUpdatePB;updateportBfrombuffer.ENDC;LDIORB,01Fh;LDIORB,09Fh*di/dtAVERAGECALCULATION**Forusebythedi/dt,aboutfourtimeseverysecondtheaverageofthe'*previous32curvoUreadingsisstoredinFreshBVforcomparisontoa'承readingtakenonceeverysecond,*DIDTAVGLDA,Temp2;ifTemp2=0thenfirstreadingIRNZDIDTAVGI;skipinitifnot1streadingLDITemp2,02他;initializeTemp2to32DIDTAVGILDA,FBVTotLo;ADDA,CurVolt;addcurrentvoltagetototalJKNCDIDTAVG2;don'tinchighbytsifnocanyINCFBVTotHi;inchighbyteDIDTAVG2LDFBVTotLo,A;updatetotalDECT咖p2;邵dateTemp2JRZDEDTAVG3;computeavgJPDIDTAVGX;exittoMainDIDTAVG3LDITemp2,003h;preparetoshift3timesDIDTAVG6LDA,FBVTotHi;loadhighbyteoftotalintoaccumulatorSLAA;shiftaccumulatorleftLDFBVTotHi,A;updatehighbyteoftotalLDA,FBVTotLo;loadlowgyteoftotalintoaccumulatorSIAA;shiftaccumulatorLDFBVTotLo,A;updatelowbyteoftotalJKNCDIDTAVG4;迈sbwaszero,skipnextlineINCFBVTotHi;DIDTAVG4DECTemp2;decloopcounterIRZDIDTAVG5;ifzero,finishaverageJPDIDTAVG6;notzero,shiftagainDIDTAVG5LDA,FBVTotHi;storeaverageinFreshBVLDFreshBV,ACLRFBVTo胆CLRFBVTotLoJRS7,FreshBV,DA7;skipaheadif>8.5VRESHi6V,Hags3;clearHi6VflagJPDinLWG;X;andskiptoraidofroutineDA7SETHi6V,Flags3;setHi6VflagDIDTAVGXJPM細*Thisiswherethesequencestatesaredefined.Thenumberofagiven*sequencestatehasnorelevancetotheorderinwhichitisactuallyBATTERYDETECT*Thisisthechargeridlestate.Theprogramremainshereuntilabattery*isdetected.Dectectionisdeterminedbyfindingapositivevoltage*greaterthano加volt,*SSO;RESCrank,Flags;clearCrankbitofFlagsCALLShutOff;low&highpccwer,fan,&craxikoff;mindutyCALLShowRate;turnoncWgerateLED(SloworFast)CALLShowType;turnonbatterytypeLED(Reg,D/CorGei)CALLChrgRly;changeE/SrelayifnecessaryIRSChMo5e,纟iags2,Ready;continueroutineifinChargerModeCALLCheckBatt"..otherwise,checkiftestershouldshowO'sJPSSOEXIT;...andexitReadyIRRStarted,Flags,SS00;skipifoutputhasn'tbeenonRESStarted^Flags;setFlagsforchargenotstartedSS00LDA,FreshBV;checklatestaveragevoltageJRNZRvrsBatt;Isit0(exactly)CALLShowRed;turnonRedLEDuntilbatteiyisdetectedJPSSOEXIT;...Yes:mustberev.batt,sostopRvrsBattCPI入VoltsO+l;No:otherwise,checkif>0.7VIRCPulse;no:trypulsingtheoutputJPSS0一1;yes:setupfornosparkdelayPulse;turnonchargerfor1cycleeachsecondLDA^MSecsl;pulseoncepersecondCPIA'MSINIT;timetopulseJRZPulseON;yes,gototopulsecodeRESPower,Flags2;otherwse,telltimertoleavechargeroffJPSSOEXIT;andkeepwaiting(untilnextsecondstarts)PulseON;pulsechargerononcepersecondSETPower,Flags2;tellPtvtCohchargerison;GALLShowGreen;turnonGreenLED***test***IPSSOEXIT;nobattery,justexitSSO—1CALLIniTimel;setuptimerLDISecsl,002h(adjustfor2secondsLDITries,005h;5TriesfordebounceSETO,CurentSS;goontoBATTERYDETECTDELAYSSOEXITJPExitMain*BATTERYDETECTDELAY**Thisstatechecksthatavoltageispresentfortwoseconds.Ifthe**voltagedropsbelow1"Vdc,thetimerisrestartedandthe"try"counter**isdecremented.Ifafter5Triesthevoltagehasnotbeenabove1Vdc**for2seconds,gobacktobatterydetect.Thisdelayhastheeffectof**debouncingtheleadsbeingconnectedtothebattery.*<table>tableseeoriginaldocumentpage305</column></row><table>CALLGetPercent;updatePercentforinitialvoltageLDA,Percent;getlatest%LDDspPcnt,A;storelatest%inDispkyPercentRESWaitOP,FIags2;setflagtoindicatenotwaitingJPSS2-BP;skipaheadSS2—CPIA,IOO;checkfor100%JRN2SS2—BP;continueState2ifnotl00%CALLSetMinOff;limitoutputtomax2Acurrent;LDILowOf《MinOff2;limitoulputtomax2Acurrent;IRRBat6V,FI昭s2,SS2—6S;skipnextlineifnot6Vmode;LDILowOff,Min60fE2;lhnitoutputtomax6V2acurrent;SS2—6SJPSS5—Maintotherwise,gotoMaintainSS2—CALLShowChgng;turnChargingLEDonCALLIniTimel;initializetimer1LDIMinsl,5;settimer1for5minutes;LDISecsl,005hjsettimer1for5secondsLDICCDcnt,MaxHrs;setintervalcountertoMaxHrsCLRLastBart,'dearLastBatt(ensurepass1sttest);SETSOC,Fiags4;setStartOfChargeflagCALLIniTime2;initializetimer2LDISecs2,0011i;settimerfor1secondLDIMSecs2,MS500;settimerfor500milliseconds(0.5secs)LDIMins2,006h;settimerfor5minutesand2secondsLDIHrs2,005h;settimerfor4hours,5minutes&2secondsJRSRate,Fkgs,SS2Fast;skipaheadifnotsetforSlow;…otherwise,setforSlowchargeCALLStartSlow;setOFFSETforSlowrate;LDIOFFSET,OffSlow;setOffsetfor2A;JRRBat6V,Flags2,SS2Slo;skipifnotsetfor6Vmode;LDIOKFSET,O筋Slo"..otherwise,adjustOFFSET;SS2SbJPSS2一0ajslcipaheadandreadvoltageSS2Fast;setforFastchargeLDIOFFSET,OffFast;setOffeetforFastrateJRRBat6V,Flags2,SS2Fst;skipifnotsetfor6VmodeLDIOFFSET,Off6Fst;…otherwise,adjustOFFSETSS2FstJRRRapid,Flags2,SS2Rap;skipaheadifrateisnotRapidCALLSetRmpUp;preparetorampfromFasttoRapidSS2Rap;setforRapidchargerateJPSS5—0a".otherwiseskipaheadandreadvoltageSS2一0a—CALLGetBatt;getlatestvoltage<&doubleif6VmodeCPIA,Volts09;verylowbatteiyJRNCSS2—2;no,trynextlimitSS2—1;B^tery<9VLD"003h;yes,serviceit,below9VOLTSSJPSS2一5SS2—2—;Battery>9VCPIA,Volts12;lowbatterystateJRNCSS2一4;加,gotoSS5SS2—3;9A7"<Battery<12VLDfA,004h;yes,serviceit,below12VOLTSSJPSS2一5SS2—4;Battery>12V;Jr5Alert^lags2'SS2EXTT;don'tstartchargeifAlertsetbyDouWe6VLDIA,0051i;normalchargeSSSS2一5Ul)"tlurentSS,A;preparetogotothecorrectstate(3,4or5)SETStarted,Flags;setFlagsforchargestartedCALLTumON;turnoutput,Fan,andChargingLEDonSETSettle,Flags3;initialchargevoltagesettlemodeSS2EXITJPExi她in*BELOW9Volts**Batteryisextremelydischargedandmaybebad.Chargeforamaximum**offiveminutes.Ifvoltagedoesnotcomeabove9VoJtsinthistime**period,abortcharge.Otherwise,gotobelow12Volts.SS3CALLChkRapid;updateRamptimer,ifnecessaryIRRSEC,TicFkg2,SS3EXIT;exitifvoltagesettletimenotexpiredRESSettle,Flags3;clearsettleflagCALLIReg;regulatecurrenttillwegettodV/dtJRRMIN,TicFlag2-SS3—1;checkiftimehasexpiredCALLSetAbort;yes,timetoabortJPSS3EXITSS3一1CALLBattProg;checkbatteryvoltageforchargeprogressCPI入Voits09;isbatterytipto9VJRCSS3EXIT;continuestate3if<9VINCCurentSS;.-.otherwise,gotostate4SS3EXITJPExitMain*BELOW12Volts**Batteryisverylow.Allowamaximumof2hoursforthevoltageto*riseabove12voltsundercharge.Ifvoltagedoesnotcomeup,goto*abortcharge.Otherwisegotonormalcharge.*SS4CALLChkRapid;updateRamptimer,ifnecessarySEC,TicFlag2,SS4EXIT;exitifvoltagesettletimenotexpiredRESSettle,Flags3otherwise,clearsettleflagCALLIReg;regulatecurrenttillwegettodV/dtJRRHR,TicFlag2,SS4—1;clieGkiftime(4hours)hasexpiredCALLSetAbort;yes,timetoabortJPSS4EXIT;exitroutineSS4一1CALLBattProg;checkbatteryvoltageforchargeprogressCPIA,Volts12',isbatteryupto12VJRCSS4EXIT;…if加t,justexitINCCurentSS"..otherwise,gotostate5SS4EXITJPExitMain;*NORMALCHARGE*;*Programstayshereuntilthevoltagereaches14,2vo〗fsorthemaximum*;*chargetimeisexceded.Ifthevoltagelimitisreachedtheprogram*;*willtransferto:*;*A.SSB(dV/dt)ifthethebatteryhasbeenchargingmorethan5*,minutesor*;*B.SS9(Desulfation)iftheOCVwaslessthan12.2voltsor*;*C.SS14(Maintain)iftheOCVwasmorethan12.2volts*;*Ifthemaximumchargetimeisexcededtheprogramwillabort*^S5CALLShowChgng;tonChargingLEDonCALLChkRapid;updateRamptimer,ifnecessaryJRRSEC,TicHag2,SS5x;exitifvoltagesettletimenotexpiredRESSettle,Flags3;…oHierwise,clearsettleflagCALLBattProg;checlcbatteiyvoltageforchargeprogressJRRHR,TicFlagl,SS5一0;skipnextlineifmaxtimenotexpired;NOTE:CurentSSs^itoABORTbyBattProg.ChkProgSS5xJPSS5EXIT;exit(andabort)ifmaxtimeexpiredSS5一0JE^"Rate,Flags,SS5一0b;cliangedeltaifslowrateCPI入Voltsl42+l;checkifover14.2voltsyetJPSS5」SS5一0bCPfA,Voltsl42+3;checkifover14.2voltsyetSS5一1JKNCSS5—2;yes,checkif>5minutesCALLIReg;no,regulatecurrenttillwegettodV/dtJPSS5EXIT;...andjustreturnSS5一2LD"XcCDcnt;getCCDcnt(setbyBattPRogw/minutes)LDHrsl,A;setTimedhourstoCCDcntRESHiPwr,Flags4;setforlowpowermodeRESRmpInt,Flags3;clearflagbeforemovingon;RESSettle,Plags3;clearflagbeforemovingonJRSMIN,TicFlag2,SS5—3;if>5min,gotodV/dtLDA,OldVolt;otherwise,checkinitialvoltageCALLDouble6V;doubleBatteryvoltageifsetfor6VCPIA,Volts122;initialvoltage<12.2VJRCSS5—5;Yes:thendesulfateJPSS5J^aint;No:gotoMaintainSS5—5一LDfCurentSS,009h;batteryissulfatedLDIMaintVolt,Voltsl6;trytoholdbatteryat16VLDIVref,Volts15;andseeifitdropsto15VCALLIniTime2;LDIHrs2,002h;inlessthan2hoursJPSS5EXIT;SS5一3CALLSetMinOff;min2Aoffsetvalue(maxcurrent)LDILowOff,MinOff2;rnin2Aoffsetvalue(迈axcurrent)JRRBat6V,Flags2,SS5一6V;skipnextlineif加t6VmodeLDILowOff,Min60ffi;min6V2Aoffsetvalue(maxcurrent)SS5一6VJRRRate,Flags,SS5一6;checkfor15AchargerateLDILowOff,MinOffl5;min15Aoffsetvalue(maxcurrent)JRRBat6V,Flags2,SS5—6;skipnextlineifnot6VmodeLDILowOff,Min60ff15;min6V15Aoffsetvalue(maxcurrent)SS5—6LDA,LowO任;LoadLowOffintoAfornextstepLDOldOff,A;initializeOldOfffordi/dttoLowO任LDICurentSS,00Bh;gotowaitfordv/dttripvoltageLDIPercent,77;setPercentto77CALLIniTime2LDIMins2,13;setto13minutesfordV/dtLDA,BADhi;getlatestbatteryvoltageSUBI入4;preventmatch@1stdV/dtcheckLDMaintVo[t,A;storeasmaintainvoltagefordi/dtLDITries,004h;initializedV/dtfor4Tries(3intervals)JPSS5EXTT;SS5—Maint;gotoMAINTAIN,batteryisalreadychargedCALLSetlOOp;setPercentto100LDIMaintVolt,Volts132;setmaintainvoltagetoB.2V;CALLFanOff;tumcoolingfanoffJRRBatTypeB,Flags,SS5—7;skipaheadifnotGel/AGMLDIMaintVolt,Volts135;^tmaintainvoltageto13,5VforGd&AGMSS5—7LDfCurentSS,00Hi;Maintainisstate14(OEhex)CALLSetON;turacoolingfan&outputonCALLFanOff;turncoolingfanoffCALLSetHiOff;MAXoffeetvalue->mindutycycleSS5EXITIPExitMain556557*SS8-ABORTCHARGE**TurnoffallLED's.BlinkTROUBLELEDathalfsecondinterval.IP*batterybecomesdisconnected^gotoBATTERYDETECT.*SS8SETAlert,Flags2;s改Alertflag;CALLShutOff;low&highpower,f叫&crankoff;mindutyCALXSetOff;turnoffpowerandsetformindutyCALLChrgRly;changeE/SrelayifnecessaryCALLBlinkAlert;blinkredLEDJRSBurnln,Flags3,SS8X;don'tcheckforbatteryifBum-InCALLCheckOV;checkfordisconnectedbatteryJRSBatt3Flags2,SS8X;ifconnected,justexitRESAlert,Flags2;…otherwise,endabortroutineSS8rstJPMAIN2;re-initializeSS8XJPExi她in*SS9-DESULFATION**DesulfationModeisenterediftheinitialbatteryvoltageisless**than12,2voltsandthevoltagereaches14.0voitswithinfive**minutes.**Thechargertriestoholdthevoltageat16,0volts.Asthebattery**startstoconduct,thevoltagewillfall.Ifthevoltagereaches14.0**inareasonabletimelimit(10hours),wewilltransitiontothe**normalchargingsequence(SS5),Ifthevoltagedoesn'tfellto14.0*voltswewilitransitiontotheABORTsequencestate(SS8).*SS9LDIPercent,15;setto15%CALLBlnkChrg;blinkChargingLEDCALLCheckBatt;checkforconnectedbatteryJRRBatt,Flags2,SS8rst;re-initializeifnotconnectedCALLVoltRegJRRSEC,TicFlag2,SS9X;wait1minuteJRRHR,TicFlag2,SS9—1;maximumtimeout(1or2hours)DECCurentSS;AB6"RTstateSS9exitIPSS9X;doneSS9一1CALLGetBatt;getlatestvoltage&doubleif6VmodeCPA,Vref;arewethereJRNCSS9exit;ifnot,thenexitDECVref;1countis0.0667voltsDECVref;reduceVrefby0.133voltsLDA^Vref;seeifbattisdesulfatedyetCPI入輔sI4;isVref<14.0VoltsJRNCSS9一3;no:tryanotherhourLDICurentSS,005h;yes:preparetogotonormalchargeUDA,Vmax;setMaintVolttoVmaxLDMaintVolt,A;maintainvoltageforstate5CALLIniTime2;initializetimer2LDISecs2,002h;settimerfor2seconds(voltagesettletime)JPSS9X;SS9一3CALLIniTime2;resettimerLDIHrs2,00lh;setmaxtiiefor1hourSS9XJPExitMainSS10*dV/dtMONITOR**Thisstateislookingforoneofthreeconditions:**1.Maximumtimeisexceded-setforcheckbatteryandturnoffcharger.:*2."NochangeindV/dtfor45minutes-batteryisabout80%charged.**3.MAXvoltageisreached-GOTOdl/dt.*SSllJRRHR,TicFlagl,SS11—1;Ifnotmaxtimeo叫gotoSSll一lCALLSetAbort;otherwise,gotoabortJPSS11XSSIl一lCAliShowChgng;lightChargingLEDCALLGetBatt;getlatestvoltage&doubleif6VmodeCPA,Vmsx;isbattvotage<MAXJRCSSI1J2;yes:continueloopSETHiEn5,Flags3;no:settoboostduringD/CEndChargeJPSSI1—6;...andpreparetoGOTOdl/dtSS11一2一IRR"klN,TicFlag2,SS1IX;exitifnottimefordv/dttestLDA,Percent;getPercentCPIA,84;kPercent<84则CSSI1—3;…ifnot,skipaheadINCPercent"..otherwise,increasePercentSSll—3LDA,BADhi;getbatteryvoltageDECA;limitfor6Vbatteriesis1countJRSBat6V,Flags2,SSl1—3a;leavelimitat1for6VbatteriesDECA;limitfor12Vbatteriesis2countsSSll一3aCPA,MaintVolt;testforupperlimitchangeJRCSSI1—4;lessthan1countup,testdownchangeJPSSIl一7;otherwise,skipahead&updateMaintVoltSS11—4—DECTries^decrementcounterIRZSS11一6;alldone,GOTOdl/dtLDA,Percent;getPercentCPIA,87;isPercent<88厕CSS11—5;..,ifno、skipaheadINCPercentotherwise,increasePercentSSll—5JPS§11—8;no,reloadtimerSSll—6—INCCurentSS;GOTOdl/dtnextLDIPercent,88;setPercentto88-NOTEmustalwaysbeevenJRSHiEnd,Flags3,MntMx;skipaheadifV迈axreachedCALLGetBatt;getlatestvoltage&doubleif6VmodeLDMaintVolt,A;saveBADhiasmaintainvoltageJPSSI1—9;initializeTriesandTimer2fordi/dtMntMxLDA,V迈ax;otherwise,setMaintVolttoVmaxLDMaintVolt,A;MaintVoltusedfordi/dtJPSSI1—9;initializeTriesandTimer2fordi/dtSSll—7"updateMaintVoltLDA,BADhi;getcurrentbatteiyvoltageLDMaintVolt,A;updateMaintVoltford,&di/dtSS〗I一9LDITries,004h;resetcounter(4matches=3intervals)SSllSCALLIniTime2;initializetimerLDIMins2,009h;…for9minutesJPExitMain*di/dtMONITOR**Indi/dttheOFFSETvalueisadjustedtoholdthevoltageatthedV/dt**value.TheOFFSETvaluewillincreaseandstabilize,**Thisstateislookingforoneoftwoconditions:**1.Maximumtimeisexceded-setforcheckbatteryandturnoffcharger.**2.NochangeinOFFSETvaluefor39minutes-currentstabilizedata**lowvalue.Batteryisabout97%charged.GotoSS13(EndCharge)for**〗hour,*SS12CALLVoltReg;regulatebatteryvoltageatMaintVoltLD入DspPcnt;getlast%displayedCPI入IOO;has%displayedreached100JR2SS12—14;…ifso,turnongreenLEDCAULShowYdlow;…othenvise,turnonyeUowLEDJPSS12一15;."andskipahead(leavegreenofQSS12—14一CALLShowDone;turnonchargecompleteLEDSS12—15JRRllR,TicFlagl,SS12一l;maximumtimeoutIRSAleryFlags2,SSi:23);If2ndmaxti迈eout,goto0SETAlert,Flags2;If1stmaxtime,setAlertflagCALLIniTimel;andresettimerLDIHrs〗,0O42i;toalow4咖rehoursSS12—10LD入MaintVolt;andgetMaintainvoltageSUB1A,007k;thensubtract^0.5VLDMaintVolt,A;andupdateMaintainvoltageJPSS12EXIT;thenrestartdi/dtSSI2—0CALLSetAbort;gotoabortRESAlert,Flags2;resetAlertflagforAborttimerJPSS12EXITSS12—1JRRMIN,TicFlag2,SS12EXIT;timefordi/dttestLDA,Percent;getPercentCPIA,IOO;isPercent<100JRNCSS12一2;…ifnot,skipaheadINCPercent"..otherwise,increasePercentLDA,Percent;getpercent;Ispercent-100JRZSS12—2;YES,don'tincreaseanymoreINCPercent;No,increaseby2SSI2—2CAlic鹏iOff;checkforinaxOFTFSET(P丽MofO3KNCSS12—13;ifso,finishdi/dtDECA;ensurecarryifequalCPA,OldOff;testforlowerlimitchange<table>tableseeoriginaldocumentpage313</column></row><table>CALLSetl00p;setPercentto100IDA,DspPcnt;getlast%displayedCPIA,100;has%displayedreached100JKNZSS13—2;...ifso,加mongreenLEDCALLShowDone;tumonchargecompleteLEDSS13_2CALLVo欣eg;regulatebatteryvoltageatMaintVoltCALLChkHiOff;checkformaxOFFSET(PWMfiilloff)JRZSS13—1;exitifmaxOFFSETreachedJRRHR,T^Flag2,SS13EXIT;exitif1hourtimenotupSS13—1JPsS5_Maiirt"..otherwise,GOTOMAINTAINSSI3E:5tJPExitMain*MAINT細**Batteryhasreachedfoilcharge.Stayhereandmaintainbattery**at13.5voltsuntilbatteryisdisconnected*SS14CALLSetlO0p;setPercentto100CALLVoltReg;regulatebatteryvoltageatMaintVoltLDA'DspPcnt;getlast%displayedCPIXjOO;has%displayedreached100IRZSS14—1;…ifso,turnongreenLEDCALLShowYellow;…otherwise,turnonyellowLEDJPSS14一2;...andskipahead(leavegreenofi)SS14—1一CALLShowDone;turnonchargecompleteLEDSSI4—2CAliChkHiOff;checkformaxOFFSET(PWMfiillofQJKNCSS14—3;…ifso,shutofffanJRSBat6V,Flags2,SS14—5;skipaheadif6VmodeCPIA,HiOff-4;checkforsustainedo啤utJPSS14一7SS14—5一CPIAjHiOff6-4;checkforsustainedoutputSS14—7,5SS14—4;...ifnot,leavefanoffSS14—6CALLFanON"..otherwise,turnfanonJPSS14一4"..andskipaheadSS14一3一CALLFanOff;turncoolingfanoffSS14—4CALLCheckBatt;ctieckforbatteryJRSBatt,Flags2,SS14EXIT;".connected:continueJPMAIN2disconnected:startoverfromstate0SS14EXITJPExitMain;*SS15MANUAL*;*Regulatecurrent.Novo〗tagelimit.Resetafter〗hour,*,SS15JRRPower,Flags2,SSl5—2;poweroffindicatescompletedBurn-InCALLShowRate;tumonthe2Aor15ALED;NOTE:outputalreadyon,butTurnONsavescodespaceCAIXTurnON;turnoutput^Fan,andChargingLEDonCALLIReg;regulatecurrentatselectedrate;CALLCheckl7v;checkfordisconnectedbattery;IRNZSS150K;ifo17V,thencontinue;LDICurentSS,ABOHT"..otherwise,Abort;RESManual,Flags3;",endManualMode;JPSS15EXIT;...andskiprestofState15JRSBurnln,Flags3,SS15BI;skipaheadifBurn-inmodeRESMtrScale,Flags;setforAlternator%LEDoffRESMtrUnits,Fbgs;setforVoltsLEDON,batt%LEDoffCALLSliowMeter;updatemeterLEDsJPSS15rmp;jumptorampcheckSS15BIJRRM!N,TicFlag2,SS15b;skipaheadifnottimetoupdatecounterDECCCDcnt;decreasedisplaycountby1CALLIniTime2;resetTimei2LDIMins2,1;settimerforcounterinterval(1minute)SS15bLDAjCCDcnt;getlatestcountdownvalueLDLEDnum,A;stoeinLEDnumCALLStiowNum;displaycountondigitalLEDCALLMeterOff;turnoffallmetermodeLED'sSS15nopCALLShowData;updatedisplayJRRRapid,Flags2,SS15—1;don'trampifRapidisnotsetCALL6hlilapid;updateR咖ptimer,ifnecessarySS15—1JRR^R,TicFkgl,SS15EXIT;contiimeifnotmaxmanualchaxgetimeJRSBurnln,FIags3,SS15一2;skipaheadiffinishedBum-InJPRESET"..otherwise-res改SS15—2CAliDigitsOff;turaoff3-digitLEDCALLResetLEDs;turnoffalltype,rate&StatusLED'sCALLShcwGreen;liglitGreenLEDonlyCALLSetoff;resetPower&Crankingflags;setmin.dutySS15EXITJPExitMain;*BOOSTMODE**Firstsetthechargeroffsetvaluefor2ampcharging.Next,wait*;*forthevoltagetostabilize.Thenwaitforthevoltagetodrop*;*abouttwovolts.Whenthevoltagedrops,goftillonfor5seconds.*;*Afterfivesecondsofcranking,waitfor4minutesandstartover.*,*CommenttheCALLandthefollowingtwoLDl'sfortest.AlsoloadofeetwithPHASE15insteadofPHAZBOST*SS16CALLVoltMtr;setforvoltmeterandupdatedisplayJRSESrly,DRBbuf'SS16一0;skipaheadifrelayalreadysetforE/SGALLFi池Second;wait200mSSETESrly,DRBbuf;setE/SrelayforstartSS16—0CAliCheckBatt;makesurebattis>1.6VJRRBattjFlags2,SS16—1;skipaheadifnotconnectedJRSSEC,TicFlag2,BaiiOK;skipif>2secondssinceBoostselectedJPSS16Exit;if<2seconds,thenstayoffSSI6—1CALLTurnOff;low&highpowerandfanoff,mindutyCALLShowRed;tumonAlertLEDJPSS16Exit;ifbatt<1,6V,thenstayoffBattOKCALLShowCrank;turnONCrankLED&turnAlertLEDoffCALLTuraON;turnoutput,Fan,andChargingLEDonCALLSetffiOff;setformindutycycleSETStarted,Fkgs;setFlagsforchargestartedCALLIniTime2;resettimer2LDIMSecs2,MS200;setTimer2for200msINCCurentSS;setstateto17SS16ExitJPExitMain砂toendofloop*DELAYFORVOLTREADINGSS17JRSMSEC,TicFlag2,SS17—1;Is200msupJPSS17EXTT;no,justreiuraSS17一1CALLGelMeter;updatedisplayCALLCheckOV;makesureba忧isconnectedJRSBatt,Flags2,SS17—2;skipaheadifconnectedJPMAIN2;discomected,sostartoverSS17一2SUbTa,OIOIi;adjustforaonevoltdropLDOldVolt^A;saveitLDIMaintVoIt,Volts142;trytoholdbatteryat14.2(or7.1)VLDILowOff,OffCrank;limitratetoCrankoffsetJRRBat6V,Flags2,SS17一3;skipnextlineifnot6VmodeLDILowOff,Off6Cmkjlimitrateto6VCrankoffsetSS17—3INCCurentSS;waitforcrankCALLMT(me2;initializeTimer2LDIMins2,15;setTimer2for15mi加tesSS17EXITJPExitMain*WAITFORCRANK*SS18JTRRMIN,TicFlag2,SS18—0;waitforcrankonly15minutesJPMAEST2;thenstartre-initializeSS18—0CALLGe(Meter;updatedisplayCALLVoltR邻;regulatebatteryvoltageatMaintVoltLDAjFreshBV;getcurrentreadingSUBIA,O1Oh;adjustforaonevoltdropCPA,0dVot;hasvoltageincreasedIRCSS18一2;ifnot,thenskipaheadLDOldVo"It,A;updateOldVoltSS18xJPSS18EXIT;andexitroutineSS18_2LDA,FreshBV;getcurrentreadingCPA,OldVolt;1VdropmightindicatecrankingJRNCSS1;justexitifnodropADDIA,0Ch;storeFreshBV+0.8VinACPA,BADhi;islatestaverage>FreshBV+0,8V篇CSS18EXIT;ifBADhi>FreshBV+0.8V,startcrankingSSI8」SETPower,Flags2;turnoutputonINCCurentSS;timethecrankingSETCrnkng,Flags4;indicatecrankingstartedCALLIniTime2LDISecs2,CrankON;crankforCrankON(5)secondsSS18EXTTJPRdtMain;*CRANKTIMING*;*Allowcrankingforfivesecondsandthengobacktocharging,*『S19LDA,Secs2;getremainingcranksecondsLDLED加m,A;storeinLEDnumCALLMeteNum;showLEDnumandturnoffmetermodeLED'sIRRSEC,TicFlag2,SS19EXIT;ifcrankingnotfinished,thenexitRESSCRs,DRBbuf;turnoffSCR's(inbuffer)CALLUpdatePB;updateportBfrombufferCAllResetStatus;tumoffChargingLEDRESCrnkng,Flags4;indicatefinishedcrankingRESPower,Fkgs2;telltimertoleavechargeroffINCCurentSS;justwaitfortimetoexpireCALLSetoff;turnoffpowerandsetformindutySETCrankWait,Flags;indicatescrankcool-downtimeCALLIniTimel;resetTimerlLDISecsl,CCDint;settimerforcounterinterval(seconds)LDICCDcnt,CrankOff;setcrankcooldowncountertoCrankOffseesSS19EXITJPEx謹ain*INTER-CRANKDELAY**Stayhereuntilthe4minutetimerhasexpiredthengobacktoBOOST**ifswitchstillengaged,elsegoto2Aauto(default)*SS20317CALLFanON;tum咖lingfanON孤SEC,TicFlagl,SS20一0;sfcipaheadifnottimetoupdatecounterDECCCDcnt;decreasedisplaycountby1JRNZSS20—1;finishstate20ifcountdownto0RESCrankWait,FlagspresetCrankWaitbitofFlagsLDICurentSS,010h;setstateto16toCrankagainSETSEC,TfcFiag2;tdiState16thatE/SalreadyrunningJPSS20EXIT;andexitState20SS20—1CALLIniTimel;resetTimedLDISecsl,CCDint;settimerforcounterinterval(seconds)SS20—0LDA,CCDcnt;getlatestcountdownvalueLDLEDmxm,A;storeinLEDnumCALLMeterNum;showLEDnumandturnoffmetermodeLED's;RESRmpng,Flags3;clearflagforCheckBatt鹏Settle'Flags3;clearflagforCheckBattCA!XBlinkCrank;blinktheCrankLEDSS20EXITJPExitMain*SUBROUTINESSTARTHERE**Initializestate(Slowcharge,Regularbatt,State0)InitStateCLRFlags;0isdefaultforallbitsCLRFlags2;0isdefaultforallbitsCLRFlags3;settoindicatenoRapidtoFastchangeCLRTEMPI^initializeCLRCCDcnt;initializeRESDisable,DRBbuf;enableoutput;SETChMode,Flags2;setforChargerMode(chargermode)RESBSrly,DRBbuf;setE/Srelayforcharge(notboost)LDIOFFSET,ffiOfif-1;setformimimumoutputcurrentLDILowOff,OfiRap;limitmaxratetoMl60AoffsetLDISwData'01111101b;InitializeswitchLBDsfor2A,RegLDIVmax,V"olts155;"VmaxforRegularbatteriesLDIVltC:it,001h;initializeVltCntto1LDIVR叫00lhjinitializeVRcntto1LDIPcntL,001h^initializePcntLtoILDIPcntH,OOlh(initializePcntHto1LDICurentSS,000h;setchargerstateto0LDISecsl,SecInit;restartTMERlsecondcounterLDISecs2,SecInit;restartTTIMER2secondcounterRETResetWatchdogRegister*:ThisroutinesimiplyresetstheWatchdogregister,RstWDRwas*:onlytosaveprogramspace(LDIrequire3bytes,CALLrequiresonly2).RstWDRLDIWDR,0FEH;resetwatchdogtimerRET*SetAbortState**ThisroutinesimiplysetsCurentSStoABORTsothatthecodewillgo1*totheAbortstateafterthenextNMI.SetAbortwaswrittenonlyto**saveprogramspace(LDIrequire3bytes,CALLrequiresonly2).*SetAbortLDICurentSS,ABORT;setcurrentstatetoAbortRET*Set100Percent**ThisroutinesimiplysetsPercentto100.SetlOOpwaswrittenonlyto:*saveprogramspace(LDIrequire3bytes,CALLrequiresonly2).*SetlOOpLDIPercent,100;setPercentto100RETClearPercent*;ThisroutinesimiplysetsPercentandDspPcntto0.ClrPcntwas*;writtenonlytosaveprogramspace((Xkrequire3bytes,CALLrequires:only2),SetOpisthesecondhalfofClrPcnt.*Set0Percent*:ThisroutinesimiplysetsPercentto0.SetOpwaswrittenonlyto*:saveprogramspace(LDIrequire3bytes,dALLrequiresonly2),*ClrPcntCLRDspPcnt;setDisplayPercentto0SetOpLDIPercent,O;setPercentto0RET*UpdatePortA**ThisroutineupdatesPortAwiththecontentsoftheDRAbuffer.*UpdatePAwaswrittenonlytosaveprogramspace.*UpdatePALDA,DKAbuf;updateAccumulatorfrombufferLDDRA,A;updateportfromAccumulatorRETUpdatePortB*:ThisroutineupdatesPortBwiththecontentsoftheDRBbuffer,:UpdatePB柳swrittenonlytosaveprogramspace.*UpdatePBLDA,DRBbuf;updateAccumulatorfrombufferLDDRB,A;叩dateportfromAccumulatorRET*UpdatePortBOptions**ThisroutineupdatesthePortBoptionswiththecontentsoftheORB*buffer,UpdateORBwaswrittenonlytosaveprogramspace.*UpdateORBLDA,ORBbuf;updateAccumulatorfrombufferLDORB,A;updateoptionsregisterfi:omAccumulatorRET*WaitaF她Second**Thisroutinecausestheprogramtowaitonefi他secondbywaiting*for24interrupts,*Fi他SecondCALLIniTimelLDIMSecsl,MS200;settimerfor1/5secondWFS一lCALLRstWDR;resetwatchdogtimerJRRMSEC,TicFlagl,WFS一l;waituntiltimergoesto0RET—SetRampUp*:Thisroutinesetstheparametersnecessarytochangethedutyfi:oirithe:fastratetotherapidrate.ItisusedbeforeBum-InandAutomatic*:Rapidcharge.*SetRamp*:Thisroutinesetstheparametersnecessarytochangethedutybetween'thefastandrapidrates.ItisactuallythelastpartofSetRmpUp.*SetRmpUpLDIRmpCnt,RCinitX2;1801-secondintervalsyields180secondsRESHiPwr,Flags4;setforlowpowerSetRampLDITEMP,RIiBit;120NMIinterruptsyields1,5secondsSETRmpInt,Flags3;咖nting1stoftwo180cycleperiodsRETCHECKRAPID;*Thisroutinedetermineswhethertoreduceorincreasethechargerate;*fromRapidtoFastorvicaversa,ifnecessary.Itsetstheflags*usedbyRampOSappropriately.*,水承ChkRapidJRRRapid,Flags2,ChkRapX;ifnotRapidchargerate,thenexitDECTEMP;otherwise,updateramptimerJRNZChekRapX;exitifnottimetoupdatecountLDITEMP,RIinit;count180morecycles(1.5sec)JRRRtDpIntjFlags3,RmpCtr;skipaheadifjustcounted1sthalfRESRmpInt,Flags3"'.otherwise,startcounting2ndhalfChefcRapXJPChkR叩X;…andexitRmpCtrSETRmpInt,Flags3;counting1stoftwoISOcycieperiodsDECRiiipCnt;checkiftimetorampJRNZChekRapX;exitifnottimetorampJRRHiPwr,Flags4,StRmpUp;skipaheadifchangingtohigherrateRESEKPwr,Fiags4;setnotHiPwr(changetolowerrate)LDIOFFSET,OfiEFast;setforFastrateLDIRmpCnt,RCinitX2"..otherwise,doubleinter-ramptimeJPChkRapXStRmpUpSETHiPwr,F〗ags4;setflagsfor>FastrateLDIOFFSET,OffRap;setOffsetforRapidChargeLDIRmpCnt,RCinit;1003-secondintervalsyields5minutesChkRapXRET;*SHOWNUMBER*.;*ThisroutinedetermineswhatthreedigitstodisplayonthedigitalLED;*torepresentthenumberstoredinLEDNum.Thethreedigitswillbe*;*displayednexttimetheShowDataroutineiscalled.*ShoWNumCLRIndex^initializeLU丁Indexto0CALLDigiOff;setregistersforallsegmentsoffLDA,LEDmim;storeLEDnuminaccumulatorCPIA,10;checkforsingledigitnumberJRNCChkMaxNum;…ifnot,checkformaxnumberJPNextOOlotherwiseskipto3rddigitChkMaxNumCPIA,199;checkforhighestdisplayablenumberJRCCheckl00;ifless,checkvalueJLDIAJ99"-.otherwise,displaly199CheddOOCPIA,100;checkwhehtertoshowmostsignificant1JRCCheck010;ifnot,checkfor10RESDigitl,DigiDat2;otherwise,turnONmostsignificant1SUBIA,IOO;...andsubtract100;fromaccumulatorCheck010CPIA,IO;checkif<l0JRCCheck001;…ifso,skipaheadandcheck3rddigit<formula>formulaseeoriginaldocumentpage322</formula>SUBIA'VoltslO;…andsubtract10VfromaccumulatorChecfclVCPIA,VoltsOl;checkif>1.0VJRCCheckOlV;…ifso3skipaheadandcheck3rddigitINCIndex;…otherwise,stownexthighervalueSUBIA,VoltsOl;..,andsubtract1,0VfromaccumulatorJPChecklV;-.,andcheckfornexthighervalueCl咖kOlVLDAT咖p,A;saveAccumulatorLDIDRWR,DigitsOxO.w;lookuptable(LUT)for2nddigitLDIX,DigitsOxO.d;initializeLUTLDA,Index;getindexfromstartofLUTAM)IA,03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXA,(X);storcvalueatXintoAANDA,DigiDat2;…setbitsinAforbottomsegmentsLDDigiDat2,A;…storeAintoDigiDat2乙DA,ATemp;restoreAccumulatortoremainderofUEDnumShowVOOlLDIDRWR,DigitsOVx,w;lookuptable(LUT)for3rdvoltsdigitLDIX,DigiteOVx,d;initializeLUTANDIA,03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;stoieaddressofvalueinXLDA'(X);storevalueatXintoAANDA,DigiDatJ(;…setbitsinAforbottomsegmentsLDDigil)atl,A;…storeAintoDigiDatlRESDecimal,DigiDatl;turnONdecimalpointGetVexitRET;*VoltMeter*;*Thisroutinesetsthedisplaytoshowvolts,thencallsShowMeterand;*ShowDatatoupdatethedisplaywiththecurrentbatteryvoltage.***GetMeter*ThisroutinecallsShowMeterandShowDatatodisplaythelatest*;*voltageorpercentage(determinedbyMtrScale&MtrUnits)onthe*LEf)display.6etMeteristhelastsectionofVocMtr.*VoltMtrRESMtrScaie,Flags;setforAlternator%LEDoffRESMtrUnits,Flags;setforVoltsLEDON,batt%LEDoffGetMeterCALLShowMeter;updatemeterLEDsCALLShowData;updatedisplayRJBT*GETPERCENT*,*Thisroutinedetermineswhatvaluetouseforthepercentageof*:*chargebeforethechargestatehasreachedthedv/dtstate.The**percentiscalculatedbyreadingthebatteryvoltage(BADhi)and*;*performingthefollowingcalculations:*;*AsTester*;*l,0V<BADhi<11.6VDC=>Percent-(BADfai/16)+1*',11.61V<BADhi<12.8VDC=>Percent=(BADW-175)*5+15*;*12,80V<BADhi=>Percent-100*;*AsCharger*;*lVolt<BADhi<12Volts=>(BADhi/4)+15=Percent*;*12Volts<BADhi<dv/dt=>(kADhi/2)-30-Percent*GetPercentJRRGhMode,Fkgs2,TstrBP;jumptoTester0/0ifnotchargingLDA,CurentSS;getcurrentprogramstateCPIA,11;haschargingreacheddV/dtJRCCalcPrcnt;…ifnot,calculatepercentageGPsndJPGetPctEnd"..otherwise,donothingCalcPrcntLDA,Percent;getPercentCPIA'76;checkforhighestcalculated%JTRNCGPend;exitifalreadyHiereJRSHiPwr,Flags4,GPend;exitifinHighPowermodeLDA)RmpCnt;getRampintervalcounter;NOTE:RmpCntwillbe0ifnotsettorampatallCPIA,5;isitalmosttimetorampupJRNCGPend;don'tupdate%untilendoflowpowerintervalCALLGetBatt;getlatestvoltage&doubleif6VmodeCPIA,Volts12;isthebatteryvoltagelessthan12VJRNCFonmila2;…No,gotoFonnula2CPIA,VoltsOl;Isbatteiy>lJRNCGPfoml;"ifso,skipnextlineJPGPzero;…ifnot,setforzero%GPfbrmlCALLDivMe4;…Yes,usefirstformulaADDIA,15;Addl5and…JPGetPctExitstoreintoAFormula2CALLDivide2;Divideby2andSUBIA,30"..subtract30JPGetPctExit;skipaheadandfinishroutineTstrBPLDAjFreshBV;getlatest(avg)batteiyvoltageCALLDouble6V;doubleBatteryvoltageifsetfor6VCPIAVoltsl28;Isbattery>12.8VJRCTstrl00;…ifnot,skipaheadCALLSetlOOp"..otherwise,Percent=100JPGetPctEndandendroutineTstrl00CPIA,BattMin;Isbattery>BattMinJRNCTstrBPhi;...ifso,jumpaheadCPI人Volts01;Isbattery>1JRNCTstrBPmed;…ifso,jumpaheadGPzeroCALLSetOp""otherwisesetPercentto0JPGetPctEnd;,..andendroutineTstrBPhiSUBIA,BattMin;subtractminimumhighvoltageCALLATimes5;multiplyby5ADDIA,15;addl5JPGdPcffidt;…storeintoATstrBPmedSUBIA,15;A-battery-15CALLDivide4;A-(batteiy-15)/4CALLDivide4;A—battery-15)/16INCA;A-(battery-l5)/簡GetPctExitLDPercent,A;storeintoPercentGetPc出adRETUPDATEBATTERYPERCENT*Thisroutinecontrolshowthebatterypercentagedisplayedisupdated.*.UpdateBPensuresthatundernormalcircumstances,thebattery%dis-**playedisupdatedaccordingtothefollowingtworules,*1、ilie%^splayeddoesn'tchangebymorethan1%atatime*2'The%displayedisnotupdatedtwicein<:PCintseconds*Thereareafewexceptions.*1The%displayedcanjumpupmorethan1ifitwas0*2,The%displayedwilldropto0immediatelyfordisconnectedbatt.*,*3.The%displayedcanchangebymorethan1ifthescale**changes****Scalereferstothe%scale,whichiseitherbatteryoralternator*UpdateBPLDA,Percent;checkwhether%is0JKNZUBPO;.'.ifnot,waitforupdateintervalJPUBPfinish"..otherwisefinishroutineUBPOLDAjDspPcnt;getlast%displayedJRZUBP00;contimieifO%JPUBPl;skipaheadifnot0%JRSMtrScale,Flags,UBPl;alsoskipaheadifAlternator%JRSWa加P,Flags2,UBPz;skipaheadifWaitOPflagalreadysetSET衡tOP,Flags2''."otherwise,setflagtowaitCALLIniTitne2;initializeTimer2LDISecs2,3;setTimer2for3secondsJRRChMode,Flags2,UBPz;skipaheadifintestermodeLDISecs2,5;setTimer2for5secondsinchargermodeUBPzJRRSEC,TicFlag2,UBPx;skipaheadifstillwaitingUBPOaRESWaitOP,Flags2;setflagtoindicatenotwaitingLDA,Percent"..otherwise,getnew0/oJPUBPfinish;…anddon'twaittodisplayitUBPxJPUBPexitandjustexitUBPlDECPcntL;decrement%interrupi:counterJRNZUBPx;ifnot0thenjustexitLDIPcntL,MSIN!T;re-initialize%int咖ptcounterDECPcntH;decre迈entintervalcounterJRNZUBPx;ifnotdownto0,thenjustexitLDIPcntH,PCint;re-initialize%intervalcounterLDA,DspPcnt;getlast%displayedJTIKZUBP2;skipaheadifnot0%;getnew%;andfinishroutineLDA,PercentJPUBPfinishUBP2CPA,PercentJRZUBPexit;comparetonewest%;ifequal,donothingJRCIncBP;ifless,increasedisplay%by1JUSChMode,Fkgs2,UBPexit;don'tdecrease%ifchargingDECA"'.otherwise,decrease%by1JPUBPfinishandfinishIncBPINCA;increasedisplay%by1UBPfinishLDDspPcnt,A;storeupdateddisplay0/oUBPexitRETMcterNum*〖ThisroutinecallsMeterOff,ShowNum,andShowDatatoturnofftke*:displaymodeLED'sanddisplayLEDnumonthe3-digitLEDdisplay.NumData*:THsroutinecallsShowNumandShowDatatodisplayLEDnumonthe:3-digitLEDdisplay.NumDataisthelastsectionofMeterM咖.*MsteiNumCALLMeterOff;turaoffallmetermodeLED'sNumDataCALLShowNum;getdatatoshowthenumberCALLShowData;showUienumberRET*SHOWDATA**ThisroutineupdatesthedigitalLEDand6switchLEDscontrolledby:*theserialtoparallelshiftregisters.ItsendsthebitsofSwData**andDigiDatatotheregistersbitbybitfromLSBtoMSBusing**SerData.Aftereachbitissent,ShflCIkistoggledtoshiftthebit**tothenextposition.Afterall24bitshavebeensent,LtchClkis**usedtoupdatetheoutputs,whichupdatestheLEDs.*ShowDataCALLRstWDR;resetwatchdogtimer;RESClrData,DRAtmf;clearshiftregister;CALLUpdatePA;updateportAfrombuffer;SETClrData,DRAbuf;preparetoacceptdata;CALLUpdatePA;updateportAfrombufferLDJBitCnt,OO幼''initializebitcountertoSLDIBytCnt,003h;initializiebytecounterto3LDA,DigiDatl;getfirst8bitsofdigitdataG識RLCA;sendMSBofAcumulatortoCarryJRCSetBit;ifCarry=lthendatabitis1RESSerData,DRAkxf;...otherwisesetSerDatato0JPSendBit;skipaheadtoSendBitSetBitSETSerData,DRAbuf;setSerDatato1SendBitLDDataBuf,A;storeshifteddatafromACALLUpdatePA;updateportAfrombufferRESSMOc,DRBbuf;setShiftClocklowRESLtchClk,DRBbuf;setLatchClocklowCALLUpdatePB;updateportBfrombufferSETShftCik,DRBbuf;setShiftClockhighCALLUpdatePB;updateportBfrombufferDECBitCnt;updatebitcountJRZNextData;ifallbitssentthenskipaheadLDAjDataBuf;storeshifteddatabackinAJPGetBit;otherwise,getnextbitNextDataDECBytCnt;updatebytecountJRKZ&extByte;getnextbyteiscountisnot0JPLatchDataotherwise,donesendingbitsN汰氾yteLDIBitCnt,08h;setbitcountfor8morebitsLDA3ytCnt;whichbyteisnextCPI儿02h;checfcfor2ndbyteisnextJRZScndByte;stipaheadifequalLDA,SwData;get8bitsofswitchLEDdataJPGetBit;sendbitsofsecondbyteScndByteLDA,DigiDat2;getlast8bitsofdigitdataJPGetBit;sendbitsofsecondbyteLatchDataSETLtcliClkJ)RBbuf;updatelatchesCALLUpdatePB;updateportBfrombufferRET;*ShowMeter*;*ThisroutinesetsthedigitalLEDtoshoweitherthecurrentvoltage*;*orlastpercentbasedonFlagsandCurentSS.DuringEnginestart,it*;*wiUcountdownsecondsofeitherremainingcranktimeorcooldown;*time.*ShowMeterJRSAkrt,Flags2,SMeXit;exitifabortmodeJRSMtrUnits,Flags,GetPrcnt;skipaheadandsetfor%CALLGetVoltsotherwise,getvoltsJRSChMode,Flags2,SMl;skipaheadifnotinTestermodeCALLShowStatus"..otherwise,updateStatusLEDsSMIJPShowMtrX;…andskiptoendorroutineGetPrciitJRRChMode,Flags2,TstMtr;ifintestermode,get%JPShowPrcnt"..otherwise,skipahead&show%ShowOCALLSet0p;settoshow0%ShoPerJPShowPrcnt;andskipaheadTs隐LDA,FreshBV;getlatestBatteryvoltageJRZShowO;ifOV,shcwO%J]RRMtrScaeJPags,ShoPer;shcwBatteiy%if加tsetforAJt%CALLDouble6V;doubleBatteryvoltageifsetfor6VCPIA,AltMin;checkfor<1stLUTvalueJRCShowO;ifso,showO%CPI入AltMax;checkfor>lastLUTvalueJRCAltVal;ifnot,skipaheadandcheckLUTLDIPercent,199otherwise,settomaxvalueJPShowPrcnt;andskipaheadAltValLDIDRWR,AltLvls.w;LUTforalternator%LDIX^AltLvls.d;initializeLUTSUBIA,AltMin;diffenceisindexinlookuptableANDIA,03Fh;limittowindowADDA,X;addbaseaddressoftableLDX,A;storeaddressofvalueinXLDA,(X);storevalueatXintoALDPercent,A;storevalueintoPercentShowPrcntCALLShowPercent;othprwise,showpercentageCALLShowStatus;tumonappropriatestatusLEDShowMtrXCALLShoMtrMode;turnonappropriatemeterLEDSMeXitCALLRstWDR;resetwatchdogtimerRETSHOWMETERMODE*:ThisroutineturnsononeofthemeterunitsLED'sbasedonFlagsand::Flags2.IftheunitisinTesterMode(ChMode-0),theroutinewill*'alsolighttheappropriatestatusLEDbasedonthevoltageatthe*'clamps.*ShoMtrModeSETLEDvolt,DRAbuf;turnoffDCVoltageLEDSETLEDprcnt,DRAbuf;tumoffBatteiy%LEDSgTLEDalt,DRAbuf;turnoffAlternator%LEDShowVolteJRSMtrUnits,Flags'ShoPrcnt;gotoShoPrcntifsetRESLEDvolt,DRAbuf;tornonVoltage乙EDJPShow應XShoPrcntJRSMtrScale,Flags,SliowAlt;gotoShowAltifsetRESLEDprcnt,DRAlraf;tamonBattery%LEDJPShowMMXSkwAltRESLEDalt,DRAbuf;turnonAlternator%LEDShowMMXCALLUpdatePA;updateportAfrombufferRET;*HoldMeterModeLED(dependingon咖de)*;*ThisroutineturnsontheBattery%,VolteDC,orAltemator%LEDbased*;*onFlags&Flags2andkeepsthatLEDonforonefifthsecond.*ko謝trMdCALLShoMtrMode;加monMeterModeLEDCALLFifthSecond;waito加fi他secondRET*SHOWSTATUS**ThisroutineturnsononeofthethreestatusLED'sbasedonthe*batteryvoltage.Thisroutineisforuseinthetestermode.*ShowStatusJRSChMode,Flags2,ShoStatX;exitifnotTestermodeJRRBatt,Flags2,RedStat;showredLEDifnobatteryJRRMtrUnits3Flags,ClrStat;turnoffStatusLED'sifvoltsmodeLDA,FreshBV;getlatestBatteryvoltageJRS]VItrScale,Flags,TestAlt;skipaheadifsetforAlternatorJLDA,DspPciit;getast%displayedCPIA,IOO;Isitl00%JRZGrnBatt;…ifso,showgreenLEDCALLResetSta加s;…otherwise,turnStatusLED'soffJPShoStatX;".andskiptoendGrnBattCALLShowGreen;turnonGreenLEDJPShoStatX;skiptoendTestAltCALLDouble6V;doubleBatteryvoltageifsetfor6VCPIA,Voltsl5a;Isalternatoratleast15.07VJRNCRedStat;…:ifso,skipaheadandshowredCPIA,Volts138;isalternatoratleast13.80VJRCRedStat;,..ifnot,skipaheadandshowredCPIA,Volts14;Isalt咖tor<14.0VJRCClrStat;…ifso,skipaheadandshowyellowCPIA,Volts149;isalternatoratleast14.87VJRNCClrStat;...ifso,skipaheadandshowyellowCALLShowGreen"..otherwiseturnonGreenLEDJPShoStatX;…andskiptoendRedStatCALLShowRed;turnonRedLEDJPShoStatX;skiptoendClrStatCALLResetStatus;turaStatusLED'soffShoStatXRET329*METEROFF**ThisroutineturnsoffthethreemetermodeLED's.**MeterOffSETLEDvolt,DRAbuf;turnoffDCVoltageLEDSETLEDprcnt,DRAbuf;turnoffBattery%LEDSETLEDalt,DRAbuf;turno諸ternator%LEDCALLUpdatePA;updateportAfrombufferRET*DigiOff**Thisroutinesettheregisterstoturnoffthethree-digitLED.*DigiOffLDIDigiDatl,DigiOffa;tumoff8of16digitalsegmentsLDIDigiDat2,DigiOffb;tumo汪other8of16digitalsegmentsRET'*DIGITSOFF**Thisroutineturnsoffthethree-digitLED.DigiteOffCALLDigiOff;setregistersforallsegmentsoffCALLShowData;updatedispkyRET*DIGITSON**ThisroutineturnsONallsegmentsofthethree-digitLED.DigitsONLDIDigiDatlJ)igiONa;tumON8of16digitalsegmentsLDIDigiDat2,DigiONb;turnONother8of16digitalsegmentsCALLShowData;updatedisplayRET*SHOWPERCENT**Thisroutine加rnsONtheBattery%LED.ShowPercentSETMtrUnitsJFIags;setFlagsfor°/0(notvolts)JRRWaitOP,Flags2,SPl;skipaheadifnotwaitingfrom0LDIDigiDatl,Dashes1"..otherwise,showdasheswhilewaitingLDIDigiDat2,Dashes2;…otherwise,showdasheswhilewaitingJPShowPxSP1LDA)DspPcnt;getPercentvaluetodisplayJRRMtrScale,Rags,SP2;don'tuseDisplay0/0forAltemator%LDA,Percent;..,useactualPercentfordisplay.IFCEQShoOff;assemblenextlineonlyidebuggingJRRChMode,Flags2,SP2;skipahead**DEBUG**LDA,OFFSET;diplayOFFSET**DEBUG**;JRRRapid,Flags2,SP2;**DEBUG**;LDA,RmpOrt;displayRampCount"DEBUG**.ENDCSP2LOLED加m,A;...andstoreitinAccumulatorCALLShowNum;setdigitalLEDforLED加tnSETDecimal,DigiDatl;tumOFFdecimalpointShowPxRET*RESETLEDS**ThisroutineturnsofftheType,Rate,andStatusLED'sResetLEDsCALLResetStatus;tumoffallthreestatusLEDsCIrLEDsIDISwData,SwsOff;tumoffTypeandRateLED'sRET*ResetStatus**ThisroutineturnsofftheLED'sintheStatusarea.ResetStatusSETLEDchgng,DRAbuf;tumoffChargingLEDSETLEDdoneJ)RAbuf;tarnoffChargedLEDSETLEDalert,DRAbuf;turnoffFault(red)LEDRET*BLINKChargingLED**ThisroutineblinkstheChargingLEDatarateofoncepersecond.BbkChrgLDA,MSecsl;getMSecscountCPI入MS500;testfor>1/2secJRNCBlinkChl;ifso,skipaheadCALLResetStatus"..otherwise,turnoffstatusLEDsIPBinkChX;...andexitroutineBlinkChlCALLShowChgng;TumonChargingLEDBlinkChXRET*ShowCharging**ThisroutineturnstheChargingLEDonand&erestoff.**ShowYellow**ThisroutineturnstheChargingLEDonanddoesnotaffecttheCheck**andChargedLEDs.ShowYellowisactuallythelastpartofShowChgng*ShcwChgngCALLResetStatus;turnoffallStatusLEDsShowYelJowRESLEDchgng,DRAbuf;tumONChargingLEDCALLUpdatePA;updateportAfrombufferRET*BLINKAlertLED**ThisroutineblinkstheAlertLEDatarateofoncepersecond.BlinkAlertLDA,MSecsl;getMSecscountCPIA,MS500;testfor1/2secJRNCBkikAlrt;ifso,skipaheadCALLResetLEDs;...otherwise,turnoffallLBDsJRSBumln,FIags3,BBI;skipaheadifnotBurn-InCALLDigitsON;...tumonalldigitalLEDsegmentsJPBAeXit;...andexitroutineBBICALLNumData;getdatafor,andshowLEDnumberJPBAeXit;...andexitroutineBkkAlrtCALLAlertCM;TumonAlertLEDCALLDigitsOff;Turnoff3-digitLEDBAeXitRET*AlertLEDON**ThisroutineturnsontheAlert(red)LEDandturnstheothermeter*LEDsoff.NOTE:itdoesnotaffecttheRateandTypeLEDs.*AlertONCALLMeterOff;TumoffMeterModeLEDsShowRedCALLResetStatus;TunioffStatusLEDsRESLEDalery3RAbuf;TurnonAlertLEDCALLUpdatePA;updateportAfrombufferRET*ShowDoneLED**ThisroutineturnsontheDone(green)LEDandturnsalltheother*LEDsoff.NOTE:itturnsofftheRateandTypeLEDs.*ShowDoneCALLResetLEDs;TurnoffallLEDsLDISwData,SwsOff;setType&RateLED'soffCALLSh。wType;showgatteryType&updatedisplayShowGreenCALLResetStatus;turnoffallthreestatusLEDsRESLEDdone,DRAbuf;丁urnonDoneLEDCALLUpdatePA;updateportAfrombufferRET*BLINKCrankLED**ThisroutineblinkstheCrankLEDatarateofoncepersecond.BlinkCrankLDA,MSecs2;getMSecscountCPIA,MS500;testfor>1/2secIRNCBIinkES;ifso,skipaheadSETLEDboost,SwData"..otherwise,turnoffCrankLEDJPBCeXit;...andexitroutineBlinkESCALLShowCraDk;tumonCrankLEDBCeXitRET*ShowCrank**ThisroutinetonstheEngineStart(Crank/Boost)LEDonandtarns:*tiieTypeandotherRateLEDsoff.**NOTE:The6VLEDwillbeleftonifappropriate.*ShowCrankCALLClrLEDs;tumoffallRate&TypeLEDsJRRBat6V,Flags2,ShoES;skipaheadifnot6VRESLED6V,SwData;turnonRegular6VLEDShoESRESLEDboost,SwData;tumONCrankLEDCALLShowData;updatedisplayRET*SetS!ow**ThisroutinesetsthechargerfortheSlowratebysettingtheappro-:承priateflags.*SetSlowRESRate,Flags;turnonSlowLEDRESRapid,Flags2;turnoffRapidLEDRET*SetSlow**ThisroutinesetstheOFFSETforthecorrect(12or6V)Slowrate.StartSlowLDIOFFSET,OffSlow;setOffsetfor2AJRRBat6V,Flags2,StrtSloX;skipifnotsetfor6VmodeLDJtOFFSET,OffiSSlootherwise,adjustOFFSETStrtSloXRET*SetMinOff**ThisroutinesetstheOFFSETforthecorrect(12or6V)maximumSlow**rate(minimumOFFSET).*Se幽OffLDILowOff,MinOQ2;limitoutputtomax2AcurrentJRRBat6V,Flags2,SefMOx;skipnextlineifnot6VmodeLDILowOff,MMOfE2;imito啤uttomax6V2acurrantSetMOxRET*ShowChargeRateLED(dependingonmode)**ThisroutineturnsontheSlow,Fast,orRapidLED,basedonFlags,ShowRateSETLEDboost,SwData;turnoffBoostLEDSETLEDrap,SwData;turaoffR^pidLEDSETLEDfast,SwData;tumoffFastLEDSETLEDslo"w,SwData;turnoffSlowLEDIRRChMode,Flags2,ShoRateX;exitifinTesterModeShowRapJRRRapid,Flags2,ShowSlow;gotoShowSlowifnotRapidRESLEDrap,SwData,'turaonRapidLEDJPShoRateXShowSlowJRSRate,Flags,ShowFast;gotoShowFastifsetRESLEDslow,SwData;turaonSlowLEDJPShoRateXShowFastRESLEDfast,SwData;turnonFastLEDShoRateXRETSetl2V*;Thisroutinesetsthechargerforthe12VRegularbatterytypeby*1resettingthe6V,AGM/Gel,andDeepCydeflags.*审SetReg承'ThisroutinesetsthechargerfortheRegularbatterytypebyreset-*:tbgtheDeepCycleandAGM/Gelflags,SetRegisactuallypartof;Setl2V*Setl2VRESBat6V,Flags2;tumoff6VLEDSetRegRESBatType入Flags;turnonRegularLEDRESBatTypeB,Fiags;turnoffGel/AGMLEDRET*ShowChargeTypeLED(dependingonmode)**ThisroutineturnsoneithertheRegular,DeepCycle,Gel/AGM,or6V**LEDbasedonFlags.TheroutnealsosetsVmaxtomatch.*ShowTypeSETLEDreg,SwData;setRegularLEDtooffSETLEDdeep,SwData;setDeepCycleLEDtooffSETLEDgel,SwData;setGel/AGMLEDtooffSETLED6V,SwData;set6VLEDtooffJRRBat6V,Fl昭s2,ShowTl;skipaheadifnot6VRESLED6V'SwData;turnonRegular6VLEDJPShowT2a;setVmaxforregular(15.5V)ShowTlJRRBatTypeB,Flags,SliowT2;skipaheadifnotGel/AGMRESLEDgel,SwData;tarnonGel/AGMLEDLDIVmax,Volts144;Vmax=14.4VforGel/AGMMODEJPShoTypeXShowT2JRSBatTypeA,Flags,SliowT3;gotoShowT3ifsetRESLEDreg,SwData;tumonHegularUEDShowT2aLDIVmax,Volts155;Vmax=15.5VforRegularMODEJPShoTypeXShowT3RESLEDdeep,SwData;tumonDeepCycleLEDLDIVmax,Volts16;Vmax=16VforDeepCyclebatteryShoTypeXRET*HoldChargeTypeLED(dependingonmode)**ThisroutineturnsontheRegular,DeepCycle,orGel/AGMLEDbasedon:*FlagsandkeepsitonforoneFifthsecond.HoldTypeCALLShcwType;turnonBatteryTypeLEDCALLShowData;updatedisplayCALLFifthSecond;waitoneFi他secondRET*HoldChargeRateLED(dependingonmode)**ThisroutineturnsontheSlow,Fast,orRapidLEDbasedonFlagsand*keepsitonforoneK他second.HoldRateCALLShowRate;tarnonChargeRateLEDCALLNumData;getdatafor,andshownominalrate(amps)CALLF她Second;waitoneFifthsecondRETCheckHighOffsetThisroutineisusedtocheckwhetherthelatestOFFSETisequaltothe*;*maximumvalue,HiOff.WhenOFFSET-HiOff;thechargerateis0.*bikHiOffLDA,OFFSET;getcurrentOFFSET3RSBat6V,Flags2,CH06;skipnextlineifnot6V边odeCPIA,HiOff-2;hasOFFSETreachedmaximum(outputofE)JPCHOxCH06CPIA,招0筋-2;hasOFFSETreachedmaxfor6V(outputoff)CHOxRET*CheckOV**Thisroutinechecksthelatestrunningaverageofthebatteryvoltage:*andsetstheCanybitifit'slessthanVoits0+1DACcount.This**routineisusedtocheckwhetherabatteryisconnected.*Chec講CheckBattSETBatt,Flags2;setflagforconnectedbattery;LDA,FreshBV;testlatestaveragevoltageLDIA,Volts0+l;checkifhigherthanzeroJRRCrnktig,Flags4,ChkBat;skipnextlineifnotcrankingLDIA,l;dieckfortrue0ifcrankingChkBatCPA,FreshBV;testlatestaveragevol但geJENCNoBatt;Ifnot:>03batterynotconnectedJPChkBattX;...otherwise,justexitNoBa忧RESBatt,Flags2;setforbatterynotconnectedCALLShowRed;turnonAlert(Red)LEDCALLClrPcnt;clearPercentandDisplayPercentCLRBADhi;clearpreviousvoltagereadingCLRFreshBV;clearpreviousvoltagereadingChkBattXRET*GetBatteryVoltage**ThisroutinegetsthebatteryvoltagestoredinBADhiandsaveditin**theaccumulator.Italsodoubles&eresultifsetfor6Vbattery.*承承*Double6V**Thisroutinedoublestheaccumulator,A,iftheBat5VflagissetThis:*routineiscalledbeforetheaccumulatoriscomparedtooneofthe**constantsoriginallyassignedfor12vbatteries.*承承*NOTE:IftheBat6Vflagisset,andtheaccumulatoris>8.5V,the**Hi6VFlagissetinstetadofdoublingA.*GdfiattLDA,BADhi;getlatest(avg)batteryvoltageDouble6VJRRBat6V,Flags2,D6VX;skipaheadifnotsetfor6VJKRHi6V,Flags3,D6V;doubleif6VBatt<8.5VLDIA,MaxVolts"..otherwise,setAtoMaxVoltsJRRChMode,Flags2,D6VX;checkforChargeorTestmodeCALLSetA^bort;...setforAbortstateifChargemodeSETAlertJFl昭s2;…setAlertFlagJPD6VX;".andskiptoendofroutineA;doubleA*CheckProgress**Thisroutineisusedtoensurethatthechargerwillabortifthe**batteryvoltagedoesnotincreasethroughoutthecharge.Itchecksthe:*voltageeveryCPintminutesforameasurableincreasesincethe**previouscheck.Ifthereisn't,thechargeisaborted.*ChkProgJRRMIN,TicFlagl-ChkProgX;exitifnottimetocheckforprogressCMProgOJKHSOC,SwDown,ChkProgl;skipaheadifnotStartOfChargeRESSOC,SwDownotherwise,clearSOCflagCALLIniTimel^initializeTimerlLDIMinsl,5;…setTimerlfor5minutesCLRLastBatt;clearLastBatt(ensurepass1sttest)JPChkProgX;".andexitChkProglLDA^BADhi;getlatestbatteryreadingSUBIA,l;subtractonecountCPA,LastBatt;checkforincreaseJRCChkProgA;settoabortifnoincreaseLDAJBADhi;setAbacktoBADhiLDLastBatt,A;updateLastBattCALLIniTimel^initializeTimerl.IFCNEFastCP;assemblenextlineonlyifnotdebuggingLDIMins1,CPint;setTimerlfor60minutes.ELSE;assemblenextlineonlyifdebuggingLDIMiasl,3;setTimerlfor3mins.ENDCDECCCDcnt;updateintervalcountJRNZChkProgX"ustexitifnotzeroSETHR,TicFlag1;ifzero,setfortimeexpiredChkProgACALLSetAbort;settostartAbortmodeChkProgXRET.*BatteryProgress**ThisroutineisusedtoensurethatChkProgandCheckBattarecalled**onlywhenthechargerateisabouttorampuporisn'tsettorampat**all.Thatway,thebatteryvoltageusedtocheckchargingprogress**won'tbeaffectedbythehighercurrentBattProgworksbychecking**RmpCnttomakesureit'slessthan5.Ifthestartofchargeflag(SOC)*VAwTDsDR*isset,BattProgdoesnotcheckRmpCnt.*BattProgJRRRmpng,Flags3,BtPrgO;skipaheadifnotRapid->FasttransitionCAIXRampOS;otherwise,graduallyreducedutycycleBtPrgOCLRA;setAto0toensure<(9,12,or14,2V)JRSHiPwr,Flags4,BtPrgX;exitifhighpowermode;JRSSOC,SwDown,BtPrg2;skipaheadifStartOfChargeLDA^RmpCnt;getRampintervalcounter;NOTE:RmpCntwillbe0ifnotsettorampatallCPIA,5;isitalmosttimetorampupJRNCBtPrgX;ifnot,thenexit;BtPrg2CALLCbkProg;checkforchargingprogressCALLGetfiatt;getlatestvoltage&"bleif6VmodeBtPrgXRET*Check2V**Thisroutinechecicsthelatestrunningaverageofthebatteiyvotage:*andsetstheCarrybitifit'slessthanVolts016.Thisroutineis**usedtocheckwhetherabatteryisreadyforcranking.*Check2VLDAjFreshBV;testlatestaveragevoltageCPIA,Volts016;checkifhigherthan1.6voltsRET承ghecxswttc:hes承*Checkifswitchisengagedandchangemodesifappropriate.CheckSwJRRCrankWait,Flags,ChkStart;checkswitchesifnotduringCrankwaitJPChkSwRET;don'tcheckswitchesifduringCrankwaitChkStartJRSCrankjFlags'ChekRate;don'tcheckdisplaymodeduringBoostJRRMeterSw,DRC,MeterDowri;Ifswitchisbeingpressed,skipaheadRESMeterSw,SwDown;setforMeterswitchnotpressed(up)ChckRateJPChkRate;Meterswitchnotpressed,soexitCheckSwMeterDownRESIdle,Flags3;setfornotidleJRSMeterSw,SwDown,ChekRate;Ifswitchwasn'treleased,don'tcheckitSETMeterSw^wDown;setformodeswitchpressed(down)JRRMtrScale,Flags,ChkPrcnt;ifnotsetforAlt,thenskipaheadRESMtrScale,Flags;setforAlt%,sochangetoBatt%JPChkRateChkPrcntJRRMtrUnits,Fkgs,ChkAlt;ifsetforvolts,thenskipaheadRESMtrUnits,Flags;setforBatt0/o,sochangetovoltsJPChkRateChkAItSETMtrUnits,Flags;setforvolts,sochangeto%,IFCKEShoOff;assemblenextlineonlyifnotdebuggingJRSChMode,Hags2,ChkRate;don'tsetforAltifcharging.ENDCSETMtrScale,Flags;setforbatt,sochangetoaltRESWaitOP-!Flags2;settostopwaitingforbattery%ChkRateCALLShoMtrMode;Meterunitsaresetbeforerate;.IFCEQDEBUG;assemblenextlineonlyifdebugging;IRRSwOff,S邻Down,SkpSw;skipRateandTypeswithifSw6ffisset;JPChkSwRET;Otherwise,justexit;SkpSw;.ENDCJRRRateSw,DRC,RateDown;Ifswitchisbeingpressed,skipaheadRESRateSw,SwDown;setforRateswitchnotpressed(up)ChekTypeJPChkType;Rateswitchnotpressed,socheckTypeRateDownRESIdle,Flags3;setfornotidleJRSRateSw,S邻Down,CliekType;Ifswitchwasn'treleased,don'tcheckit;JRRRateSw,SwDown,ChngRate;Ifswitchwasreleased,thencheckit;JPChkType;Otherwise,skipaheadtoTypeSwitch;ChngRate;changeChargeRateSETRateSw,SwDown;setforRateswitchpressed(down);SETCrank,Flags"..otherwisetemporarilysetCrankflag;JRRMtrScale,Flags,ChkCM;skipaheadifnotsetforAlt%;CLRDspPcntotherwise,don'tuseAlt%forchargeChkCMJRRCrank,Flags,ChkSlow;ifnotsetforCrankjcheckforSlowCALLTurnOff;low&highpowerandfanoff,mindutyCALLChrgRly;setrelayforcharge(notstart)RESChMode,Flags2;setforTester(notCharger)ModeSETDisable,DRBbuf;disableoutputifRatewasBoostJPModeChange;gotoendofCheckSwChkSlowJRSChMode,Flags2,ChkFast;skipaheadifalreadyChargermodeSETChMode,Flags2;setforCharger(nottester)ModeRESDisable,DRBbuf;enableoutputafterRateispressedRESMtrScaie,Flags;setforBatt%(notAlt%)whennottesterRESRate,Flags;wasCrank,sosetforSlowJPModeChange;gotoendofCheckSwChkFast;ifsetfor§low,thensettoFastJRSRate,Flags,ChkRap;IfnotSlow,flienmustbeFastSETHate,Flags;setChargerateforFastJPModeChange;gotoendofCheckSwChkRap;ifsetforFast,thenchangetoRapidJRSRapid,Flags2,ChkES;IfnotRapid,thenmustbeFastSETRapid,Flags2;setChargerateforRapidJPModeChange;gotoendofCheckSwChkES;wassettoRapid,changetoBoostCALLSetSlow;setforSlowRateSETCrank,Flags;setChargerateforBoost;CALLSetReg;setbatterytypeforRegularCALLShowCrank;turnONCrankLEDCALLTuraOff;low&highpowerandfanoff,mindutyLDICurentSS,CrankSS;setChargestatetoCrankCALLIniTime2;resettimer2LDISecs2,003h;setTimer2for3secondsJPChkSwRETChl<Type;ifGel/AGM,thensetforRegularJRRTypeSw,DRC,TypeDown;IfSwitchisbeingpressed,skipaheadRESTypeSw,SwDown;setforTypeswitchnotpressed(up)ChkSwXJPChkSwRET;Typeswitchnotpressed,soexitCheckSwTypeDownRESIdle,Flags3;setfornotidle爪STypeSw,SwDown,ChkSwX;IfSwitchwasn'treleased,don'tcheckitSETJypeSw,SwDown;setformodeswitchpressed(down)IRRBat6V,Flags2,ChkBTl;Ifnotsetfor6V,checkforRegiilarChkBT0;ifsetfor6V,changeto12VregularRESHi6V^lags3;clear6VovervoltageflagCALLSetl2V;setforRegular,12VbatteryCALLClrPcnt;clearPercentandDisplayPercentJPTypeChange;gotoendofChedcSwChkBTl;ifsetforAGM/Gel,changeto6VIRRBatTypeB,Flags,ChkBT2;IfnotsetforGel/AGM,checkforRegularJRSHi6V,Flags3,ChkBTO;don,tsetto6Vifbatt>8.5VCALLSetR邻;setbatterytypeforRegularSETBat6V,Flags2;setfor6VbatteryCALLClrPcnt;clearPercentandDisplayPercentJPTypeChange;gotoendofCheckSwChkBT2;ifRegular,thensetforDeepCycleJRSBatTypeA,Flags,ChkBT3;IfnotsetforRegular,mustbeDeepCycleSETBatType乂Flags;setbatterytypeforDeepCycleRESBatTypeB,Flags;setbatterytypefornotAGM/GelJPTypeChange;gotoendofdheckSwChkBT3;mustbeDeepCycle,sosetforGel/AGMSETBatTypeB,Flags;setbatterytypeforGel/AGMRESBatTypeA'Flags;setbatterytypefornotDeepCycleTypeChangeRESCrankjFlags;setchargeratefornon-BoostCALLShowType;turnonBatteryTypeLEDModeChangeRESCrack,Flags;clearCrankbitofFlagsLDICurentSS,0OOh;restartchargingChkSwRETRET5(5FANON**ThisroutineturnsthecoolingfanON.FanONiscalledduringoneof*thefollowingconditions:**1.Startofcharge(endofState2)**2,Startofboost(State16)*,3.IfOFFSET<HiOff-3inMaintain(State14)*;*4.ManualMode(State15)*:*5,States4,5,11,12,and13*FanON<formula>formulaseeoriginaldocumentpage341</formula>*Thisroutinesetsthechargertorunwiththefanandoutputon**SetONisactuallypartofT咖ON*CALLShowChgng;turnChargingLEDonSetONCALLFanON;turncoolingfanonSETPower,Flags2;tellPwrConchargerisonRET*ChargeRelay**ThisroutineswitchestherelayfromStarttoChargeifnecessary,**ChrgRlywaits200mSbeforeswitchingtherelay.Theoutputshouid*beforeturnedoffbeforecallingChrgRly.*ChxgRlyJRRESrly,DRBbuf,ChgRlyX;skipaheadifrelayalreadysetforchargeCAIX:Fi他Se咖d;wait2衡SRESESriy,DRBbuf;setE/SrelayforchargeChgRlyXRET*Updatetheclocksandsetoverflowflagsasnecessary.*TicFlagl(s)bit0=hourswenttozero**TkFlagl(s)bit1=minuteswenttozero**TicFiagl(s)bit2=secondswenttozero**TicFiagl(s)bit3=milisecondswenttozero*CLOCKSDECMSecsl;decrementmillisecondcounterJRNZClksl;skiptoclock2ifMSECsoODoMSecsLDIA,MSINIT;restartmillisecondcounterLDMSecsl,A;SETMSEC,TicFlagl;setmillisecflagDECSecsl;decrementsecondcounterJRZDo一MinsClksl一JPCLOCKS1Do一MinsSE^SEC,TicFkgl;setsecondexpiredflagLDISecsl,SecInit(restartsecondccmntwrDECMinsl;decrementminutecounterJRNZCLOCKS1;skipHRslifMINsldowntozeroDo一HrsSEiMIN,TicFlag1;setminuteexpiredflagLDIMins1,Minlnit;restartminutecounterDECHrs,'decre咖iit2咖rcounterJRNZCLOCKS1;checkforoverflowSETHR,TicFlagl;sethourexpiredflagCLOCKS1DECMSecs2;decrement迈illisecondcounterJRZDOMSecs2C腿xitJPCLOCEXITDOMSecs2LDIA,MSINTT;restartmillisecondcounter;LDMSecs2,A;SETMSEC,TicFlag2;setmillisecflagDECSecs2;decrementsecondcounterJRNZClkExit;exitifnotdowntozerbDo一Mins2SEiSEG,丁icFlag2,'setsecondexpiredfkgLDISecs2,SecInit;restartsecondcounterDECMins2;deGrementminutecounterJRNZCLOCEXIT;exitifnotdowntozeroDo_Hrs2S^iMIN,TicFkg2;setminuteexpiredflagLDIMins2,Minlnit;restartminutecounterDECHrs2;decrementhourcounterJRNZCLOCEXIT;checkforoverflowSETHR,TicFlag2;sethourexpiredflagCLOCEXITRET承IOTTIALIZETIMERl+*SubroutinetoinitializetimerlIniTimelLDIMSecsl,MSINITLDISecsl,SecInitLDIMinsl,MinInitCLRHrslCLRTicFlaglRETINITIALIZETMER2*SubroutinetoinitializeTimer2IniTime2LDIMSecs2,MSINITLDISecs2,SecInitLDIMins2,MinlnitCLRHrs2CLRTicFlag2RET*ShiftA7**Subroutinetoshifttheaccumulatorleft7times.UsedbyDivide2*andDivide4.Writtenonlytosavecodespace.*ShiftA7SLAA;s础left343RLCA;rotateleftthroughCARRYbit6timesRLCARLCARLCARLCARLCARET*DIVIDEBY2**SubroutinetodividethenumberinAby2.Theremainder,ifany*willbeavailableinthecanybituponreturn.*Divide2CALLShiftA7;shiftleftoncethenrotateleft7timesRLCA;rotateleft7thtimeRETDIVIDEBY4**SubroyitinetodividethenumberinAby4.Divide4CALLShiftA7;shiftleftoncethenrotateleft7timesANDIA,Ol1111lib;dropMSBRET;*ATimes5*;*Subroutinetomultiply也eaccumulator(A)by5.*;*Atinies5mul1pliesAby4byshiftinglefttwicethenaddingthe;*originalvalueofA:(A*4)+A=A*5*ATimes5LDAT咖p,A;ATemp=AADDA,A;A=A+A=A*2ADDA,A;A=A+A=ATemp*4ADDA,ATemp;A=A+ATetnp=ATemp*5RET*CURRENTREGULATION**ThisroutinereducestheoutputcurrentbyincreasingtheOFFSET**valuewhenthevoltageisbelow14.2volts(thruSS5).Anoffsetinto**anLUTisdeterminedbasedonthebatteryvoltage.Thevalueisloaded**intoOFFSETwhichisusedtocontrolstheofftimeoftheSCR's.*IRegLDA,BADhi;getvoltage;LDA,FreshBV;getvoltageJRSBat6V,Flags2,IR—6V;skipaheadif6VmodeJRSRate,Flags,PH一l;skipaheadif15ampmodeLDIDRWR,OFFAl)J2,w;lookuptablefor12V2ampLDIX,OFFADJ2.d;initializelookuptableLDITempOff,OflELow2;highest2Aoffset-lowestcurrentSUBIA,BatLo2;subminimmi12V2amptableentry(10V)JRNCP一A14;do加P一A15ibA,Te迈pOffJPP—A12P—A14TeinpOff,0飽i2;lowest12V2Ao泡et-highestcurrentCPIA,040h;lasttableentry-highestindex则CP_A15;doneJPPH—2;donewith12V2ampPH一lJRSRapid,Flags2,IR—rap;skipaheadifRapidrateER一1一L5lDRWR,OFFADJ15.w;bokuptablefor12V15ampLDIX,OFFADJ15.d;initializelookuptableLDITempOff,OffLow15;highest15Aoffset-lowestcurrentSUBIA,6atLo15;submininum15amptableentryJRNCP_A17;doneP—A16一5P_A15P—AHfblTempOff,0舰15;lowest12V15Aoffset-highestcurrentCPIA,040h;lasttableentry-highestindexJRNCP—A16;doneJPPH一2—;dcmewithI2V15ampIR—rapJ^kHiPwr,Fags4,IR一l;use12V15AtableiflowpowermodeLDIDRWR^OffAdj6";lookuptablefor60ampLDIX,OHAdj60.d;initializelookuptableLDITempOfi;OfflLow60;highest60Aofifeet-lowestcurrentSUBIA力atLo60;submininum60amptableentry厕CIR一rp2;doneIR一ipl_JPP—A15IR一rp5LSITempOff'Of伍i60;lowest60Aoffset-highestcurrentCPIA,040h;lasttableentry-highestindexJRNCIR一rpI;donePH一2一Al^bl入03Fh;limitto64bytewindowADD人X;addtablebaseaddressLDX,A;LDA,(X);getvaluefromtableJPP—A12;skipaheadandupdateoffetvalueJRSRate,Flags,IR6—3;skipaheadif15ampmodeLDIDRWR,OfAd6^2.w;lookuptablefor6V2ampLDIX,OfAd6V2.d;initializelookuptableLDITempOff,0筋Lo2''highest2Aoffset-lowestcurrentSUBIA,Bat6Lo2;submininum6V2amptableentry(5V)JRNCIR6—2;doneIR6一1一LDA,TempOffJPP—A12IR6—5LDTTempOff,Of細2;Iowest6V2Aoffset-highestcurrentCPIA,020h;lasttableentry-highestindexJRNCIR6一1;do加JPIR6—10一;donewith6V2ampIR6—3JR^"Rapid,Flags2,IR6—7;skipaheadifRapidrateIR6—4LD亍DRWR,0议d(5VI5.w;look叩tablefor6V15ampIDIX,OfAd6V15.d^initializelookuptableLDITempOff,Off6Lo15;highest15Aoffset-lowestcurrentSUBIA,Bat6Lo15;submininum6V15amptableentryJRNCIR6—6;doneIR6一5一JPlR6一lIR6—6LDTTempOff,Of伤Hi15;lowest6V15Aoffset-highestcurrentCPIA^020h;lasttableentry-highestindexJRNCIR6一5;doneJPIR6—IO一;donewith6V15ampIR6_7—JRRHiPwr,Flags4,IR6一4;use6V15AtableiflowpowermodeLDIDRWR,OfAd6V65.w;lookuptablefor60ampLDIX,OfAd6V60.d;initializelookuptableLDITempOff,Off6Lo60;highest6V60Aoffset-lowestcurrentSUBI入Bat6Lo60;submininum6V60amptableentryJRNCIR6—9;doneIR6一8一JPlR6一lER6一9LD丁TempOff,Off6Hi60;lowest6V60Aofeet-highestcurrentCPIA,020h;lasttableentry-highestindexJENCIR6—8;doneIR6一10一Al5)1A,01Fh;limitto32bytewindowADDA,X;addtablebaseaddressLDX,A;LDAj(X);getvaluefromtableP_A12;XDDA,FUDGE;debugfodgefactorLDOFFSET,A;savenewoffsetvalueP—A13VOLTAGEREGULATION*:ThissubroutinewilladjustthevalueofOFFSEToncepersecondto*:controlthecurrentandmaintainthevoltagedeterminedbyMaintVolt.Vo股egLDA,MSecs2;MSec2=MSInitoncepersecondCPIA,MSIN1T;IsMSEC1=MSINITJRZVReg—0;Yes:thentimetoadjust■VReg_X—JPVReg一3;No:thennottimetoadjust,VReg—0一;adjustoffsetDECVRcnt;decrementintervalcounterJRZVReg一O;Yes:thentimetoadjustJPVoltRegX;No:thennottimetoadjustVReg一0;adjustoffsetLDI^Rcnt,l^SINIT;re-initializeinitervalcounter(1sec)LDA,FreshBV;getbatteryvoltageCALLDouble6V;doubleBatteryvoltageifsetfor6VDECACPA,MaintVolt;comparewithsetvalue+1JRNCVReg—6;greaterthan,increaseOFFSETJPVReg_greaterthan,testiflessthanVReg—6LD尺OFFSET;greaterthan,getphasedela"ahieINCA;JRSBat6V,Flags2,VKeg一2CPIA,HiOff;testifath^hlimitJPVReg一5VReg_2CPIA,ffiO筋VReg一5JGRN(JVReg-3;atthelimi^don'tchangeOFFSETVReg—4—LDOlFSEIVA;updateOFFSETVReg—3JPVo欣egX;doneforthispassVReg—1CPA,MaintVolt;comparewithsetvalueIRNCVoltRegX;notlessthan,justexitLDA,OFFSET;lessthao^getphaseddayvalueDECA;CPA,LowOff;testifatknvlimitIRNCVReg—4;notatthelimit,updateOFFSETVoltRegX—RET;*TIMERINTERRUPTHANDLER*;*ThisroutineturnstheSCRsonifthepowerflagsarenon-z加andinhibitsthetimer,*PwrConLDATemp,A;saveAregisterJRSPower,Hags2,PCon;chargeron,turaonSCRsJPPWREXrr;notchargingjustexitPConSETSCRs,DRBbuf;turnontheSCRs(inbu酬CALLUpdatePB;updateportBfrombufferPWREXn;LDITSCR,015h;iohibittimerCALLRstWDR;resetwatchdogtimerLDIA,FULLTIME;TCRisreloadedherefor1McycleLDTC&A;LDITSCR,05dh;reloadprescalerandstarttimerJRRCmkng,FIags4,PC一NormPC—CrankCJiLCLOCKS;updateclocksRESNMInt,Flags2;tellExitMainthiswasNMIinteruptJPPCexit;leaveSCRsonduringCrank;turnoffSCRdrivesothatonlyapulseisgenerated(SCR'slatchon)PC—NormSEiNMInt,Flags2;tellExitMainthiswastimerinterupt;RESSCRs,DRBtmf;otherwise,tono任SCR言s(inbuffer);CALLUpdatePB;updateportBfrombufferPCexitLDA,ATemp;restoreAregisterRETI*NON-MASKABLEINTERRUPTHANDLER**ThisistheNMIinterruptroutine.TheNMIisgeneratedonthefalling:*edgeoftheftillwaverectifiedAClinevoltage.Aninterruptis**generated120timespersecond^onceevery8.333咖,AftereachNMI,*thisroutineperformsthefollowingsteps.**1.Resetthewatchdogtimerandsavetheregister.**2,TurnofftheSCRs(unlessduringCrankONstate).**3.Settheinterruptti迈eraccordingtoOFFSET.**4.ResetNMIntsoExitMainknowsifsanNMI(nottimerint).**5.Updatetheclocks.**6,Restoretheregisters.**Ifturnedoff,theSCRswillremainoffforaperioddeterminedby**OFFSET.TheTimerwillthentriggeraninterruptwhichtellsPwrCon*toturntheSCRsbackonifnecessary.*IT—TIMERC^LLRstWDR;resetwatchdogtimerLDATemp,A;saveAregisterLDA,X;getXregisterLDXTEMP,A;saveXregisterJRSCrnkng,Fl昭s4,lT—XIT—Normn5pLDIX,2Ah;delayfortruezerocrossit一tD云CXJRNZIT—TNOP;adjustzerocrossdelayLD入OFFSET;getcurrentoffsetLDTCR,A;loadthecounterwithcurrentoffset乙DITSCR,01011101b;reloadprescaler(32)andstarttimerRESSCRs;DRBbuf;turnoffSCR,s(inbuffer)CALLUpdatePB;updateportB&ombufferIT—TMRRisNMInt,Flags2;tellExitMainthiswas丽IinteruptCALLCLOCKS;updateclocksIT一XLDA,XTEMP;restoreregistersLDX,ALDA,ATempRETI*A/DINTERRUPTHANDLER**ThisistheAtoDinterruptserviceroutine.Theonlythingitdoesis**cleartheinterruptbitandwakestheprocessorupfromitswaitmode.11ADINTRES7'ADCRLDA,ADRRETI*ROMDATAWINDOWforTHIRDVOLTSLEDDIGIT**Thefollowingbitpatternsareusedtodisplaytheindicatednumbersas**thethird(leastsignificant)digitofthevoltagedisplay.*.block16-$0/J6DigitsOVx;patternsforDigiDatl-Digit1(LSD)&decimalpoint.byte00010010b;display_0for00h.byteOllUllOb;display二lfor01hbyte0111111Ob;dispay—Ifor02h.byte0011000〗b;display__2for03h.byte00111000b;display]^3for04h.byte00111000b;display[Z3for05h.byte0101110Ob;display__4for06h.byte10011000b;display二5for07h.byte10011000b;dispky二5for08hbyte10010000b;display二6for09h.byteOO川IlOb;display二7forOAhbyteOOllUlOb;display二7forOBh.byte00010000b;display二8forOCh.byte00011000b;display二9forODh.byte00011000b;displayforOEh*ROMDATAWINDOWforTHIRDLEDDIGIT**Thefollowingbitpatternsareusedtodisplaytheindicatednumbersas**thethird(leastsignificant)digitontheL运D..block16-$%16DigitsOOx;patternsforDigiDatl-DigitI(LSD)&decimalpoint.byte00010010b;bitpatterntodisplay__0.byteOllllllOb;bitpatterntodisplay—1.byte00110001b;bitpatterntodisplay^2.byte00111000b;bitpattemtodisplay—3.byte01011100b;bitpatterntodisplay—_4.byte10011000b;bitpatterntodisplay二5.byte10010000b;bitpatterntodisplay_6.byte0011111Ob;bitpatterntodisplay^^7.byte00010000b;bitpatterntodisplay—8,byte00011000b;bitpatterntodisplay=9*ROMDATAWINDOWforSECONDLEDDIGIT**Thefollowingbitpatternsareusedtodisplaytheindicatednumbersas:*thesecond(middlesignificant)digitontieLED..block16-$%16Digits0x0;patternsforDigiDat2-Digit2(middledigit)andMS1.byte00000101b;bitpatterntodisplay一0—.byte11001111b;bitpattemtodisplay—1—.byte0010001lb;bitpatterntodisplay—2—.byte10000011b;bitpatterntodisplay—3—.byte11001001b;bitpatterntodisplay—4_bytelOQIOOOlb;bitpatterntodisplay一5一.byteOOOlOOOlb;bitpatterntodisplay—6_.byte1100011lb;bitpatterntodisplay一7_byte0000000lb;bitpatterntodisplay二8—byte10000001b;bitpatterntodisplay—9_;*ROMDATAWINDOWforAlternatorChargeinPercent*.;*ThefollowingvaluesarethePercentvaluesforthealternatorvoltagesN;*listedbelow.Thesenumbersareonlyusedwhenthechargerisin*;*Testermode.Voltageslowerthanthe&stentryaredisplayedas0%*:charged.Voltagesabovethelastentryaredisplayedas199%charged..block32-$%32AltLvls;%VoltsHexbyteO;13.53CBred.byte12;13.60CC!.byte25;13.67CD|byte38;13.73CEred.byte50;13.80CFyellow.byte62;13.87DO|byte75;13.93Dlyellow.byte85;14.00D2green.byte92;14.07D3|.byte97;14.13D4j.byte100;14.20D5.byte100;14.27D6.byte100;14.33D7.byte100;14.40D8.byte100;14.47D9.byte100;14.53DA1/byte100;14.60DB|.byte103;14.67DC|.byte110;14.73DDibyte120;14.80DEgreenbyte130;.byte140;.byte150;byte160;.byte170;.byte180;.byte190;.byte196;.byte199;14,87DFyellow14,93EOI15.00Elyellow15.07E2red15.13E3I15.20E4j15.27E5j15.33E6red15.40E7red;*ROMDATAWINDOWFOR2ampmode*;*Thesearetheoffsetstocontrolthecurrentoutput..block64-$%64OFFADJ2;2咖ptable;OffsetIndexVots;(D)(h)(Dec)(Hex).byte128;7F010.0096.byte128;7F110.0797.byte127;7E210.1398.byte127;7E310.2099.byte127;7E410.279A.byte127;7E510.339B.byte127;7E610.409C.byte127;7E710.479Dbyte127;7E810.539E.byte126;7D910.609F.byte126;7D1010.67AO.byte126;7D1110.73Al.byte126;7D1210.80A2.byte126;7D1310.87A3.byte125;7C1410.93A4.byte125;7C15I1.00A5.byte125;7C1611.07A6■byte125;7C171U3A7.byte125;7C1811.20A8.byte125;7C19U.27A9.byte125;7C2011.33AA.byte125;7C2111.40AB.byte124;7B2211.47AC.byte124;7B2311.53AD.byte124;7B2411.60AE.byte124;7B2511.67AF.byte124;7B2611.73B0.byte124;7B2711.80B1.byte124;7B2811.87B2.byte123;7A2911.93B3.byte123;7A3012.00B4.byte123;7A3112.07B5.byte123;7A3212.13B6byte123;7A3312.20B7.byte123;7A3412.27B8.byte122;793512.33B9.byte122;793612.40BA,byte122;793712.47BB.byte122;793812.53BC.byte122;793912.60BD.byte121;784012.67BE.byte121;784112.73BF.byte121;784212,80CO.byte121;784312.87CI.byte120;774412.93C2.byte120;774513.00C3.byte120;774613.07C4.byte120;774713.13C5,byte120;774813.20C6byte119;764913.27C7.byte119;765013.33C8.byte119;765113.40C9.byte119;765213.47CAbyte119;765313.53CB.byte119;765413.60CC.byte118;755513.67CD.byte118;755613.73CE.byte118;755713.80CF.byte118;755813.87DO.byte117;745913.93Dlbyte117;746014.00D2byte117;746114.07D3.byte117;7462RI3D4byte117;746314,20D5ROMDATAWINDCWFOR15ampmode*Thesearetheoffsetstocontrolthecurrentoutput.;.block64-$%64OFFADJ15;OffsetBattVolts;DecHexIndexDecHex.byte112;7009.0087.byte112;7019.0788.byte112;7029.1389.byte111;6F39.208A.byte111;6F49.278B.byte111;6F59.338C.byte111;6F69.408D.bytelll;6F79.478E.byte111;6F89.538F.byte111;6F99.6090.byte111;6F109.6791.byte111;6F119.7392.byte111;6F129.8093.byte110邻139.8794.byte110邻149.9395.byte109;6D1510.0096.byte109.byte109.byte109.byte109.byte109.byte109.byte108.byte108.byte108.byte108.byte108.byte107.byte107.byte107.byte106.byte106.byte106.byte106.byte106.byte106byte106.byte105.byte105byte104.byte104.byte104byte104-byte104byte104.byte104.byte103.byte103.byte103.byte103.byte102byte102.byte102.byte102.byte102.byte102byte101.byte101byte101.byte101.byte101.byte100.byte100.byte99;636D,6D6D6D6D6D,6C6C6C6C6C6B6B6B6A6A6A,6A6A6A6969,68,6868686868;686767■6767,6666,6666666665656565651610.07971710.13981810.20991910.279A2010.339B2110.409C2210.479D2310.539E2410.609F2510.67AO2610.73Al2710.80A22810.87A32910.93A43011.00A53111.07A63211.13A73311.20A83411.27A33511.33AA3611.40AB3711.47AC3811.53AD3911.60AE4011.67AF4111.73BO4211.訓l4311.87B24411.93B34512.00B44612.07B54712.13B64812.20B74912.27B85012.33B95112.40BA5212.47BB5312.53BC5412.60BD5512,67BE5612.73BF5712.80CO5812.87CI5912.93C26013.00C36113.07C46213,13C56313.20C6ROMDATAWINDOWFOR60ampmode*Thesearetheoffsetstocontrolthecurrentoutput."block64-$%640脇j60;OffsetJDecHexVoltsIndexDecHex.byte77byte77.byte77.byte77.byte76byte76.byte76.byte76.byte75.byte75.byte74.byte74byte73.byte73.byte72.byte72.byte71.byte71.byte70.byte70.byte79-byte79.byte68.byte68.byte67.byte67.byte66.byte66.byte65.byte65byte64.byte64byte63.byte63.byte62.byte62byte61.byte61.byte60.byte60.byte59.byte59byte58.byte58.byte57.byte57.byte56.byte56.byte55byte55.byte54.byte54.byte53,48:47,47:4646;45,45444443:434242,41,41;40;40;4909.80934919.8794;4829.9395310.0096410.0797510.1398610.2099710.279A810.339B910.409C1010.479D1110.539E1210.6013歸7A01410.73Al1510.80A21610.87A31710.93A41811.00A519II.07A6■3F2011.13A7■3F2111.20A83E22II.27A5犯2311.33AA3D2411.40AB3D2511.47AC:3C2611.53AD,3C2711.60AE:3B2811.67AF3B2911.73BO■3A3011.80Bl,3A3111,87B2393211.93B312.00B412.07B512.13B612.20B712.27B812.33B912.40BA12.47BB12.53BC12.60BD12.67BE12.73BF12.80CO12.87CI4712.93C248〗3.00C34913.07C45013.13C55113.20C65213.27C7333435363738394041424344:4546<image>imageseeoriginaldocumentpage355</image>Thesearetheoffsetstocontrolthecurrentoutput*;.block32-$%32OfAd6V15OffsetVolteDecHexIndexDecHexbyte121byte120,byte120byte120,bytel19,byte119byte119byte119byte"9■byte119byte119byteH8.byte118byte118■byte118■byte118.byte118,byte118byte118byte118■byte118■byte118byte118,byte117byte117byteH7.byte117■"117,bytel17,byte117byte117,byte117■04.47437BI4.544470:24.60456A34,674667■44.74476754.80486764.87496674.944A6685.004B6695.074C65105.144D65II5.204E64125.274F64135.345064145.40155.47165.54175,60185.67195.74■205.80215.87225.94,236.00■246.07256.14,266.20276.27286.34■296.40,306.47316.545163526353635462556256625761586159615A605B605C5F5D5F5E5F5F5E605E615E625E*ROMDATAWINDOWFOR6V60ampmode**Thesearetheoffsetstocontrolthecurrento鄉ut*block32-$%32OfAd6V60;Offs改Volts;DecHexIndexDecHex.byte88;8A04.8749.byte88;8A14.944A.byteS7;8A25.004B.byte87;8A35.074C.byte87;8945.134D.byte86;8955.204E.byte86;8965.274F.8685858585S5353535;5i4i4!4!414;414:3:3;3:3,3332888888878787868686858585糾8475.335085.405195.4752115.6054125,6755135.7356145.8057155.8758165.9359176.005A186.075B196.135C206,205D84216.275E83226.335F236.4060246.4761256.5362266.6063276.6764286.7365296.8066306.8767316.9368Interruptvectors.org0FF0hADCJPADINTTIMERJPPwrConINT2NOPRETIINT1NOPRETI.orgOFFCh雨IJPIT—TIMERRSTJPRESET■END显然,鉴于以上教示,可能作出对本发明的许多修改和变化。因此,应理解,在所附权利要求书的范围内,可以与上文具体描述的不同的方式来实践本发明。权利要求1.一种电池充电器,其包括电池充电电路,其用于提供电池充电电流对电池进行充电,所述电池充电电流电路经配置以提供在两个非零平均DC值之间交变的平均DC充电值,从而界定具有低平均DC充电电流和相对较高平均DC充电电流的快速充电波形。2.根据权利要求l所述的电池充电器,其中所述电池充电电流是线性电池充电器。3.根据权利要求1所述的电池充电器,其中所述电池充电电流是开关模式电池充电器。4.根据权利要求1所述的电池充电器,其中所述快速充电波形是方波。5.根据权利要求1所述的电池充电器,其中所述快速充电波形从所述较低平均DC充电电流向所述较髙平均DC充电电流斜线上升。6.根据权利要求1所述的电池充电器,其中所述快速充电波形从所述较高平均DC充电电流向所述较低平均DC充电电流斜线下降。7.根据权利要求1所述的电池充电器,其中所述快速充电波形从所述较低平均DC充电电流向所述较高平均DC充电电流斜线上升,且所述快速充电波形从所述较高平均DC充电电流向所述较低平均DC充电电流斜线下降。8.根据权利要求1所述的电池充电器,其中所述快速充电波形的工作循环作为电池充电的函数而变化。9.根据权利要求l所述的电池充电器,其中所述电池充电器配置有多个可选择的充电速率。10.根据权利要求9所述的电池充电器,其中所述电池充电器经配置使得当选择所述可选择的充电速率中的一者或一者以上时自动产生所述快速充电波形。11.根据权利要求1所述的电池充电器,其中所述较高和较低平均DC充电电流在充电循环内是恒定的。12.根据权利要求1所述的电池充电器,其中所述较高和较低平均DC充电电流在充电循环内是不恒定的。13.—种对电池进行充电的方法,其包括以下步骤(a)在第一平均DC充电电流下对所述电池进行充电;以及(b)随后在第二平均DC充电电流下对所述电池进行充电,从而界定快速充电波形。14.根据权利要求13所述的方法,其进一步包含以下步骤(c)在一个或一个以上可选择的充电速率下以所述快速充电波形对所述电池进行充电。15.—种电池充电器,其包括电池充电电路,其配置有多个可选择的充电电平,并进一步经配置使得在一个充电电平下,充电电流由充电循环期间的至少两个平均DC充电电流组成,从而界定当选择所述可选择的充电电平时自动产生的快速充电波形。16.根据权利要求15所述的电池充电器,其中所述电池充电电路是线性电池充电器。17.根据权利要求15所述的电池充电器,其中所述电池充电电路是开关模式电池充电器。全文摘要本发明揭示一种电池充电器,其用于例如汽车和轮船型电池等各种电池。根据本发明的一方面,充电电流在非零DC充电电流电平之间交变。通过使所述充电电流在非零DC充电电平之间交变,电池可较快地充电到较高的容量(即,安培小时),因此缩短充电时间且同时允许所述电池充电器的额定值增加。根据本发明的另一重要方面,用于使所述充电电流交变的技术可在线性和开关模式电池充电器两者中实施。文档编号H02J7/04GK101253667SQ200680025856公开日2008年8月27日申请日期2006年7月14日优先权日2005年7月15日发明者托马斯·菲尼斯·约翰逊,约翰·F·沃尔德伦,约翰·S·怀廷申请人:舒马克电器公司
网友询问留言 已有0条留言
  • 还没有人留言评论。精彩留言会获得点赞!
1