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

                MCU  ES7P169C

A    equ    0
R    equ    1
HRAM_0X1  equ  0X1
HRAM_0X10  equ  0X10
HRAM_0X19  equ  0X19
HRAM_0X1A  equ  0X1a
HRAM_0X1B  equ  0X1b
HRAM_0X1C  equ  0X1c
HRAM_0X1D  equ  0X1d
HRAM_0X1F  equ  0X1f
HRAM_0X20  equ  0X20
HRAM_0X21  equ  0X21
HRAM_0X22  equ  0X22
HRAM_0X23  equ  0X23
HRAM_0X24  equ  0X24
HRAM_0X25  equ  0X25
HRAM_0X26  equ  0X26
HRAM_0X3  equ  0X3
HRAM_0X6  equ  0X6
HRAM_0X80  equ  0X80
HRAM_0X81  equ  0X81
HRAM_0X82  equ  0X82
HRAM_0X83  equ  0X83
HRAM_0X84  equ  0X84
HRAM_0X86  equ  0X86
HRAM_0X87  equ  0X87
HRAM_0X94  equ  0X94
HRAM_0X96  equ  0X96
HRAM_0X9A  equ  0X9a
HRAM_0X9B  equ  0X9b
HRAM_0X9C  equ  0X9c
HRAM_0X9D  equ  0X9d
HRAM_0X9E  equ  0X9e
HRAM_0X9F  equ  0X9f
HRAM_0XA0  equ  0Xa0
HRAM_0XA1  equ  0Xa1
HRAM_0XA2  equ  0Xa2
HRAM_0XA3  equ  0Xa3
HRAM_0XA4  equ  0Xa4
HRAM_0XA5  equ  0Xa5
HRAM_0XA6  equ  0Xa6
HRAM_0XA7  equ  0Xa7
HRAM_0XA8  equ  0Xa8
HRAM_0XD6  equ  0Xd6
HRAM_0XD7  equ  0Xd7
HRAM_0XD8  equ  0Xd8
HRAM_0XF7  equ  0Xf7
HRAM_0XF8  equ  0Xf8
HRAM_0XF9  equ  0Xf9
HRAM_0XFA  equ  0Xfa
HRAM_0XFB  equ  0Xfb

                ORG             0X00
HADR_0X0:
:0X0  6120                      CALL            HADR_0X120
:0X1  c704f000                  AJMP            HADR_0X4
                                ORG             0X3
