C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:10:06 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>                             // for _nop_();
   6          #include "REG_MA82G5Dxx.H"
   7          #include "delay.H"
   8          
   9          
  10          #define         EPCA            0x04
  11          #define         ECOMn           0x40
  12          #define         CAPPn           0x20
  13          #define         CAPNn           0x10
  14          #define         MATn            0x08
  15          #define         PWMn            0x02
  16          #define         ECCFn           0x01
  17          
  18          #define         CCF0            0x01
  19          
  20          #define         EPCA            0x04
  21          
  22          #define    ISP_ENABLE          0x80              // Set ISP Enable
  23          #define    ISP_DISABLE         0x00              // Set ISP Disable
  24          
  25          #define         MCU_12MHz                       0x01
  26          #define         MCU_24MHz                       0x02
  27          
  28          #define         MCU_Freq                        MCU_24MHz
  29          
  30          union WTYPE
  31            { uCHAR B[2];
  32              uINT W;
  33            };
  34          
  35          union WTYPE PCA_Cnt;
  36          uINT PCA_Interval;
  37          
  38          uCHAR PCA_Interrupt_Flag;
  39          
  40          
  41          void PageP_Write(uCHAR Addr, uCHAR Dta)
  42          {
  43   1              IFADRH = 0x00;
  44   1              IFADRL = Addr;
  45   1              IFD = Dta;
  46   1              IFMT = 0x04;                                                            //write
  47   1              ISPCR = ISP_ENABLE;
  48   1          SCMD = 0x46;
  49   1          SCMD = 0xB9;
  50   1          ISPCR = ISP_DISABLE;
  51   1      }
  52          
  53          uCHAR PageP_Read(uCHAR Addr)
  54          {
  55   1              uCHAR Dta;
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:10:06 PAGE 2   

  56   1      
  57   1              IFADRH = 0x00;
  58   1              IFADRL = Addr;
  59   1              IFMT = 0x05;                                                            //read
  60   1              ISPCR = ISP_ENABLE;
  61   1          SCMD = 0x46;
  62   1          SCMD = 0xB9;
  63   1          ISPCR = ISP_DISABLE;
  64   1      
  65   1              Dta = IFD;
  66   1              return Dta;
  67   1      }
  68          
  69          void INT_PCA(void)      interrupt       9       using   1
  70          {
  71   1              CL = 0x00;
  72   1              CH = 0x00;
  73   1              CCON &= ~CCF0;
  74   1              
  75   1              PCA_Cnt.B[0] = CCAP0H;
  76   1              PCA_Cnt.B[1] = CCAP0L;
  77   1              
  78   1              PCA_Interrupt_Flag = 1;
  79   1              
  80   1      
  81   1      }
  82          
  83          void Initial_PCA(void)
  84          {
  85   1      
  86   1              SFRPI=0;                                                                        // CEX0(P22) : Open-Drain With Pull High
  87   1              P2M0=P2M0|P2M02;
  88   1              SFRPI=1;
  89   1              P2M1=P2M1|P2M12;
  90   1              SFRPI=0;
  91   1      
  92   1              CCAPM0 = (CAPNn | ECCFn);                                       //falling edge capture
  93   1              CMOD = 0x0A;                                                            //CPS2 ~ CPS0 = 1, 0, 1. (SYSCLK)
  94   1              CCON = 0x40;                                                            //PCA run.
  95   1      
  96   1              EIE1 = EPCA;
  97   1      }
  98          
  99          void Initial_MCU_Sysclk(void)
 100          {
 101   1              uCHAR tmp;
 102   1      
 103   1              #if(MCU_Freq == MCU_24MHz)
 104   1              
 105   1                      CKCON0 |= ENCKM;
 106   1                      delay_ms(1);
 107   1                      tmp = PageP_Read(CKCON2_P);
 108   1                      tmp |= MCKS0;
 109   1                      PageP_Write(CKCON2_P, tmp);
 110   1              
 111   1              #endif
 112   1      
 113   1      }
 114          
 115          void main()
 116          {
 117   1              Initial_PCA();
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:10:06 PAGE 3   

 118   1              Initial_MCU_Sysclk();
 119   1              EA = 1;
 120   1      
 121   1              while(1){
 122   2                      if(PCA_Interrupt_Flag)
 123   2                      {
 124   3                              PCA_Interrupt_Flag = 0;
 125   3                              #if(MCU_Freq == MCU_12MHz)
                                      
                                              PCA_Interval = PCA_Cnt.W / 12;                          // PCA_Cnt.W / 12M * 1000000 = us.
                                      #elif(MCU_Freq == MCU_24MHz)
 129   3                              
 130   3                                      PCA_Interval = PCA_Cnt.W / 24;                          // PCA_Cnt.W / 12M * 1000000 = us.
 131   3                              #endif
 132   3                      }
 133   2                      
 134   2              }
 135   1      }
 136          
 137          
 138          
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:10:06 PAGE 4   

