C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:07:12 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE NOAREGS DEBUG OBJECTEXTEND CODE

line level    source

   1          
   2          #define         uCHAR   unsigned char
   3          #define         uINT    unsigned int
   4          
   5          #include <Intrins.h>
   6          #include "REG_MA82G5Dxx.H"
   7          #include "delay.H"
   8          
   9          
  10          union WTYPE
  11            { uCHAR B[2];
  12              uINT  W;
  13            };
  14          
  15          float ADC_Volt;
  16          float VDD_Volt;
  17          
  18          union WTYPE ADC_Value;
  19          union WTYPE ADC_Ch0_Value;
  20          union WTYPE ADC_Ch1_Value;
  21          union WTYPE ADC_Ch2_Value;
  22          
  23          void WriteP(uCHAR PsfrAddr,uCHAR PsfrData)
  24          {
  25   1                      bit bEA=EA;
  26   1                      EA = 0;                                         // 关中断
  27   1                      IFADRH = 0;                             // IFADRH必须为0
  28   1                      IFADRL= PsfrAddr;                       // 送P页地址;
  29   1                      IFD= PsfrData;                          // 送P页内容
  30   1                      IFMT = 4;                                       // 写P页
  31   1                      ISPCR = 0x80;                           // 允许ISP/IAP操作
  32   1                      SCMD = 0x46;
  33   1                      SCMD = 0xB9;
  34   1                      _nop_();
  35   1                      ISPCR = 0;                                      // 清ISP/IAP特殊寄存器
  36   1                      IFMT=0;
  37   1                      EA = bEA;                                       // 恢复中断
  38   1      }
  39          void Initial_ADC(void)
  40          {
  41   1              ADCON0 = (ADCEN | CHS3 | CHS2 | CHS1 | CHS0);           // ADC Channel select Int 1.4V
  42   1              ADCFG0 = (ADRJ | ADCKS1 | ADCKS0);                                      // SYSCLK / 8， ADRJ=1: ADCH(------B9B8),ADCL(B7B6B5B4B3B2B1B0)
  43   1              WriteP(PCON3_P,0x80);                                                           // Enable IVR 1.4V
  44   1              delay_ms(10);
  45   1      }
  46          
  47          void ADC_Start(void)
  48          {
  49   1              ADCON0 |= 0x08;                                                                         //start AD conversion
  50   1              while(!(ADCON0 & 0x10));                                                        //wait AD conversion finish
  51   1              ADCON0 &= 0xEF;                                                                         //Clear ADC interrupt flag
  52   1      
  53   1              ADC_Value.B[0] = ADCDH;                                                         //get ADC value
  54   1              ADC_Value.B[1] = ADCDL;
  55   1      }
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:07:12 PAGE 2   

  56          
  57          void main(void)
  58          {
  59   1      
  60   1              Initial_ADC();
  61   1      
  62   1      
  63   1              ADC_Start();
  64   1              ADC_Ch0_Value.W = ADC_Value.W;
  65   1      
  66   1              VDD_Volt = 1.4*1023 / ADC_Ch0_Value.W;                          // 使用通道 Int 1.4V的ADC值，计算出VDD的电压值
  67   1              ADC_Volt = VDD_Volt / 1023 * ADC_Value.W;
  68   1      
  69   1              while(1)
  70   1              {
  71   2                      _nop_();
  72   2              }
  73   1      }
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:07:12 PAGE 3   

ASSEMBLY LISTING OF GENERATED OBJECT CODE


             ; FUNCTION _WriteP (BEGIN)
                                           ; SOURCE LINE # 23
;---- Variable 'PsfrData' assigned to Register 'R5' ----
;---- Variable 'PsfrAddr' assigned to Register 'R7' ----
                                           ; SOURCE LINE # 24
                                           ; SOURCE LINE # 25
0000 A2AF              MOV     C,EA
0002 9200        R     MOV     bEA,C
                                           ; SOURCE LINE # 26
0004 C2AF              CLR     EA
                                           ; SOURCE LINE # 27
0006 E4                CLR     A
0007 F5E3              MOV     IFADRH,A
                                           ; SOURCE LINE # 28
0009 8FE4              MOV     IFADRL,R7
                                           ; SOURCE LINE # 29
000B 8DE2              MOV     IFD,R5
                                           ; SOURCE LINE # 30
000D 75E504            MOV     IFMT,#04H
                                           ; SOURCE LINE # 31
0010 75E780            MOV     ISPCR,#080H
                                           ; SOURCE LINE # 32
0013 75E646            MOV     SCMD,#046H
                                           ; SOURCE LINE # 33
0016 75E6B9            MOV     SCMD,#0B9H
                                           ; SOURCE LINE # 34
0019 00                NOP     
                                           ; SOURCE LINE # 35
001A F5E7              MOV     ISPCR,A
                                           ; SOURCE LINE # 36
001C F5E5              MOV     IFMT,A
                                           ; SOURCE LINE # 37
001E A200        R     MOV     C,bEA
0020 92AF              MOV     EA,C
                                           ; SOURCE LINE # 38