:0X3  6800                      GOTO            HADR_0X0
HADR_0X4:
;}
;
;/**********************************************
;函数名：main()
;描  述：主函数,选择AIN7通道，测量值经UART传送到上位机
;输入值：无
;输出值：无
;返回值：无
;**********************************************/
;void main(void)
;{
;    uint i = 10000;       //延时变量
;    uint j = 3000;        //延时变量
;    uchar cnt = 3;
:0X4  e783                      CLR             HRAM_0X83
:0X5  e503                      MOVI            0X3
:0X6  ea01                      SECTION         0X1
:0X7  e619                      MOVA            HRAM_0X19
;
;//    RAMclear();
;    CLRWDT();
:0X8  c18b                      CWDT
;    GPIOInit();
:0X9  ec00                      PAGE            (_GPIOInit)>>11
HADR_0XA:
:0Xa  60e8                      CALL            HADR_0XE8
:0Xb  ec00                      PAGE            (_6)>>11
;
;    /****************初始化UART*******************/
;    PBT5 = 0;       //TX输出
:0Xc  adae                      BCC             (_PBT5_0)>>3,   5                     ;(_PBT5_0)>>3: Bank 511    Addr: 65454    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
HADR_0XD:
;    PBT6 = 1;       //RX输入
:0Xd  a6ae                      BSS             (_PBT6_0)>>3,   6                     ;(_PBT6_0)>>3: Bank 511    Addr: 65454    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    TX1LEN = 0;     //8位数据发送格式
:0Xe  a483                      BSS             HRAM_0X83,      4
:0Xf  aed7                      BCC             HRAM_0XD7,      6
;    BRGH1 = 0;      //波特率低速模式：波特率=Fosc/(64*(BRR<7:0>+1))
:0X10  add7                     BCC             HRAM_0XD7,      5
;    BR1R = 25;      //波特率=16MHz/(64*26)≈9600bps
:0X11  e519                     MOVI            0X19
HADR_0X12:
:0X12  e6d8                     MOVA            HRAM_0XD8
HADR_0X13:
;
;    /****************初始化ADC********************/
;#ifdef VDDVREF
;
;    while (cnt != 0)
:0X13  ea01                     SECTION         0X1
:0X14  5019                     MOV             HRAM_0X19,      A
:0X15  9a84                     JBC             HRAM_0X84,      2
:0X16  6854                     GOTO            HADR_0X54
;    {
;        offset_value = GetOffsetVDD();  //获取offset值
:0X17  ec00                     PAGE            (_GetOffsetVDD)>>11
:0X18  6220                     CALL            HADR_0X220
:0X19  ec00                     PAGE            (_7)>>11
HADR_0X1A:
:0X1a  2080                     MOVAR           _offset_value                        ;_offset_value: Bank 1    Addr: 128     
:0X1b  5001                     MOV             (?_TMP+1)&7f,   A                    ;(?_TMP+1)&7f: Bank 0    Addr: 1     
:0X1c  2081                     MOVAR           _offset_value+1                      ;_offset_value+1: Bank 1    Addr: 129     
;
;        if ((offset_value >> 8) == ((~offset_value) & 0x00FF)) //是否满足高低8位取反，是则取低8位作为offset
:0X1d  ea01                     SECTION         0X1
:0X1e  5200                     COM             (_offset_value)&7f,             A    ;(_offset_value)&7f: Bank 0    Addr: 0     
:0X1f  e61a                     MOVA            HRAM_0X1A
:0X20  5201                     COM             (_offset_value+1)&7f,           A    ;(_offset_value+1)&7f: Bank 0    Addr: 1     
HADR_0X21:
:0X21  e61b                     MOVA            HRAM_0X1B
:0X22  e508                     MOVI            0X8
:0X23  e001                     ADDI            0X1
:0X24  2000                     MOVAR           ?_TMP                                ;?_TMP: Bank 0    Addr: 0     
:0X25  5000                     MOV             (_offset_value)&7f,             A    ;(_offset_value)&7f: Bank 0    Addr: 0     
:0X26  2001                     MOVAR           ?_TMP+1                              ;?_TMP+1: Bank 0    Addr: 1     
:0X27  5001                     MOV             (_offset_value+1)&7f,           A    ;(_offset_value+1)&7f: Bank 0    Addr: 1     
:0X28  2002                     MOVAR           ?_TMP+2                              ;?_TMP+2: Bank 0    Addr: 2     
:0X29  7800                     MOVRA           ?_TMP                                ;?_TMP: Bank 0    Addr: 0     
:0X2a  682f                     GOTO            HADR_0X2F
HADR_0X2B:
:0X2b  a884                     BCC             HRAM_0X84,      0
:0X2c  ea00                     SECTION         0X0
:0X2d  d102                     RRB             (?_TMP+2)&7f,   R,              0X1  ;(?_TMP+2)&7f: Bank 0    Addr: 2     
:0X2e  d101                     RRB             (?_TMP+1)&7f,   R,              0X1  ;(?_TMP+1)&7f: Bank 0    Addr: 1     
HADR_0X2F:
:0X2f  e0ff                     ADDI            0XFF
:0X30  9284                     JBS             HRAM_0X84,      2
:0X31  682b                     GOTO            HADR_0X2B
:0X32  ea00                     SECTION         0X0
:0X33  5001                     MOV             (?_TMP+1)&7f,   A                    ;(?_TMP+1)&7f: Bank 0    Addr: 1     
:0X34  209c                     MOVAR           HRAM_0X9C
HADR_0X35:
:0X35  5002                     MOV             (?_TMP+2)&7f,   A                    ;(?_TMP+2)&7f: Bank 0    Addr: 2     
:0X36  209d                     MOVAR           HRAM_0X9D
:0X37  789a                     MOVRA           HRAM_0X9A
:0X38  e2ff                     ANDI            0XFF
:0X39  209e                     MOVAR           HRAM_0X9E
:0X3a  789b                     MOVRA           HRAM_0X9B
:0X3b  e200                     ANDI            0X0
:0X3c  209f                     MOVAR           HRAM_0X9F
:0X3d  789e                     MOVRA           HRAM_0X9E
:0X3e  ea01                     SECTION         0X1
:0X3f  5c1c                     XOR             HRAM_0X1C,      A
:0X40  9284                     JBS             HRAM_0X84,      2
:0X41  6845                     GOTO            HADR_0X45
:0X42  501f                     MOV             HRAM_0X1F,      A
:0X43  5c1d                     XOR             HRAM_0X1D,      A
:0X44  9284                     JBS             HRAM_0X84,      2
HADR_0X45:
:0X45  684d                     GOTO            HADR_0X4D
;        {
;            offset_value =  offset_value & 0x00FF;
:0X46  5000                     MOV             (_offset_value)&7f,             A    ;(_offset_value)&7f: Bank 0    Addr: 0     
:0X47  e2ff                     ANDI            0XFF
:0X48  e600                     MOVA            (_offset_value)&7f                   ;(_offset_value)&7f: Bank 0    Addr: 0     
:0X49  5001                     MOV             (_offset_value+1)&7f,           A    ;(_offset_value+1)&7f: Bank 0    Addr: 1     
:0X4a  e200                     ANDI            0X0
:0X4b  e601                     MOVA            (_offset_value+1)&7f                 ;(_offset_value+1)&7f: Bank 0    Addr: 1     
;
;            break;
:0X4c  6854                     GOTO            HADR_0X54
HADR_0X4D:
;        }
;        else
:0X4d  1119                     DEC             HRAM_0X19,      R
;
;            if (cnt == 0)
:0X4e  5019                     MOV             HRAM_0X19,      A
:0X4f  9284                     JBS             HRAM_0X84,      2
:0X50  6813                     GOTO            HADR_0X13
;                offset_value = 0;  //读IAP超过3次后仍不满足高低8位取反则offset固定为0
:0X51  e700                     CLR             (_offset_value)&7f                   ;(_offset_value)&7f: Bank 0    Addr: 0     
:0X52  e701                     CLR             (_offset_value+1)&7f                 ;(_offset_value+1)&7f: Bank 0    Addr: 1     
;        }
;    }
:0X53  6813                     GOTO            HADR_0X13
HADR_0X54:
;
;    ANSL7 = 0;          //选择AIN7为模拟口
:0X54  afbc                     BCC             (_ANSL7_0)>>3,  7                    ;(_ANSL7_0)>>3: Bank 511    Addr: 65468    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    ADCCL |= 0xF0;      //ADCCL<7:4>选择通道
:0X55  ac83                     BCC             HRAM_0X83,      4
:0X56  50fa                     MOV             HRAM_0XFA,      A
:0X57  e1f0                     IORI            0XF0
:0X58  e6fa                     MOVA            HRAM_0XFA
;    ADCCL &= 0x7F;      //选择通道7
:0X59  affa                     BCC             HRAM_0XFA,      7
;    ADCCM = 0x4B;       //参考源VDD,负参考固定选择VSS，转换位数固定选择12位，AD调整offset固定选择档位1
:0X5a  e54b                     MOVI            0X4B
:0X5b  e6f7                     MOVA            HRAM_0XF7
;    ADCCH = 0xC8;       //低位对齐;时钟周期FOSC/16
:0X5c  e5c8                     MOVI            0XC8
:0X5d  e6fb                     MOVA            HRAM_0XFB
;    ADEN = 1;           //使能ADC模块
:0X5e  a0fa                     BSS             HRAM_0XFA,      0
;#else
;
;    while (cnt != 0)
;    {
;        offset_value = GetOffset2048();  //获取offset值
;
;        if ((offset_value >> 8) == ((~offset_value) & 0x00FF)) //是否满足高低八位取反，是则取低8位作为offset
;        {
;            offset_value =  offset_value & 0x00FF;
;
;            break;
;        }
;        else
;        {
;            cnt--;
;
;            if (cnt == 0)
;                offset_value = 0;    //读IAP超过3次后仍不满足高低8位取反则offset固定为0
;        }
;    }
;
;    ANSL7 = 0;          //选择AIN7为模拟口
;    ADCCL |= 0xF0;      //ADCCL<7:4>选择通道
;    ADCCL &= 0x7F;      //选择通道7
;    ADCCM = 0x6B;       //参考源内部固定选择2.048V,负参考固定选择VSS，转换位数固定选择12位，AD调整offset固定选择档位1
;    ADCCH = 0xC8;       //低位对齐;时钟周期FOSC/16
;    ADEN = 1;           //使能ADC模块
;    VREFEN = 1;         //参考电压模块使能
;
;    while (j--);        //等待300us以上
;
;    VREF_CHOPEN = 1;    //内部参考必须使能电压斩波器
;
;    while (i--);        //等待1ms以上再启动转换
;
;#endif
;
;    ADC_LP_EN = 1;      //ADC低功耗必须固定使能
:0X5f  a5ba                     BSS             (_ADC_LP_EN_0)>>3,              5    ;(_ADC_LP_EN_0)>>3: Bank 511    Addr: 65466    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    PAT7 = 1;
:0X60  a7ad                     BSS             (_PAT7_0)>>3,   7                    ;(_PAT7_0)>>3: Bank 511    Addr: 65453    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    SMPS = 1;           //硬件控制采样，ADTRG=1时启动AD采样转换
:0X61  a2fa                     BSS             HRAM_0XFA,      2
HADR_0X62:
;
;    while (1)
:0X62  ec00                     PAGE            (_ADC_convert)>>11
:0X63  6204                     CALL            HADR_0X204
:0X64  ec00                     PAGE            (_8)>>11
:0X65  20a9                     MOVAR           _adc_value                           ;_adc_value: Bank 1    Addr: 169     
:0X66  5001                     MOV             (?_TMP+1)&7f,   A                    ;(?_TMP+1)&7f: Bank 0    Addr: 1     
:0X67  20aa                     MOVAR           _adc_value+1                         ;_adc_value+1: Bank 1    Addr: 170     
;
;        if (adc_value > offset_value)  //AD转换值大于offset值则减去offset，否则ADC结果归0
:0X68  78aa                     MOVRA           _adc_value+1                         ;_adc_value+1: Bank 1    Addr: 170     
:0X69  ea01                     SECTION         0X1
:0X6a  ee01                     SUB             (_offset_value+1)&7f,           A    ;(_offset_value+1)&7f: Bank 0    Addr: 1     
:0X6b  9284                     JBS             HRAM_0X84,      2
:0X6c  686f                     GOTO            HADR_0X6F
:0X6d  5029                     MOV             (_adc_value)&7f,                A    ;(_adc_value)&7f: Bank 0    Addr: 41     
:0X6e  ee00                     SUB             (_offset_value)&7f,             A    ;(_offset_value)&7f: Bank 0    Addr: 0     
HADR_0X6F:
:0X6f  9884                     JBC             HRAM_0X84,      0
:0X70  6878                     GOTO            HADR_0X78
;            adc_value -= offset_value;
:0X71  5000                     MOV             (_offset_value)&7f,             A    ;(_offset_value)&7f: Bank 0    Addr: 0     
:0X72  ee29                     SUB             (_adc_value)&7f,                A    ;(_adc_value)&7f: Bank 0    Addr: 41     
:0X73  e629                     MOVA            (_adc_value)&7f                      ;(_adc_value)&7f: Bank 0    Addr: 41     
:0X74  5001                     MOV             (_offset_value+1)&7f,           A    ;(_offset_value+1)&7f: Bank 0    Addr: 1     
:0X75  162a                     SUBC            (_adc_value+1)&7f,              A    ;(_adc_value+1)&7f: Bank 0    Addr: 42     
:0X76  e62a                     MOVA            (_adc_value+1)&7f                    ;(_adc_value+1)&7f: Bank 0    Addr: 42     
:0X77  687a                     GOTO            HADR_0X7A
HADR_0X78:
;        else
:0X78  e729                     CLR             (_adc_value)&7f                      ;(_adc_value)&7f: Bank 0    Addr: 41     
:0X79  e72a                     CLR             (_adc_value+1)&7f                    ;(_adc_value+1)&7f: Bank 0    Addr: 42     
HADR_0X7A:
;
;        TX1EN = 1;      //打开发送
:0X7a  a483                     BSS             HRAM_0X83,      4
:0X7b  a7d7                     BSS             HRAM_0XD7,      7
;        UART_send(str, 7, adc_value);
:0X7c  e582                     MOVI            _str
:0X7d  e620                     MOVA            HRAM_0X20
:0X7e  e500                     MOVI            (_str)>>8
:0X7f  e621                     MOVA            HRAM_0X21
:0X80  e507                     MOVI            0X7
:0X81  e622                     MOVA            HRAM_0X22
:0X82  5029                     MOV             (_adc_value)&7f,                A    ;(_adc_value)&7f: Bank 0    Addr: 41     
:0X83  e623                     MOVA            HRAM_0X23
:0X84  502a                     MOV             (_adc_value+1)&7f,              A    ;(_adc_value+1)&7f: Bank 0    Addr: 42     
:0X85  e624                     MOVA            HRAM_0X24
:0X86  ec00                     PAGE            (_UART_send)>>11
:0X87  6147                     CALL            HADR_0X147
:0X88  ec00                     PAGE            (_9)>>11
;
;        for (i = 0; i < 50000; i++);   //延时
:0X89  ea01                     SECTION         0X1
:0X8a  e719                     CLR             HRAM_0X19
:0X8b  e71a                     CLR             HRAM_0X1A
HADR_0X8C:
:0X8c  e5c3                     MOVI            0XC3
:0X8d  ee1a                     SUB             HRAM_0X1A,      A
:0X8e  9284                     JBS             HRAM_0X84,      2
:0X8f  6892                     GOTO            HADR_0X92
:0X90  e550                     MOVI            0X50
:0X91  ee19                     SUB             HRAM_0X19,      A
HADR_0X92:
:0X92  9884                     JBC             HRAM_0X84,      0
:0X93  6899                     GOTO            HADR_0X99
:0X94  5519                     INC             HRAM_0X19,      R
:0X95  9284                     JBS             HRAM_0X84,      2
:0X96  6898                     GOTO            HADR_0X98
:0X97  551a                     INC             HRAM_0X1A,      R
HADR_0X98:
:0X98  688c                     GOTO            HADR_0X8C
HADR_0X99:
;
;        for (i = 0; i < 50000; i++);
:0X99  e719                     CLR             HRAM_0X19
:0X9a  e71a                     CLR             HRAM_0X1A
HADR_0X9B:
:0X9b  e5c3                     MOVI            0XC3
:0X9c  ee1a                     SUB             HRAM_0X1A,      A
:0X9d  9284                     JBS             HRAM_0X84,      2
:0X9e  68a1                     GOTO            HADR_0XA1
:0X9f  e550                     MOVI            0X50
:0Xa0  ee19                     SUB             HRAM_0X19,      A
HADR_0XA1:
:0Xa1  9884                     JBC             HRAM_0X84,      0
:0Xa2  68a8                     GOTO            HADR_0XA8
:0Xa3  5519                     INC             HRAM_0X19,      R
:0Xa4  9284                     JBS             HRAM_0X84,      2
:0Xa5  68a7                     GOTO            HADR_0XA7
:0Xa6  551a                     INC             HRAM_0X1A,      R
HADR_0XA7:
:0Xa7  689b                     GOTO            HADR_0X9B
HADR_0XA8:
;
;        for (i = 0; i < 50000; i++);
:0Xa8  e719                     CLR             HRAM_0X19
:0Xa9  e71a                     CLR             HRAM_0X1A
HADR_0XAA:
:0Xaa  e5c3                     MOVI            0XC3
:0Xab  ee1a                     SUB             HRAM_0X1A,      A
:0Xac  9284                     JBS             HRAM_0X84,      2
:0Xad  68b0                     GOTO            HADR_0XB0
:0Xae  e550                     MOVI            0X50
:0Xaf  ee19                     SUB             HRAM_0X19,      A
HADR_0XB0:
:0Xb0  9884                     JBC             HRAM_0X84,      0
:0Xb1  68b7                     GOTO            HADR_0XB7
:0Xb2  5519                     INC             HRAM_0X19,      R
:0Xb3  9284                     JBS             HRAM_0X84,      2
:0Xb4  68b6                     GOTO            HADR_0XB6
:0Xb5  551a                     INC             HRAM_0X1A,      R
HADR_0XB6:
:0Xb6  68aa                     GOTO            HADR_0XAA
HADR_0XB7:
;
;        for (i = 0; i < 50000; i++);
:0Xb7  e719                     CLR             HRAM_0X19
:0Xb8  e71a                     CLR             HRAM_0X1A
HADR_0XB9:
:0Xb9  e5c3                     MOVI            0XC3
:0Xba  ee1a                     SUB             HRAM_0X1A,      A
:0Xbb  9284                     JBS             HRAM_0X84,      2
:0Xbc  68bf                     GOTO            HADR_0XBF
:0Xbd  e550                     MOVI            0X50
:0Xbe  ee19                     SUB             HRAM_0X19,      A
HADR_0XBF:
:0Xbf  9884                     JBC             HRAM_0X84,      0
:0Xc0  68c6                     GOTO            HADR_0XC6
:0Xc1  5519                     INC             HRAM_0X19,      R
:0Xc2  9284                     JBS             HRAM_0X84,      2
:0Xc3  68c5                     GOTO            HADR_0XC5
:0Xc4  551a                     INC             HRAM_0X1A,      R
HADR_0XC5:
:0Xc5  68b9                     GOTO            HADR_0XB9
HADR_0XC6:
;
;        for (i = 0; i < 50000; i++);
:0Xc6  e719                     CLR             HRAM_0X19
:0Xc7  e71a                     CLR             HRAM_0X1A
HADR_0XC8:
:0Xc8  e5c3                     MOVI            0XC3
:0Xc9  ee1a                     SUB             HRAM_0X1A,      A
:0Xca  9284                     JBS             HRAM_0X84,      2
:0Xcb  68ce                     GOTO            HADR_0XCE
:0Xcc  e550                     MOVI            0X50
:0Xcd  ee19                     SUB             HRAM_0X19,      A
HADR_0XCE:
:0Xce  9884                     JBC             HRAM_0X84,      0
:0Xcf  68d5                     GOTO            HADR_0XD5
:0Xd0  5519                     INC             HRAM_0X19,      R
:0Xd1  9284                     JBS             HRAM_0X84,      2
:0Xd2  68d4                     GOTO            HADR_0XD4
:0Xd3  551a                     INC             HRAM_0X1A,      R
HADR_0XD4:
:0Xd4  68c8                     GOTO            HADR_0XC8
HADR_0XD5:
;
;        for (i = 0; i < 50000; i++);
:0Xd5  e719                     CLR             HRAM_0X19
:0Xd6  e71a                     CLR             HRAM_0X1A
HADR_0XD7:
:0Xd7  e5c3                     MOVI            0XC3
:0Xd8  ee1a                     SUB             HRAM_0X1A,      A
:0Xd9  9284                     JBS             HRAM_0X84,      2
:0Xda  68dd                     GOTO            HADR_0XDD
:0Xdb  e550                     MOVI            0X50
:0Xdc  ee19                     SUB             HRAM_0X19,      A
HADR_0XDD:
:0Xdd  9884                     JBC             HRAM_0X84,      0
:0Xde  68e4                     GOTO            HADR_0XE4
:0Xdf  5519                     INC             HRAM_0X19,      R
:0Xe0  9284                     JBS             HRAM_0X84,      2
:0Xe1  68e3                     GOTO            HADR_0XE3
:0Xe2  551a                     INC             HRAM_0X1A,      R
HADR_0XE3:
:0Xe3  68d7                     GOTO            HADR_0XD7
HADR_0XE4:
;
;        TX1EN = 0;      //关闭发送
:0Xe4  a483                     BSS             HRAM_0X83,      4
:0Xe5  afd7                     BCC             HRAM_0XD7,      7
;
;        CLRWDT();
:0Xe6  c18b                     CWDT
;    }
:0Xe7  6862                     GOTO            HADR_0X62
HADR_0XE8:
;/*********************************************************
;*Copyright (C), 2020, Shanghai Eastsoft Microelectronics Co., Ltd
;*文件名:  adc_offset.c
;*作  者:  AE Team
;*版  本:  v1.0，编译于iDesigner(v4.2.3.187) + 工具链HRCC(v1.2.0.136)
;*日  期:  2020/12/25
;*描  述:  ADC通信演示
;          PA7：模拟输入端口
;          PB5：TX
;          PB6：RX
;          程序将转换完的AD值通过串口发送到上位机，波特率9600bps。宏定义VDDVREF选择VDD作为参考电压正端，
;          否则选择内部2.048V作为参考电压正端。
;          转换值减去offset进行ADC软件补偿，offset为802FH（内部2.048V作参考）和8030H（VDD作参考）低8位数据，
;          IAP读16位数据后需先判断是否满足高低8位取反。
;          注意：由于offset的存在，为防止溢出，转换值小于offset时，ADC结果直接归0；并且ADC最大只能测到(0xFFF-offset)。
;*备  注:  本软件仅供学习和演示使用，对用户直接引用代码所带来的风险或后果不承担任何法律责任。
;**********************************************************/
;#include <hic.h>
;
;#define VDDVREF        //宏定义选择VDD作为参考电压，注释本句则选择内部2.048V作为参考电压正端
;#define CLRWDT()   {__Asm CWDT;}        //宏定义清狗指令
;
;typedef unsigned char uchar;
;typedef unsigned int uint;
;
;uint adc_value;
;uint offset_value = 0;  //保存ADC校准值
;uchar str[] = "通道 的转换值为:    \r\n\0";
;
;/******************************************************
;函数名：void RAMclear(void)
;描  述：RAM区数据清零，RAM区地址0x0000~0x03FF
;输入值：无
;输出值：无
;返回值：无
;*******************************************************/
;void RAMclear(void)
;{
;    for (IAAH = 0; IAAH <= 0x03; IAAH++)
;    {
;        for (IAAL = 0; IAAL < 0xFF; IAAL++)
;            IAD = 0x00;
;
;        IAD = 0x00;
;    }
;}
;
;/******************************************************
;函数名：void GPIOInit(void)
;描  述：首先初始化所有未用到的IO口为输出低电平
;输入值：无
;输出值：无
;返回值：无
;*******************************************************/
;void GPIOInit(void)
;{
;    ANSH = 0xFF;        //选择对应端口为数字IO功能
:0Xe8  e783                     CLR             HRAM_0X83
:0Xe9  e5ff                     MOVI            0XFF
:0Xea  e68d                     MOVA            _ANSH_0                              ;_ANSH_0: Bank 511    Addr: 65421    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    ANSL = 0xFF;        //选择对应端口为数字IO功能
:0Xeb  e5ff                     MOVI            0XFF
:0Xec  e6bc                     MOVA            _ANSL_0                              ;_ANSL_0: Bank 511    Addr: 65468    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    PAT = 0x00;         //所有IO设为输出低电平
:0Xed  e7ad                     CLR             _PAT_0                               ;_PAT_0: Bank 511    Addr: 65453    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    PBT = 0x00;
:0Xee  e7ae                     CLR             _PBT_0                               ;_PBT_0: Bank 511    Addr: 65454    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    PCT = 0x00;
:0Xef  e7af                     CLR             _PCT_0                               ;_PCT_0: Bank 511    Addr: 65455    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    PA = 0x00;
:0Xf0  e7a8                     CLR             _PA_0                                ;_PA_0: Bank 511    Addr: 65448    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    PB = 0x00;
:0Xf1  e7a9                     CLR             _PB_0                                ;_PB_0: Bank 511    Addr: 65449    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    PC = 0x00;
:0Xf2  e7aa                     CLR             _PC_0                                ;_PC_0: Bank 511    Addr: 65450    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;}
:0Xf3  c183                     RET
                                ORG             0X100