ASSEMBLY LISTING OF GENERATED OBJECT CODE


             ; FUNCTION _PageP_Write (BEGIN)
                                           ; SOURCE LINE # 41
;---- Variable 'Dta' assigned to Register 'R5' ----
;---- Variable 'Addr' assigned to Register 'R7' ----
                                           ; SOURCE LINE # 42
                                           ; SOURCE LINE # 43
0000 E4                CLR     A
0001 F5E3              MOV     IFADRH,A
                                           ; SOURCE LINE # 44
0003 8FE4              MOV     IFADRL,R7
                                           ; SOURCE LINE # 45
0005 8DE2              MOV     IFD,R5
                                           ; SOURCE LINE # 46
0007 75E504            MOV     IFMT,#04H
                                           ; SOURCE LINE # 47
000A 75E780            MOV     ISPCR,#080H
                                           ; SOURCE LINE # 48
000D 75E646            MOV     SCMD,#046H
                                           ; SOURCE LINE # 49
0010 75E6B9            MOV     SCMD,#0B9H
                                           ; SOURCE LINE # 50
0013 F5E7              MOV     ISPCR,A
                                           ; SOURCE LINE # 51
0015 22                RET     
             ; FUNCTION _PageP_Write (END)

             ; FUNCTION _PageP_Read (BEGIN)
                                           ; SOURCE LINE # 53
;---- Variable 'Addr' assigned to Register 'R7' ----
                                           ; SOURCE LINE # 54
                                           ; SOURCE LINE # 57
0000 E4                CLR     A
0001 F5E3              MOV     IFADRH,A
                                           ; SOURCE LINE # 58
0003 8FE4              MOV     IFADRL,R7
                                           ; SOURCE LINE # 59
0005 75E505            MOV     IFMT,#05H
                                           ; SOURCE LINE # 60
0008 75E780            MOV     ISPCR,#080H
                                           ; SOURCE LINE # 61
000B 75E646            MOV     SCMD,#046H
                                           ; SOURCE LINE # 62
000E 75E6B9            MOV     SCMD,#0B9H
                                           ; SOURCE LINE # 63
0011 F5E7              MOV     ISPCR,A
                                           ; SOURCE LINE # 65
;---- Variable 'Dta' assigned to Register 'R7' ----
0013 AFE2              MOV     R7,IFD
                                           ; SOURCE LINE # 66
                                           ; SOURCE LINE # 67
0015         ?C0002:
0015 22                RET     
             ; FUNCTION _PageP_Read (END)

             ; FUNCTION INT_PCA (BEGIN)
                                           ; SOURCE LINE # 69
                                           ; SOURCE LINE # 71
0000 75E900            MOV     CL,#00H
                                           ; SOURCE LINE # 72
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:10:06 PAGE 5   

0003 75F900            MOV     CH,#00H
                                           ; SOURCE LINE # 73
0006 53D8FE            ANL     CCON,#0FEH
                                           ; SOURCE LINE # 75
0009 85FA00      R     MOV     PCA_Cnt,CCAP0H
                                           ; SOURCE LINE # 76
