;The Num of Instruction(Size):162. The Max Address(Begin with 0):162 

                MCU  ES7P169C

A    equ    0
R    equ    1
HRAM_0X0  equ  0X0
HRAM_0X1  equ  0X1
HRAM_0X2  equ  0X2
HRAM_0X3  equ  0X3
HRAM_0X4  equ  0X4
HRAM_0X5  equ  0X5
HRAM_0X6  equ  0X6
HRAM_0X7  equ  0X7
HRAM_0X8  equ  0X8
HRAM_0X81  equ  0X81
HRAM_0X82  equ  0X82
HRAM_0X83  equ  0X83
HRAM_0X84  equ  0X84
HRAM_0X87  equ  0X87
HRAM_0X88  equ  0X88
HRAM_0X89  equ  0X89
HRAM_0X9  equ  0X9
HRAM_0XA  equ  0Xa
HRAM_0XC1  equ  0Xc1
HRAM_0XC5  equ  0Xc5
HRAM_0XC7  equ  0Xc7
HRAM_0XCB  equ  0Xcb
HRAM_0XCD  equ  0Xcd
HRAM_0XD1  equ  0Xd1
HRAM_0XD4  equ  0Xd4
HRAM_0XD5  equ  0Xd5
HRAM_0XD8  equ  0Xd8
HRAM_0XDC  equ  0Xdc
HRAM_0XDD  equ  0Xdd
HRAM_0XE1  equ  0Xe1
HRAM_0XE2  equ  0Xe2
HRAM_0XE3  equ  0Xe3
HRAM_0XE4  equ  0Xe4

                ORG             0X00
HADR_0X0:
:0X0  c768f000                  AJMP            HADR_0X68
                                ORG             0X2
:0X2  6800                      GOTO            HADR_0X0
                                ORG             0X4