0022 22                RET     
             ; FUNCTION _WriteP (END)

             ; FUNCTION Initial_ADC (BEGIN)
                                           ; SOURCE LINE # 39
                                           ; SOURCE LINE # 40
                                           ; SOURCE LINE # 41
0000 75C4A7            MOV     ADCON0,#0A7H
                                           ; SOURCE LINE # 42
0003 75C370            MOV     ADCFG0,#070H
                                           ; SOURCE LINE # 43
0006 7D80              MOV     R5,#080H
0008 7F45              MOV     R7,#045H
000A 120000      R     LCALL   _WriteP
                                           ; SOURCE LINE # 44
000D 7F0A              MOV     R7,#0AH
000F 7E00              MOV     R6,#00H
0011 020000      E     LJMP    _delay_ms
             ; FUNCTION Initial_ADC (END)

             ; FUNCTION ADC_Start (BEGIN)
                                           ; SOURCE LINE # 47
                                           ; SOURCE LINE # 48
                                           ; SOURCE LINE # 49
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:07:12 PAGE 4   

0000 43C408            ORL     ADCON0,#08H
0003         ?C0003:
                                           ; SOURCE LINE # 50
0003 E5C4              MOV     A,ADCON0
0005 30E4FB            JNB     ACC.4,?C0003
0008         ?C0004:
                                           ; SOURCE LINE # 51
0008 53C4EF            ANL     ADCON0,#0EFH
                                           ; SOURCE LINE # 53
000B 85C600      R     MOV     ADC_Value,ADCDH
                                           ; SOURCE LINE # 54
000E 85C500      R     MOV     ADC_Value+01H,ADCDL
                                           ; SOURCE LINE # 55
0011 22                RET     
             ; FUNCTION ADC_Start (END)

             ; FUNCTION main (BEGIN)
                                           ; SOURCE LINE # 57
                                           ; SOURCE LINE # 58
                                           ; SOURCE LINE # 60
0000 120000      R     LCALL   Initial_ADC
                                           ; SOURCE LINE # 63
0003 120000      R     LCALL   ADC_Start
                                           ; SOURCE LINE # 64
0006 850000      R     MOV     ADC_Ch0_Value,ADC_Value
0009 850000      R     MOV     ADC_Ch0_Value+01H,ADC_Value+01H
                                           ; SOURCE LINE # 66
000C AC00        R     MOV     R4,ADC_Ch0_Value
000E AD00        R     MOV     R5,ADC_Ch0_Value+01H
0010 E4                CLR     A
0011 120000      E     LCALL   ?C?FCASTI
0014 C8                XCH     A,R0
0015 EC                MOV     A,R4
0016 C8                XCH     A,R0
0017 C9                XCH     A,R1
0018 ED                MOV     A,R5
0019 C9                XCH     A,R1
001A CA                XCH     A,R2
001B EE                MOV     A,R6
001C CA                XCH     A,R2
001D CB                XCH     A,R3
001E EF                MOV     A,R7
001F CB                XCH     A,R3
0020 7F66              MOV     R7,#066H
0022 7E06              MOV     R6,#06H
0024 7DB3              MOV     R5,#0B3H
0026 7C44              MOV     R4,#044H
0028 120000      E     LCALL   ?C?FPDIV
002B 8F00        R     MOV     VDD_Volt+03H,R7
002D 8E00        R     MOV     VDD_Volt+02H,R6
002F 8D00        R     MOV     VDD_Volt+01H,R5
0031 8C00        R     MOV     VDD_Volt,R4
                                           ; SOURCE LINE # 67
0033 7B00              MOV     R3,#00H
0035 7AC0              MOV     R2,#0C0H
0037 797F              MOV     R1,#07FH
0039 7844              MOV     R0,#044H
003B 120000      E     LCALL   ?C?FPDIV
003E EC                MOV     A,R4
003F C0E0              PUSH    ACC
0041 ED                MOV     A,R5
0042 C0E0              PUSH    ACC
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:07:12 PAGE 5   

0044 EE                MOV     A,R6
0045 C0E0              PUSH    ACC
0047 EF                MOV     A,R7
0048 C0E0              PUSH    ACC
004A AC00        R     MOV     R4,ADC_Value
004C AD00        R     MOV     R5,ADC_Value+01H
004E E4                CLR     A
004F 120000      E     LCALL   ?C?FCASTI
0052 D0E0              POP     ACC
0054 FB                MOV     R3,A
0055 D0E0              POP     ACC
0057 FA                MOV     R2,A
0058 D0E0              POP     ACC
005A F9                MOV     R1,A
005B D0E0              POP     ACC
005D F8                MOV     R0,A
005E 120000      E     LCALL   ?C?FPMUL
0061 8F00        R     MOV     ADC_Volt+03H,R7
0063 8E00        R     MOV     ADC_Volt+02H,R6
0065 8D00        R     MOV     ADC_Volt+01H,R5
0067 8C00        R     MOV     ADC_Volt,R4
0069         ?C0006:
                                           ; SOURCE LINE # 69
                                           ; SOURCE LINE # 70
                                           ; SOURCE LINE # 71
0069 00                NOP     
                                           ; SOURCE LINE # 72
006A 80FD              SJMP    ?C0006
             ; FUNCTION main (END)



MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    181    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     16    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----       1
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