000C 85EA00      R     MOV     PCA_Cnt+01H,CCAP0L
                                           ; SOURCE LINE # 78
000F 750001      R     MOV     PCA_Interrupt_Flag,#01H
                                           ; SOURCE LINE # 81
0012 32                RETI    
             ; FUNCTION INT_PCA (END)

             ; FUNCTION Initial_PCA (BEGIN)
                                           ; SOURCE LINE # 83
                                           ; SOURCE LINE # 84
                                           ; SOURCE LINE # 86
0000 E4                CLR     A
0001 F5AC              MOV     SFRPI,A
                                           ; SOURCE LINE # 87
0003 439504            ORL     P2M0,#04H
                                           ; SOURCE LINE # 88
0006 75AC01            MOV     SFRPI,#01H
                                           ; SOURCE LINE # 89
0009 439204            ORL     P2M1,#04H
                                           ; SOURCE LINE # 90
000C F5AC              MOV     SFRPI,A
                                           ; SOURCE LINE # 92
000E 75DA11            MOV     CCAPM0,#011H
                                           ; SOURCE LINE # 93
0011 75D90A            MOV     CMOD,#0AH
                                           ; SOURCE LINE # 94
0014 75D840            MOV     CCON,#040H
                                           ; SOURCE LINE # 96
0017 75AD04            MOV     EIE1,#04H
                                           ; SOURCE LINE # 97
001A 22                RET     
             ; FUNCTION Initial_PCA (END)

             ; FUNCTION Initial_MCU_Sysclk (BEGIN)
                                           ; SOURCE LINE # 99
                                           ; SOURCE LINE # 100
                                           ; SOURCE LINE # 105
0000 43C740            ORL     CKCON0,#040H
                                           ; SOURCE LINE # 106
0003 7F01              MOV     R7,#01H
0005 7E00              MOV     R6,#00H
0007 120000      E     LCALL   _delay_ms
                                           ; SOURCE LINE # 107
000A 7F40              MOV     R7,#040H
000C 120000      R     LCALL   _PageP_Read
;---- Variable 'tmp' assigned to Register 'R5' ----
000F CD                XCH     A,R5
0010 EF                MOV     A,R7
0011 CD                XCH     A,R5
                                           ; SOURCE LINE # 108
0012 CD                XCH     A,R5
0013 4404              ORL     A,#04H
0015 CD                XCH     A,R5
                                           ; SOURCE LINE # 109
0016 7F40              MOV     R7,#040H
0018 020000      R     LJMP    _PageP_Write
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:10:06 PAGE 6   

             ; FUNCTION Initial_MCU_Sysclk (END)

             ; FUNCTION main (BEGIN)
                                           ; SOURCE LINE # 115
                                           ; SOURCE LINE # 116
                                           ; SOURCE LINE # 117
0000 120000      R     LCALL   Initial_PCA
                                           ; SOURCE LINE # 118
0003 120000      R     LCALL   Initial_MCU_Sysclk
                                           ; SOURCE LINE # 119
0006 D2AF              SETB    EA
0008         ?C0006:
                                           ; SOURCE LINE # 121
                                           ; SOURCE LINE # 122
0008 E500        R     MOV     A,PCA_Interrupt_Flag
000A 60FC              JZ      ?C0006
                                           ; SOURCE LINE # 123
                                           ; SOURCE LINE # 124
000C E4                CLR     A
000D F500        R     MOV     PCA_Interrupt_Flag,A
                                           ; SOURCE LINE # 130
000F AE00        R     MOV     R6,PCA_Cnt
0011 AF00        R     MOV     R7,PCA_Cnt+01H
0013 FC                MOV     R4,A
0014 7D18              MOV     R5,#018H
0016 120000      E     LCALL   ?C?UIDIV
0019 8E00        R     MOV     PCA_Interval,R6
001B 8F00        R     MOV     PCA_Interval+01H,R7
                                           ; SOURCE LINE # 132
                                           ; SOURCE LINE # 134
001D 80E9              SJMP    ?C0006
             ; FUNCTION main (END)



MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    148    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      5    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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