:0X4  c180                      PUSH
:0X5  e787                      CLR             HRAM_0X87
:0X6  e783                      CLR             HRAM_0X83
:0X7  5081                      MOV             HRAM_0X81,      A
:0X8  e600                      MOVA            (SAVED_FSR)&7f                        ;(SAVED_FSR)&7f: Bank 0    Addr: 0    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
:0X9  5082                      MOV             HRAM_0X82,      A
:0Xa  e601                      MOVA            (SAVED_FSR+1)&7f                      ;(SAVED_FSR+1)&7f: Bank 0    Addr: 1    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
:0Xb  500f                      MOV             (CSEG_PTR)&7f,  A                     ;(CSEG_PTR)&7f: Bank 0    Addr: 15     
:0Xc  e611                      MOVA            (CSEG_PTR+2)&7f                       ;(CSEG_PTR+2)&7f: Bank 0    Addr: 17     
:0Xd  5010                      MOV             (CSEG_PTR+1)&7f,                A     ;(CSEG_PTR+1)&7f: Bank 0    Addr: 16     
:0Xe  e612                      MOVA            (CSEG_PTR+3)&7f                       ;(CSEG_PTR+3)&7f: Bank 0    Addr: 18     
:0Xf  500b                      MOV             (MUL_TEMP)&7f,  A                     ;(MUL_TEMP)&7f: Bank 0    Addr: 11     
:0X10  e60d                     MOVA            (MUL_TEMP+2)&7f                      ;(MUL_TEMP+2)&7f: Bank 0    Addr: 13     
:0X11  500c                     MOV             (MUL_TEMP+1)&7f,                A    ;(MUL_TEMP+1)&7f: Bank 0    Addr: 12     
:0X12  e60e                     MOVA            (MUL_TEMP+3)&7f                      ;(MUL_TEMP+3)&7f: Bank 0    Addr: 14     
:0X13  5007                     MOV             HRAM_0X7,       A
:0X14  e603                     MOVA            HRAM_0X3
:0X15  5008                     MOV             HRAM_0X8,       A
:0X16  e604                     MOVA            HRAM_0X4
:0X17  5009                     MOV             HRAM_0X9,       A
:0X18  e605                     MOVA            HRAM_0X5
:0X19  500a                     MOV             HRAM_0XA,       A
:0X1a  e606                     MOVA            HRAM_0X6
;
;/*******************************************************
;函数名：void isr(void) interrupt
;描  述：中断服务程序，两次捕捉1中断表示一个pwm周期的长度
;输入值：无
;输出值：无
;返回值：无
;*******************************************************/
;void isr(void) interrupt
;{
;    if (MIS1==1 && MIF1==1)       //捕捉1中断
:0X1b  e500                     MOVI            0X0
:0X1c  99cb                     JBC             HRAM_0XCB,      1
:0X1d  e501                     MOVI            0X1
:0X1e  ea01                     SECTION         0X1
:0X1f  e600                     MOVA            HRAM_0X0
:0X20  5000                     MOV             HRAM_0X0,       A
:0X21  e301                     XORI            0X1
:0X22  9284                     JBS             HRAM_0X84,      2
:0X23  684c                     GOTO            HADR_0X4C
:0X24  e500                     MOVI            0X0
:0X25  99cd                     JBC             HRAM_0XCD,      1
:0X26  e501                     MOVI            0X1
:0X27  e600                     MOVA            HRAM_0X0
:0X28  5000                     MOV             HRAM_0X0,       A
:0X29  e301                     XORI            0X1
:0X2a  9284                     JBS             HRAM_0X84,      2
:0X2b  684c                     GOTO            HADR_0X4C
;    {
;        MIC1 = 1;       //清捕捉1中断标志
:0X2c  a1d1                     BSS             HRAM_0XD1,      1
;        T31IF = 0;      //清定时器总标志位
:0X2d  aa9a                     BCC             (_T31IF_0)>>3,  2                    ;(_T31IF_0)>>3: Bank 511    Addr: 65434    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;
;        Period = T31CH1RH;        //保存捕捉事件时计数器的值
:0X2e  e707                     CLR             (_Period+1)&7f                       ;(_Period+1)&7f: Bank 0    Addr: 7     
:0X2f  50e2                     MOV             HRAM_0XE2,      A
:0X30  e606                     MOVA            (_Period)&7f                         ;(_Period)&7f: Bank 0    Addr: 6     
;        Period = (Period<<8) | T31CH1RL;
:0X31  5006                     MOV             (_Period)&7f,   A                    ;(_Period)&7f: Bank 0    Addr: 6     
:0X32  e601                     MOVA            HRAM_0X1
:0X33  e700                     CLR             HRAM_0X0
:0X34  e703                     CLR             HRAM_0X3
:0X35  50e1                     MOV             HRAM_0XE1,      A
:0X36  e602                     MOVA            HRAM_0X2
:0X37  5002                     MOV             HRAM_0X2,       A
:0X38  5800                     IOR             HRAM_0X0,       A
:0X39  e606                     MOVA            (_Period)&7f                         ;(_Period)&7f: Bank 0    Addr: 6     
:0X3a  5003                     MOV             HRAM_0X3,       A
:0X3b  5801                     IOR             HRAM_0X1,       A
:0X3c  e607                     MOVA            (_Period+1)&7f                       ;(_Period+1)&7f: Bank 0    Addr: 7     
;        Duty = T31CH2RH;          //保存捕捉事件时计数器的值
:0X3d  e705                     CLR             (_Duty+1)&7f                         ;(_Duty+1)&7f: Bank 0    Addr: 5     
:0X3e  50e4                     MOV             HRAM_0XE4,      A
:0X3f  e604                     MOVA            (_Duty)&7f                           ;(_Duty)&7f: Bank 0    Addr: 4     
;        Duty = (Duty<<8) | T31CH2RL;
:0X40  5004                     MOV             (_Duty)&7f,     A                    ;(_Duty)&7f: Bank 0    Addr: 4     
:0X41  e601                     MOVA            HRAM_0X1
:0X42  e700                     CLR             HRAM_0X0
:0X43  e703                     CLR             HRAM_0X3
:0X44  50e3                     MOV             HRAM_0XE3,      A
:0X45  e602                     MOVA            HRAM_0X2
:0X46  5002                     MOV             HRAM_0X2,       A
:0X47  5800                     IOR             HRAM_0X0,       A
:0X48  e604                     MOVA            (_Duty)&7f                           ;(_Duty)&7f: Bank 0    Addr: 4     
:0X49  5003                     MOV             HRAM_0X3,       A
:0X4a  5801                     IOR             HRAM_0X1,       A
:0X4b  e605                     MOVA            (_Duty+1)&7f                         ;(_Duty+1)&7f: Bank 0    Addr: 5     
HADR_0X4C:
;    }
;}
:0X4c  ea00                     SECTION         0X0
:0X4d  684e                     GOTO            HADR_0X4E
HADR_0X4E:
:0X4e  ffff                     NOP
:0X4f  ffff                     NOP
:0X50  5003                     MOV             HRAM_0X3,       A
:0X51  e607                     MOVA            HRAM_0X7
:0X52  5004                     MOV             HRAM_0X4,       A
:0X53  e608                     MOVA            HRAM_0X8
:0X54  5005                     MOV             HRAM_0X5,       A
:0X55  e609                     MOVA            HRAM_0X9
:0X56  5006                     MOV             HRAM_0X6,       A
:0X57  e60a                     MOVA            HRAM_0XA
:0X58  5012                     MOV             (CSEG_PTR+3)&7f,                A    ;(CSEG_PTR+3)&7f: Bank 0    Addr: 18     
:0X59  e610                     MOVA            (CSEG_PTR+1)&7f                      ;(CSEG_PTR+1)&7f: Bank 0    Addr: 16     
:0X5a  5011                     MOV             (CSEG_PTR+2)&7f,                A    ;(CSEG_PTR+2)&7f: Bank 0    Addr: 17     
:0X5b  e60f                     MOVA            (CSEG_PTR)&7f                        ;(CSEG_PTR)&7f: Bank 0    Addr: 15     
:0X5c  500d                     MOV             (MUL_TEMP+2)&7f,                A    ;(MUL_TEMP+2)&7f: Bank 0    Addr: 13     
:0X5d  e60b                     MOVA            (MUL_TEMP)&7f                        ;(MUL_TEMP)&7f: Bank 0    Addr: 11     
:0X5e  e688                     MOVA            HRAM_0X88
:0X5f  500e                     MOV             (MUL_TEMP+3)&7f,                A    ;(MUL_TEMP+3)&7f: Bank 0    Addr: 14     
:0X60  e60c                     MOVA            (MUL_TEMP+1)&7f                      ;(MUL_TEMP+1)&7f: Bank 0    Addr: 12     
:0X61  e689                     MOVA            HRAM_0X89
:0X62  5001                     MOV             (SAVED_FSR+1)&7f,               A    ;(SAVED_FSR+1)&7f: Bank 0    Addr: 1    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
:0X63  e682                     MOVA            HRAM_0X82
:0X64  5000                     MOV             (SAVED_FSR)&7f, A                    ;(SAVED_FSR)&7f: Bank 0    Addr: 0    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
:0X65  e681                     MOVA            HRAM_0X81
:0X66  c181                     POP
:0X67  c189                     RETIE
HADR_0X68:
;
;/*******************************************************
;函数名：void main(void)
;描  述：主函数，pwm输入模式，两个捕捉通道映射到一个输入口T31_CH1(PB5)，由T31_CH1(PB5)输入波形。
;        通道1捕捉上升沿成功时将计数器的值复制到T31CH1R，并复位计数器重新从0开始计数，通道2捕捉
;        下降沿成功时将计数器的值复制到T31CH2R。则在一个pwm周期，T31CH1R保存PWM的长度，T31CH2R保存PWM占空比长度
;输入值：无
;输出值：无
;返回值：无
;*******************************************************/
;void main(void) 
;{
;    RAMclear();
:0X68  e783                     CLR             HRAM_0X83
:0X69  ec00                     PAGE            (_RAMclear)>>11
:0X6a  6084                     CALL            HADR_0X84
:0X6b  ec00                     PAGE            (_0)>>11
;    GPIOInit();
:0X6c  ec00                     PAGE            (_GPIOInit)>>11
:0X6d  6096                     CALL            HADR_0X96
:0X6e  ec00                     PAGE            (_1)>>11
;    T31PRSH = 0x00;       //预分频系数1:16
:0X6f  e7dd                     CLR             HRAM_0XDD
;    T31PRSL = 0x0F; 
:0X70  e50f                     MOVI            0XF
:0X71  e6dc                     MOVA            HRAM_0XDC
;    T31CH2C = 0x02;       //T31_CH1作为通道2的捕捉管脚，无滤波，无预分频
:0X72  e502                     MOVI            0X2
:0X73  e6d5                     MOVA            HRAM_0XD5
;    T31CH1C = 0x01;       //T31_CH1作为通道1的捕捉管脚，无滤波，无预分频
:0X74  e501                     MOVI            0X1
:0X75  e6d4                     MOVA            HRAM_0XD4
;    T31PINCL = 0x20;      //通道2下降沿有效，通道1上升沿有效
:0X76  e520                     MOVI            0X20
:0X77  e6d8                     MOVA            HRAM_0XD8
;    T31C2L = 0x54;        //选择通道1为触发输入(TRGI)，上升沿重新初始化计数器
:0X78  e554                     MOVI            0X54
:0X79  e6c5                     MOVA            HRAM_0XC5
;    CH2E = 1;       //使能通道2捕捉
:0X7a  a4d8                     BSS             HRAM_0XD8,      4
;    CH1E = 1;       //使能通道1捕捉
:0X7b  a0d8                     BSS             HRAM_0XD8,      0
;    MIE1 = 1;       //使能通道1捕捉中断
:0X7c  a1c7                     BSS             HRAM_0XC7,      1
;    T31IE = 1;      //开启多功能定时器中断
:0X7d  a299                     BSS             (_T31IE_0)>>3,  2                    ;(_T31IE_0)>>3: Bank 511    Addr: 65433    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    MIC1 = 1;       //清捕捉1中断标志
:0X7e  a1d1                     BSS             HRAM_0XD1,      1
;    T31IF = 0;      //清定时器总标志位
:0X7f  aa9a                     BCC             (_T31IF_0)>>3,  2                    ;(_T31IF_0)>>3: Bank 511    Addr: 65434    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    GIE = 1;        //开全局中断
:0X80  a796                     BSS             (_GIE_0)>>3,    7                    ;(_GIE_0)>>3: Bank 511    Addr: 65430    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    T31EN = 1;      //使能计数器
:0X81  a0c1                     BSS             HRAM_0XC1,      0
HADR_0X82:
;    while (1)
:0X82  c18b                     CWDT
;    }
:0X83  6882                     GOTO            HADR_0X82
HADR_0X84:
;/*******************************************************
;*Copyright(C),2020,Shanghai Eastsoft Microelectronics Co.,Ltd.
;*文件名：capture_pwm_input.c
;*作  者：AE Team
;*版  本：v1.0，编译于iDesigner(v4.2.3.166) + 工具链HRCC(v1.2.0.106)
;*日  期：2020/07/23
;*描  述：多功能定时器pwm输入捕捉模式，T31_CH1(PB5)输入波形，调试状态下全速运行程序后暂停，
;        可以直接查看波形的周期长度和占空比长度
;        注意：若程序在调试状态下暂停运行，由于pwm仍在输入且捕捉功能依然有效，T31CH1R和T31CH2R仍会更新。所以
;        程序暂停时若程序计数器停止在捕捉中断函数中则有可能得到不正确的Period和Duty。用户可尝试将断点打在捕捉1中断
;        函数中的不同语句上实际查看Period、Duty、T31CH1R、T31CH2R的值体验一下。程序全速运行时不受影响。
;        建议：设置合理的预分频，最好保证pwm周期小于计数器溢出周期。
;*备  注：本软件仅供学习和演示使用，对用户直接引用代码所带来的风险或后果不承担任何法律责任。
;*******************************************************/
;#include <hic.h>
;
;#define CLRWDT()   {__Asm CWDT;}        //宏定义清狗指令
;
;unsigned int Period,Duty;        //保存pwm输入的波形周期和占空比
;
;/******************************************************
;函数名：void RAMclear(void)
;描  述：RAM区数据清零，RAM区地址0x0000~0x03FF
;输入值：无
;输出值：无
;返回值：无
;*******************************************************/
;void RAMclear(void)
;{
;    for (IAAH=0; IAAH<=0x03; IAAH++)
:0X84  e783                     CLR             HRAM_0X83
:0X85  e782                     CLR             _IAAH_0                              ;_IAAH_0: Bank 511    Addr: 65410    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
HADR_0X86:
:0X86  5082                     MOV             _IAAH_0,        A                    ;_IAAH_0: Bank 511    Addr: 65410    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
:0X87  ce03                     SUBI            0X3
:0X88  9084                     JBS             HRAM_0X84,      0
:0X89  6895                     GOTO            HADR_0X95
;    {
;        for (IAAL=0; IAAL<0xFF; IAAL++)
:0X8a  e781                     CLR             _IAAL_0                              ;_IAAL_0: Bank 511    Addr: 65409    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
HADR_0X8B:
:0X8b  e5ff                     MOVI            0XFF
:0X8c  ee81                     SUB             _IAAL_0,        A                    ;_IAAL_0: Bank 511    Addr: 65409    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
:0X8d  9884                     JBC             HRAM_0X84,      0
:0X8e  6892                     GOTO            HADR_0X92
;            IAD = 0x00;
:0X8f  e780                     CLR             _IAD_0                               ;_IAD_0: Bank 511    Addr: 65408    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
:0X90  5581                     INC             _IAAL_0,        R                    ;_IAAL_0: Bank 511    Addr: 65409    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
:0X91  688b                     GOTO            HADR_0X8B
HADR_0X92:
;        IAD = 0x00;
:0X92  e780                     CLR             _IAD_0                               ;_IAD_0: Bank 511    Addr: 65408    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
:0X93  5582                     INC             _IAAH_0,        R                    ;_IAAH_0: Bank 511    Addr: 65410    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    }
:0X94  6886                     GOTO            HADR_0X86
HADR_0X95:
;}
:0X95  c183                     RET
HADR_0X96:
;
;/******************************************************
;函数名：void GPIOInit(void)
;描  述：首先初始化所有未用到的IO口为输出低电平
;输入值：无
;输出值：无
;返回值：无
;*******************************************************/
;void GPIOInit(void)
;{
;    ANSL = 0xFF;        //选择对应端口为数字IO功能
:0X96  e783                     CLR             HRAM_0X83
:0X97  e5ff                     MOVI            0XFF
:0X98  e6bc                     MOVA            _ANSL_0                              ;_ANSL_0: Bank 511    Addr: 65468    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    ANSH = 0xFF;
:0X99  e5ff                     MOVI            0XFF
:0X9a  e68d                     MOVA            _ANSH_0                              ;_ANSH_0: Bank 511    Addr: 65421    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    PAT = 0x00;         //所有IO设为输出低电平
:0X9b  e7ad                     CLR             _PAT_0                               ;_PAT_0: Bank 511    Addr: 65453    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    PBT = 0x00;
:0X9c  e7ae                     CLR             _PBT_0                               ;_PBT_0: Bank 511    Addr: 65454    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    PCT = 0x00;
:0X9d  e7af                     CLR             _PCT_0                               ;_PCT_0: Bank 511    Addr: 65455    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    PA = 0x00;
:0X9e  e7a8                     CLR             _PA_0                                ;_PA_0: Bank 511    Addr: 65448    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    PB = 0x00;
:0X9f  e7a9                     CLR             _PB_0                                ;_PB_0: Bank 511    Addr: 65449    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    PC = 0x00;
:0Xa0  e7aa                     CLR             _PC_0                                ;_PC_0: Bank 511    Addr: 65450    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;
;    PBT5 = 1;           //T31_CH1设为输入
:0Xa1  a5ae                     BSS             (_PBT5_0)>>3,   5                    ;(_PBT5_0)>>3: Bank 511    Addr: 65454    C:\Users\lisq\Desktop\AN135_Examples_ES7P169C\T31\capture_pwm_input\debug\capture_pwm_input.obj 
;    //PBPU5 = 1;          //使能上拉
;}
:0Xa2  c183                     RET

                                END