HADR_0X100:
:0X100  5f86                    ADD             HRAM_0X86,      R
:0X101  e402                    RETIA           0X2
:0X102  e480                    RETIA           0X80
:0X103  e402                    RETIA           0X2
:0X104  e400                    RETIA           0X0
:0X105  e400                    RETIA           0X0
:0X106  e482                    RETIA           0X82
:0X107  e417                    RETIA           0X17
:0X108  e4cd                    RETIA           0XCD
:0X109  e4a8                    RETIA           0XA8
:0X10a  e4b5                    RETIA           0XB5
:0X10b  e4c0                    RETIA           0XC0
:0X10c  e420                    RETIA           0X20
:0X10d  e4b5                    RETIA           0XB5
:0X10e  e4c4                    RETIA           0XC4
:0X10f  e4d7                    RETIA           0XD7
:0X110  e4aa                    RETIA           0XAA
:0X111  e4bb                    RETIA           0XBB
:0X112  e4bb                    RETIA           0XBB
:0X113  e4d6                    RETIA           0XD6
:0X114  e4b5                    RETIA           0XB5
:0X115  e4ce                    RETIA           0XCE
:0X116  e4aa                    RETIA           0XAA
:0X117  e43a                    RETIA           0X3A
:0X118  e420                    RETIA           0X20
:0X119  e420                    RETIA           0X20
:0X11a  e420                    RETIA           0X20
:0X11b  e420                    RETIA           0X20
:0X11c  e40d                    RETIA           0XD
:0X11d  e40a                    RETIA           0XA
:0X11e  e400                    RETIA           0X0
:0X11f  e400                    RETIA           0X0
HADR_0X120:
:0X120  e783                    CLR             HRAM_0X83
:0X121  e501                    MOVI            (#_CINIT)>>8
:0X122  e687                    MOVA            HRAM_0X87
:0X123  e500                    MOVI            0X0
:0X124  e600                    MOVA            ?_TMP                               ;?_TMP: Bank 0    Addr: 0     
:0X125  5000                    MOV             ?_TMP,          A                   ;?_TMP: Bank 0    Addr: 0     
:0X126  ec00                    PAGE            (#_CINIT)>>11
:0X127  6100                    CALL            HADR_0X100
:0X128  e601                    MOVA            ?_TMP+1                             ;?_TMP+1: Bank 0    Addr: 1     
:0X129  5101                    MOV             ?_TMP+1,        R                   ;?_TMP+1: Bank 0    Addr: 1     
:0X12a  9a84                    JBC             HRAM_0X84,      2
:0X12b  c183                    RET
HADR_0X12C:
:0X12c  5500                    INC             ?_TMP,          R                   ;?_TMP: Bank 0    Addr: 0     
:0X12d  5000                    MOV             ?_TMP,          A                   ;?_TMP: Bank 0    Addr: 0     
:0X12e  ec00                    PAGE            (#_CINIT)>>11
:0X12f  6100                    CALL            HADR_0X100
:0X130  e602                    MOVA            ?_TMP+2                             ;?_TMP+2: Bank 0    Addr: 2     
:0X131  5500                    INC             ?_TMP,          R                   ;?_TMP: Bank 0    Addr: 0     
:0X132  5000                    MOV             ?_TMP,          A                   ;?_TMP: Bank 0    Addr: 0     
:0X133  ec00                    PAGE            (#_CINIT)>>11
:0X134  6100                    CALL            HADR_0X100
:0X135  e603                    MOVA            ?_TMP+3                             ;?_TMP+3: Bank 0    Addr: 3     
:0X136  613a                    CALL            HADR_0X13A
:0X137  5701                    JDEC            HRAM_0X1,       R
:0X138  692c                    GOTO            HADR_0X12C
:0X139  c183                    RET
HADR_0X13A:
:0X13a  5002                    MOV             ?_TMP+2,        A                   ;?_TMP+2: Bank 0    Addr: 2     
:0X13b  e681                    MOVA            HRAM_0X81
:0X13c  e500                    MOVI            0X0
:0X13d  e682                    MOVA            HRAM_0X82
:0X13e  5500                    INC             ?_TMP,          R                   ;?_TMP: Bank 0    Addr: 0     
:0X13f  5000                    MOV             ?_TMP,          A                   ;?_TMP: Bank 0    Addr: 0     
:0X140  ec00                    PAGE            (#_CINIT)>>11
:0X141  6100                    CALL            HADR_0X100
:0X142  e680                    MOVA            HRAM_0X80
:0X143  5502                    INC             ?_TMP+2,        R                   ;?_TMP+2: Bank 0    Addr: 2     
:0X144  5703                    JDEC            HRAM_0X3,       R
:0X145  693a                    GOTO            HADR_0X13A
:0X146  c183                    RET
HADR_0X147:
;
;/**********************************************
;函数名：UART_send(uchar *str,uchar ch,uint value)
;描  述：UART发送函数
;输入值：字符串指针，通道数，ADC转换值
;输出值：无
;返回值：无
;**********************************************/
;void UART_send(uchar *str, uchar ch, uint value)
;{
;    *(str + 4) = ch + '0';
:0X147  e783                    CLR             HRAM_0X83
:0X148  ea01                    SECTION         0X1
:0X149  5020                    MOV             HRAM_0X20,      A
:0X14a  e004                    ADDI            0X4
:0X14b  e625                    MOVA            HRAM_0X25
:0X14c  5021                    MOV             HRAM_0X21,      A
:0X14d  c300                    ADDCI           0X0
:0X14e  e626                    MOVA            HRAM_0X26
:0X14f  5026                    MOV             HRAM_0X26,      A
:0X150  e682                    MOVA            HRAM_0X82
:0X151  5025                    MOV             HRAM_0X25,      A
:0X152  e681                    MOVA            HRAM_0X81
:0X153  5022                    MOV             HRAM_0X22,      A
:0X154  e030                    ADDI            0X30
:0X155  e680                    MOVA            HRAM_0X80
:0X156  c201                    ISTEP           0X1
;    *(str + 16) = value / 1000 + '0';
:0X157  5020                    MOV             HRAM_0X20,      A
:0X158  e010                    ADDI            0X10
:0X159  e625                    MOVA            HRAM_0X25
:0X15a  5021                    MOV             HRAM_0X21,      A
:0X15b  c300                    ADDCI           0X0
:0X15c  e626                    MOVA            HRAM_0X26
:0X15d  e503                    MOVI            0X3
:0X15e  2003                    MOVAR           ?_TMP+3                             ;?_TMP+3: Bank 0    Addr: 3     
:0X15f  e5e8                    MOVI            0XE8
:0X160  2002                    MOVAR           ?_TMP+2                             ;?_TMP+2: Bank 0    Addr: 2     
:0X161  5024                    MOV             HRAM_0X24,      A
:0X162  2001                    MOVAR           ?_TMP+1                             ;?_TMP+1: Bank 0    Addr: 1     
:0X163  5023                    MOV             HRAM_0X23,      A
:0X164  2000                    MOVAR           ?_TMP                               ;?_TMP: Bank 0    Addr: 0     
:0X165  ec03                    PAGE            (WDIV)>>11
:0X166  ea00                    SECTION         0X0
:0X167  6000                    CALL            HADR_0X0
:0X168  ec00                    PAGE            (_0)>>11
:0X169  5004                    MOV             (?_TMP+4)&7f,   A                   ;(?_TMP+4)&7f: Bank 0    Addr: 4     
:0X16a  20a2                    MOVAR           HRAM_0XA2
:0X16b  78a6                    MOVRA           HRAM_0XA6
:0X16c  e682                    MOVA            HRAM_0X82
:0X16d  78a5                    MOVRA           HRAM_0XA5
:0X16e  e681                    MOVA            HRAM_0X81
:0X16f  78a2                    MOVRA           HRAM_0XA2
:0X170  e030                    ADDI            0X30
:0X171  e680                    MOVA            HRAM_0X80
:0X172  c201                    ISTEP           0X1
;    *(str + 17) = value % 1000 / 100 + '0';
:0X173  78a0                    MOVRA           HRAM_0XA0
:0X174  e011                    ADDI            0X11
:0X175  20a5                    MOVAR           HRAM_0XA5
:0X176  78a1                    MOVRA           HRAM_0XA1
:0X177  c300                    ADDCI           0X0
:0X178  20a6                    MOVAR           HRAM_0XA6
:0X179  e503                    MOVI            0X3
:0X17a  e603                    MOVA            (?_TMP+3)&7f                        ;(?_TMP+3)&7f: Bank 0    Addr: 3     
:0X17b  e5e8                    MOVI            0XE8
:0X17c  e602                    MOVA            (?_TMP+2)&7f                        ;(?_TMP+2)&7f: Bank 0    Addr: 2     
:0X17d  78a4                    MOVRA           HRAM_0XA4
:0X17e  e601                    MOVA            (?_TMP+1)&7f                        ;(?_TMP+1)&7f: Bank 0    Addr: 1     
:0X17f  78a3                    MOVRA           HRAM_0XA3
:0X180  e600                    MOVA            (?_TMP)&7f                          ;(?_TMP)&7f: Bank 0    Addr: 0     
:0X181  ec03                    PAGE            (WMOD)>>11
:0X182  6000                    CALL            HADR_0X0
:0X183  ec00                    PAGE            (_1)>>11
:0X184  5000                    MOV             (?_TMP)&7f,     A                   ;(?_TMP)&7f: Bank 0    Addr: 0     
:0X185  20a7                    MOVAR           HRAM_0XA7
:0X186  5001                    MOV             (?_TMP+1)&7f,   A                   ;(?_TMP+1)&7f: Bank 0    Addr: 1     
:0X187  20a8                    MOVAR           HRAM_0XA8
:0X188  e500                    MOVI            0X0
:0X189  e603                    MOVA            (?_TMP+3)&7f                        ;(?_TMP+3)&7f: Bank 0    Addr: 3     
:0X18a  e564                    MOVI            0X64
:0X18b  e602                    MOVA            (?_TMP+2)&7f                        ;(?_TMP+2)&7f: Bank 0    Addr: 2     
:0X18c  78a8                    MOVRA           HRAM_0XA8
:0X18d  e601                    MOVA            (?_TMP+1)&7f                        ;(?_TMP+1)&7f: Bank 0    Addr: 1     
:0X18e  78a7                    MOVRA           HRAM_0XA7
:0X18f  e600                    MOVA            (?_TMP)&7f                          ;(?_TMP)&7f: Bank 0    Addr: 0     
:0X190  ec03                    PAGE            (WDIV)>>11
:0X191  6000                    CALL            HADR_0X0
:0X192  ec00                    PAGE            (_2)>>11
:0X193  5004                    MOV             (?_TMP+4)&7f,   A                   ;(?_TMP+4)&7f: Bank 0    Addr: 4     
:0X194  20a2                    MOVAR           HRAM_0XA2
:0X195  78a6                    MOVRA           HRAM_0XA6
:0X196  e682                    MOVA            HRAM_0X82
:0X197  78a5                    MOVRA           HRAM_0XA5
:0X198  e681                    MOVA            HRAM_0X81
:0X199  78a2                    MOVRA           HRAM_0XA2
:0X19a  e030                    ADDI            0X30
:0X19b  e680                    MOVA            HRAM_0X80
:0X19c  c201                    ISTEP           0X1
;    *(str + 18) = value % 100 / 10 + '0';
:0X19d  78a0                    MOVRA           HRAM_0XA0
:0X19e  e012                    ADDI            0X12
:0X19f  20a5                    MOVAR           HRAM_0XA5
:0X1a0  78a1                    MOVRA           HRAM_0XA1
:0X1a1  c300                    ADDCI           0X0
:0X1a2  20a6                    MOVAR           HRAM_0XA6
:0X1a3  e500                    MOVI            0X0
:0X1a4  e603                    MOVA            (?_TMP+3)&7f                        ;(?_TMP+3)&7f: Bank 0    Addr: 3     
:0X1a5  e564                    MOVI            0X64
:0X1a6  e602                    MOVA            (?_TMP+2)&7f                        ;(?_TMP+2)&7f: Bank 0    Addr: 2     
:0X1a7  78a4                    MOVRA           HRAM_0XA4
:0X1a8  e601                    MOVA            (?_TMP+1)&7f                        ;(?_TMP+1)&7f: Bank 0    Addr: 1     
:0X1a9  78a3                    MOVRA           HRAM_0XA3
:0X1aa  e600                    MOVA            (?_TMP)&7f                          ;(?_TMP)&7f: Bank 0    Addr: 0     
:0X1ab  ec03                    PAGE            (WMOD)>>11
:0X1ac  6000                    CALL            HADR_0X0
:0X1ad  ec00                    PAGE            (_3)>>11
:0X1ae  5000                    MOV             (?_TMP)&7f,     A                   ;(?_TMP)&7f: Bank 0    Addr: 0     
:0X1af  20a7                    MOVAR           HRAM_0XA7
:0X1b0  5001                    MOV             (?_TMP+1)&7f,   A                   ;(?_TMP+1)&7f: Bank 0    Addr: 1     
:0X1b1  20a8                    MOVAR           HRAM_0XA8
:0X1b2  e500                    MOVI            0X0
:0X1b3  e603                    MOVA            (?_TMP+3)&7f                        ;(?_TMP+3)&7f: Bank 0    Addr: 3     
:0X1b4  e50a                    MOVI            0XA
:0X1b5  e602                    MOVA            (?_TMP+2)&7f                        ;(?_TMP+2)&7f: Bank 0    Addr: 2     
:0X1b6  78a8                    MOVRA           HRAM_0XA8
:0X1b7  e601                    MOVA            (?_TMP+1)&7f                        ;(?_TMP+1)&7f: Bank 0    Addr: 1     
:0X1b8  78a7                    MOVRA           HRAM_0XA7
:0X1b9  e600                    MOVA            (?_TMP)&7f                          ;(?_TMP)&7f: Bank 0    Addr: 0     
:0X1ba  ec03                    PAGE            (WDIV)>>11
:0X1bb  6000                    CALL            HADR_0X0
:0X1bc  ec00                    PAGE            (_4)>>11
:0X1bd  5004                    MOV             (?_TMP+4)&7f,   A                   ;(?_TMP+4)&7f: Bank 0    Addr: 4     
:0X1be  20a2                    MOVAR           HRAM_0XA2
:0X1bf  78a6                    MOVRA           HRAM_0XA6
:0X1c0  e682                    MOVA            HRAM_0X82
:0X1c1  78a5                    MOVRA           HRAM_0XA5
:0X1c2  e681                    MOVA            HRAM_0X81
:0X1c3  78a2                    MOVRA           HRAM_0XA2
:0X1c4  e030                    ADDI            0X30
:0X1c5  e680                    MOVA            HRAM_0X80
:0X1c6  c201                    ISTEP           0X1
;    *(str + 19) = value % 10 + '0';
:0X1c7  78a0                    MOVRA           HRAM_0XA0
:0X1c8  e013                    ADDI            0X13
:0X1c9  20a5                    MOVAR           HRAM_0XA5
:0X1ca  78a1                    MOVRA           HRAM_0XA1
:0X1cb  c300                    ADDCI           0X0
:0X1cc  20a6                    MOVAR           HRAM_0XA6
:0X1cd  e500                    MOVI            0X0
:0X1ce  e603                    MOVA            (?_TMP+3)&7f                        ;(?_TMP+3)&7f: Bank 0    Addr: 3     
:0X1cf  e50a                    MOVI            0XA
:0X1d0  e602                    MOVA            (?_TMP+2)&7f                        ;(?_TMP+2)&7f: Bank 0    Addr: 2     
:0X1d1  78a4                    MOVRA           HRAM_0XA4
:0X1d2  e601                    MOVA            (?_TMP+1)&7f                        ;(?_TMP+1)&7f: Bank 0    Addr: 1     
:0X1d3  78a3                    MOVRA           HRAM_0XA3
:0X1d4  e600                    MOVA            (?_TMP)&7f                          ;(?_TMP)&7f: Bank 0    Addr: 0     
:0X1d5  ec03                    PAGE            (WMOD)>>11
:0X1d6  6000                    CALL            HADR_0X0
:0X1d7  ec00                    PAGE            (_5)>>11
:0X1d8  5000                    MOV             (?_TMP)&7f,     A                   ;(?_TMP)&7f: Bank 0    Addr: 0     
:0X1d9  20a2                    MOVAR           HRAM_0XA2
:0X1da  78a6                    MOVRA           HRAM_0XA6
:0X1db  e682                    MOVA            HRAM_0X82
:0X1dc  78a5                    MOVRA           HRAM_0XA5
:0X1dd  e681                    MOVA            HRAM_0X81
:0X1de  78a2                    MOVRA           HRAM_0XA2
:0X1df  e030                    ADDI            0X30
:0X1e0  e680                    MOVA            HRAM_0X80
:0X1e1  c201                    ISTEP           0X1
HADR_0X1E2:
;
;    while (*str)
:0X1e2  ea01                    SECTION         0X1
:0X1e3  5021                    MOV             HRAM_0X21,      A
:0X1e4  e682                    MOVA            HRAM_0X82
:0X1e5  5020                    MOV             HRAM_0X20,      A
:0X1e6  e681                    MOVA            HRAM_0X81
:0X1e7  5080                    MOV             HRAM_0X80,      A
:0X1e8  2000                    MOVAR           ?_TMP                               ;?_TMP: Bank 0    Addr: 0     
:0X1e9  ea00                    SECTION         0X0
:0X1ea  5000                    MOV             (?_TMP)&7f,     A                   ;(?_TMP)&7f: Bank 0    Addr: 0     
:0X1eb  9a84                    JBC             HRAM_0X84,      2
:0X1ec  6a02                    GOTO            HADR_0X202
HADR_0X1ED:
;    {
;        while (!TRMT1);
:0X1ed  a483                    BSS             HRAM_0X83,      4
:0X1ee  91d7                    JBS             HRAM_0XD7,      1
:0X1ef  69ed                    GOTO            HADR_0X1ED
;
;        TX1B = *str++;
:0X1f0  ea01                    SECTION         0X1
:0X1f1  5021                    MOV             HRAM_0X21,      A
:0X1f2  e623                    MOVA            HRAM_0X23
:0X1f3  5020                    MOV             HRAM_0X20,      A
:0X1f4  e622                    MOVA            HRAM_0X22
:0X1f5  5023                    MOV             HRAM_0X23,      A
:0X1f6  e682                    MOVA            HRAM_0X82
:0X1f7  5022                    MOV             HRAM_0X22,      A
:0X1f8  e681                    MOVA            HRAM_0X81
:0X1f9  5080                    MOV             HRAM_0X80,      A
:0X1fa  2000                    MOVAR           ?_TMP                               ;?_TMP: Bank 0    Addr: 0     
:0X1fb  7800                    MOVRA           ?_TMP                               ;?_TMP: Bank 0    Addr: 0     
:0X1fc  e6d6                    MOVA            HRAM_0XD6
:0X1fd  5520                    INC             HRAM_0X20,      R
:0X1fe  9284                    JBS             HRAM_0X84,      2
:0X1ff  6a01                    GOTO            HADR_0X201
:0X200  5521                    INC             HRAM_0X21,      R
HADR_0X201:
;    }
:0X201  69e2                    GOTO            HADR_0X1E2
HADR_0X202:
;}
:0X202  ac83                    BCC             HRAM_0X83,      4
:0X203  c183                    RET
HADR_0X204:
;
;/**********************************************
;函数名：ADC_convert(void)
;描  述：ADC转换函数
;输入值：无
;输出值：无
;返回值：转换的12位结果
;**********************************************/
;uint ADC_convert(void)
;{
;    ADTRG = 1;      //启动AD转换
:0X204  e783                    CLR             HRAM_0X83
:0X205  a1fa                    BSS             HRAM_0XFA,      1
HADR_0X206:
;
;    while (ADTRG);
:0X206  99fa                    JBC             HRAM_0XFA,      1
:0X207  6a06                    GOTO            HADR_0X206
;
;    ADIF = 0;
:0X208  a89a                    BCC             (_ADIF_0)>>3,   0                   ;(_ADIF_0)>>3: Bank 511    Addr: 65434    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;
;    return (uint)ADCRH << 8 | ADCRL;
:0X209  ea01                    SECTION         0X1
:0X20a  e721                    CLR             HRAM_0X21
:0X20b  50f9                    MOV             HRAM_0XF9,      A
:0X20c  e620                    MOVA            HRAM_0X20
:0X20d  5020                    MOV             HRAM_0X20,      A
:0X20e  e623                    MOVA            HRAM_0X23
:0X20f  e722                    CLR             HRAM_0X22
:0X210  e721                    CLR             HRAM_0X21
:0X211  50f8                    MOV             HRAM_0XF8,      A
:0X212  e620                    MOVA            HRAM_0X20
:0X213  5020                    MOV             HRAM_0X20,      A
:0X214  5822                    IOR             HRAM_0X22,      A
:0X215  e624                    MOVA            HRAM_0X24
:0X216  5021                    MOV             HRAM_0X21,      A
:0X217  5823                    IOR             HRAM_0X23,      A
:0X218  e625                    MOVA            HRAM_0X25
:0X219  5024                    MOV             HRAM_0X24,      A
:0X21a  2000                    MOVAR           ?_TMP                               ;?_TMP: Bank 0    Addr: 0     
:0X21b  5025                    MOV             HRAM_0X25,      A
:0X21c  2001                    MOVAR           ?_TMP+1                             ;?_TMP+1: Bank 0    Addr: 1     
:0X21d  7800                    MOVRA           ?_TMP                               ;?_TMP: Bank 0    Addr: 0     
:0X21e  ea00                    SECTION         0X0
:0X21f  c183                    RET
HADR_0X220:
;}
;
;/*******************************************************
;函数名：uint GetOffset2048(void)
;描  述：获取参考电压为内部2.048V时offset值
;输入值：无
;输出值：无
;返回值：offset值
;*******************************************************/
;uint GetOffset2048(void)
;{
;    uint value_tmp = 0;
;    unsigned char gie_bk = GIE;     //备份GIE
;
;    CLRWDT();
;
;    while (GIE) GIE = 0;
;
;    DATARDEN = 1;
;
;    FRAH = 0x802F >> 8;
;    FRAL = 0x802F;
;    DATARDTRG = 1;
;
;    while (DATARDTRG) ;      //等待读完成
;
;    __Asm TBR;               //查表读指令
;    value_tmp = (ROMDH << 8) | ROMDL;
;
;    ROMCL = 0x00;            //退出IAP
;    GIE = gie_bk;            //恢复全局中断
;
;    return value_tmp;
;}
;
;/*******************************************************
;函数名：uint GetOffsetVDD(void)
;描  述：获取参考电压为VDD时offset值
;输入值：无
;输出值：无
;返回值：offset值
;*******************************************************/
;uint GetOffsetVDD(void)
;{
;    uint value_tmp = 0;
;    unsigned char gie_bk = GIE;     //备份GIE
:0X220  e783                    CLR             HRAM_0X83
:0X221  e500                    MOVI            0X0
:0X222  9f96                    JBC             HRAM_0X96,      7
:0X223  e501                    MOVI            0X1
:0X224  ea01                    SECTION         0X1
:0X225  e620                    MOVA            HRAM_0X20
:0X226  5020                    MOV             HRAM_0X20,      A
:0X227  e622                    MOVA            HRAM_0X22
;
;    CLRWDT();
:0X228  c18b                    CWDT
HADR_0X229:
;
;    while (GIE) GIE = 0;
:0X229  9796                    JBS             HRAM_0X96,      7
:0X22a  6a2d                    GOTO            HADR_0X22D
:0X22b  af96                    BCC             (_GIE_0)>>3,    7                   ;(_GIE_0)>>3: Bank 511    Addr: 65430    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
:0X22c  6a29                    GOTO            HADR_0X229
HADR_0X22D:
;
;    DATARDEN = 1;
:0X22d  a794                    BSS             (_DATARDEN_0)>>3,               7   ;(_DATARDEN_0)>>3: Bank 511    Addr: 65428    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;
;    FRAH = 0x8030 >> 8;
:0X22e  e580                    MOVI            0X80
:0X22f  e691                    MOVA            _FRAH_0                             ;_FRAH_0: Bank 511    Addr: 65425    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    FRAL = 0x8030;
:0X230  e530                    MOVI            0X30
:0X231  e690                    MOVA            _FRAL_0                             ;_FRAL_0: Bank 511    Addr: 65424    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    DATARDTRG = 1;
:0X232  a094                    BSS             (_DATARDTRG_0)>>3,              0   ;(_DATARDTRG_0)>>3: Bank 511    Addr: 65428    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
HADR_0X233:
;
;    while (DATARDTRG) ;      //等待读完成
:0X233  9894                    JBC             HRAM_0X94,      0
:0X234  6a33                    GOTO            HADR_0X233
;
;    __Asm TBR;               //查表读指令
:0X235  c184                    TBR
;    value_tmp = (ROMDH << 8) | ROMDL;
:0X236  e721                    CLR             HRAM_0X21
:0X237  5093                    MOV             _ROMDH_0,       A                   ;_ROMDH_0: Bank 511    Addr: 65427    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
:0X238  e620                    MOVA            HRAM_0X20
:0X239  5020                    MOV             HRAM_0X20,      A
:0X23a  e624                    MOVA            HRAM_0X24
:0X23b  e723                    CLR             HRAM_0X23
:0X23c  e726                    CLR             HRAM_0X26
:0X23d  5092                    MOV             _ROMDL_0,       A                   ;_ROMDL_0: Bank 511    Addr: 65426    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
:0X23e  e625                    MOVA            HRAM_0X25
:0X23f  5025                    MOV             HRAM_0X25,      A
:0X240  5823                    IOR             HRAM_0X23,      A
:0X241  e620                    MOVA            HRAM_0X20
:0X242  5026                    MOV             HRAM_0X26,      A
:0X243  5824                    IOR             HRAM_0X24,      A
:0X244  e621                    MOVA            HRAM_0X21
;
;    ROMCL = 0x00;            //退出IAP
:0X245  e794                    CLR             _ROMCL_0                            ;_ROMCL_0: Bank 511    Addr: 65428    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
;    GIE = gie_bk;            //恢复全局中断
:0X246  ea00                    SECTION         0X0
:0X247  a810                    BCC             ((_GetOffsetVDD_#T20773_15)>>3)&7f,             0   ;((_GetOffsetVDD_#T20773_15)>>3)&7f: Bank 0    Addr: 16    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
:0X248  ea01                    SECTION         0X1
:0X249  9022                    JBS             HRAM_0X22,      0
:0X24a  6a4d                    GOTO            HADR_0X24D
:0X24b  ea00                    SECTION         0X0
:0X24c  a010                    BSS             ((_GetOffsetVDD_#T20773_15)>>3)&7f,             0   ;((_GetOffsetVDD_#T20773_15)>>3)&7f: Bank 0    Addr: 16    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
HADR_0X24D:
:0X24d  ea00                    SECTION         0X0
:0X24e  9810                    JBC             HRAM_0X10,      0
:0X24f  6a52                    GOTO            HADR_0X252
:0X250  af96                    BCC             (_GIE_0)>>3,    7                   ;(_GIE_0)>>3: Bank 511    Addr: 65430    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
:0X251  6a53                    GOTO            HADR_0X253
HADR_0X252:
:0X252  a796                    BSS             (_GIE_0)>>3,    7                   ;(_GIE_0)>>3: Bank 511    Addr: 65430    C:\Lisq\Project\Git\AN135_Examples_ES7P169C_ES7P0693_ES7P0031\ADC\adc_offset\debug\adc_offset.obj 
HADR_0X253:
;
;    return value_tmp;
:0X253  ea01                    SECTION         0X1
:0X254  5020                    MOV             HRAM_0X20,      A
:0X255  2000                    MOVAR           ?_TMP                               ;?_TMP: Bank 0    Addr: 0     
:0X256  5021                    MOV             HRAM_0X21,      A
:0X257  2001                    MOVAR           ?_TMP+1                             ;?_TMP+1: Bank 0    Addr: 1     
:0X258  7800                    MOVRA           ?_TMP                               ;?_TMP: Bank 0    Addr: 0     
:0X259  ea00                    SECTION         0X0
:0X25a  c183                    RET
                                ORG             0X1800
:0X1800  e706                   CLR             ?_TMP+6                            ;?_TMP+6: Bank 0    Addr: 6     
:0X1801  e704                   CLR             ?_TMP+4                            ;?_TMP+4: Bank 0    Addr: 4     
:0X1802  e705                   CLR             ?_TMP+5                            ;?_TMP+5: Bank 0    Addr: 5     
:0X1803  5002                   MOV             ?_TMP+2,        A                  ;?_TMP+2: Bank 0    Addr: 2     
:0X1804  5803                   IOR             ?_TMP+3,        A                  ;?_TMP+3: Bank 0    Addr: 3     
:0X1805  9284                   JBS             HRAM_0X84,      2
:0X1806  680a                   GOTO            HADR_0XA
:0X1807  e700                   CLR             ?_TMP                              ;?_TMP: Bank 0    Addr: 0     
:0X1808  e701                   CLR             ?_TMP+1                            ;?_TMP+1: Bank 0    Addr: 1     
:0X1809  6835                   GOTO            HADR_0X35
:0X180a  e5c0                   MOVI            0XC0
:0X180b  5b06                   AND             ?_TMP+6,        R                  ;?_TMP+6: Bank 0    Addr: 6     
:0X180c  a884                   BCC             HRAM_0X84,      0
:0X180d  5506                   INC             ?_TMP+6,        R                  ;?_TMP+6: Bank 0    Addr: 6     
:0X180e  b102                   RLB             ?_TMP+2,        R,              0X1        ;?_TMP+2: Bank 0    Addr: 2     
:0X180f  b103                   RLB             ?_TMP+3,        R,              0X1        ;?_TMP+3: Bank 0    Addr: 3     
:0X1810  9084                   JBS             HRAM_0X84,      0
:0X1811  680d                   GOTO            HADR_0XD
:0X1812  d103                   RRB             ?_TMP+3,        R,              0X1        ;?_TMP+3: Bank 0    Addr: 3     
:0X1813  d102                   RRB             ?_TMP+2,        R,              0X1        ;?_TMP+2: Bank 0    Addr: 2     
:0X1814  5003                   MOV             ?_TMP+3,        A                  ;?_TMP+3: Bank 0    Addr: 3     
:0X1815  ee01                   SUB             ?_TMP+1,        A                  ;?_TMP+1: Bank 0    Addr: 1     
:0X1816  9284                   JBS             HRAM_0X84,      2
:0X1817  681a                   GOTO            HADR_0X1A
:0X1818  5002                   MOV             ?_TMP+2,        A                  ;?_TMP+2: Bank 0    Addr: 2     
:0X1819  ee00                   SUB             ?_TMP,          A                  ;?_TMP: Bank 0    Addr: 0     
:0X181a  9084                   JBS             HRAM_0X84,      0
:0X181b  6821                   GOTO            HADR_0X21
:0X181c  5002                   MOV             ?_TMP+2,        A                  ;?_TMP+2: Bank 0    Addr: 2     
:0X181d  ef00                   SUB             ?_TMP,          R                  ;?_TMP: Bank 0    Addr: 0     
:0X181e  5003                   MOV             ?_TMP+3,        A                  ;?_TMP+3: Bank 0    Addr: 3     
:0X181f  1701                   SUBC            ?_TMP+1,        R                  ;?_TMP+1: Bank 0    Addr: 1     
:0X1820  a084                   BSS             HRAM_0X84,      0
:0X1821  b104                   RLB             ?_TMP+4,        R,              0X1        ;?_TMP+4: Bank 0    Addr: 4     
:0X1822  b105                   RLB             ?_TMP+5,        R,              0X1        ;?_TMP+5: Bank 0    Addr: 5     
:0X1823  1106                   DEC             ?_TMP+6,        R                  ;?_TMP+6: Bank 0    Addr: 6     
:0X1824  5006                   MOV             ?_TMP+6,        A                  ;?_TMP+6: Bank 0    Addr: 6     
:0X1825  e23f                   ANDI            0X3F
:0X1826  a884                   BCC             HRAM_0X84,      0
:0X1827  9284                   JBS             HRAM_0X84,      2
:0X1828  6812                   GOTO            HADR_0X12
:0X1829  9706                   JBS             HRAM_0X6,       7
:0X182a  682f                   GOTO            HADR_0X2F
:0X182b  e904                   NEG             ?_TMP+4                            ;?_TMP+4: Bank 0    Addr: 4     
:0X182c  9a84                   JBC             HRAM_0X84,      2
:0X182d  1105                   DEC             ?_TMP+5,        R                  ;?_TMP+5: Bank 0    Addr: 5     
:0X182e  5305                   COM             ?_TMP+5,        R                  ;?_TMP+5: Bank 0    Addr: 5     
:0X182f  9606                   JBS             HRAM_0X6,       6
:0X1830  6835                   GOTO            HADR_0X35
:0X1831  e900                   NEG             ?_TMP                              ;?_TMP: Bank 0    Addr: 0     
:0X1832  9a84                   JBC             HRAM_0X84,      2
:0X1833  1101                   DEC             ?_TMP+1,        R                  ;?_TMP+1: Bank 0    Addr: 1     
:0X1834  5301                   COM             ?_TMP+1,        R                  ;?_TMP+1: Bank 0    Addr: 1     
:0X1835  5004                   MOV             ?_TMP+4,        A                  ;?_TMP+4: Bank 0    Addr: 4     
:0X1836  c183                   RET

                                END
