C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:11: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>                             // for _nop_();
   6          #include "REG_MA82G5Dxx.H"
   7          #include "Delay.h"
   8          
   9          uCHAR tmp;
  10          
  11          #define nCS                                             P11
  12          xdata uCHAR TestBuf[128];
  13          
  14          void Initial_SPI(void)
  15          {
  16   1              SPCON = ( SPEN | SSIG | MSTR | CPHA | SPR0);            //enable SPI and set sampling data at falling edge, SPICLK 
             -is sysclk / 8.
  17   1              P1M0 = P1M0|(P1M01|P1M05|P1M07);                                        //set P11, P15, P17 to push-pull
  18   1              P1M1 = P1M1 & (~(P1M01|P1M05|P1M07));
  19   1      
  20   1              P1M0 = P1M0|P1M06;                                                                      //set P16 to open-drain with pull high
  21   1              P1M1 = P1M1|P1M16;
  22   1      }
  23          
  24          void SPI_Wr_Single(uCHAR Var)                                                   //Write 1 Byte only.
  25          {
  26   1              SPDAT = Var;
  27   1              while(!(SPSTAT & SPIF));
  28   1              SPSTAT |= SPIF;
  29   1      }
  30          
  31          uCHAR SPI_RD_Single(void)                                                               //Read 1 Byte only.
  32          {
  33   1              uCHAR Var;
  34   1      
  35   1              SPDAT = 0xFF;
  36   1              while(!(SPSTAT & SPIF));
  37   1              SPSTAT |= SPIF;
  38   1              Var = SPSTAT;
  39   1              
  40   1              return Var;
  41   1      }
  42          
  43          void SPI_Wr(uCHAR Addr, uCHAR Dta)
  44          {
  45   1              nCS = 0;
  46   1              SPI_Wr_Single(Addr);
  47   1              delay_5us();
  48   1              SPI_Wr_Single(Dta);
  49   1              nCS = 1;
  50   1              
  51   1      }
  52          
  53          uCHAR SPI_Rd(uCHAR Addr)
  54          {
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:11:12 PAGE 2   

  55   1              uCHAR Dta;
  56   1      
  57   1              nCS = 0;
  58   1              SPI_Wr_Single(Addr);
  59   1              delay_5us();
  60   1              Dta = SPI_RD_Single();
  61   1              nCS = 1;
  62   1              
  63   1              Dta = SPDAT;
  64   1              return Dta;
  65   1      }
  66          
  67          void main(void)
  68          {
  69   1              uCHAR i;
  70   1              Initial_SPI();
  71   1      
  72   1              while(1)
  73   1              {
  74   2                      P35=!P35;
  75   2                      for(i=0;i<128;i++)
  76   2                      {
  77   3                              SPI_Wr(i&0x7F, 0xAA);
  78   3                      }       
  79   2                      for(i=0;i<128;i++)
  80   2                      {
  81   3                              TestBuf[i]=SPI_Rd(i|0x80);
  82   3                      }       
  83   2              
  84   2              }
  85   1      }
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:11:12 PAGE 3   

ASSEMBLY LISTING OF GENERATED OBJECT CODE


             ; FUNCTION Initial_SPI (BEGIN)
                                           ; SOURCE LINE # 14
                                           ; SOURCE LINE # 15
                                           ; SOURCE LINE # 16
0000 7585D5            MOV     SPCON,#0D5H
                                           ; SOURCE LINE # 17
0003 4391A2            ORL     P1M0,#0A2H
                                           ; SOURCE LINE # 18
0006 53925D            ANL     P1M1,#05DH
                                           ; SOURCE LINE # 20
0009 439140            ORL     P1M0,#040H
                                           ; SOURCE LINE # 21
000C 439240            ORL     P1M1,#040H
                                           ; SOURCE LINE # 22
000F 22                RET     
             ; FUNCTION Initial_SPI (END)

             ; FUNCTION _SPI_Wr_Single (BEGIN)
                                           ; SOURCE LINE # 24
;---- Variable 'Var' assigned to Register 'R7' ----
                                           ; SOURCE LINE # 25
                                           ; SOURCE LINE # 26
0000 8F86              MOV     SPDAT,R7
0002         ?C0002:
                                           ; SOURCE LINE # 27
0002 E584              MOV     A,SPSTAT
0004 30E7FB            JNB     ACC.7,?C0002
0007         ?C0003:
                                           ; SOURCE LINE # 28
0007 438480            ORL     SPSTAT,#080H
                                           ; SOURCE LINE # 29
000A 22                RET     
             ; FUNCTION _SPI_Wr_Single (END)

             ; FUNCTION SPI_RD_Single (BEGIN)
                                           ; SOURCE LINE # 31
                                           ; SOURCE LINE # 32
                                           ; SOURCE LINE # 35
0000 7586FF            MOV     SPDAT,#0FFH
0003         ?C0005:
                                           ; SOURCE LINE # 36
0003 E584              MOV     A,SPSTAT
0005 30E7FB            JNB     ACC.7,?C0005
0008         ?C0006:
                                           ; SOURCE LINE # 37
0008 438480            ORL     SPSTAT,#080H
                                           ; SOURCE LINE # 38
;---- Variable 'Var' assigned to Register 'R7' ----
000B AF84              MOV     R7,SPSTAT
                                           ; SOURCE LINE # 40
                                           ; SOURCE LINE # 41
000D         ?C0007:
000D 22                RET     
             ; FUNCTION SPI_RD_Single (END)

             ; FUNCTION _SPI_Wr (BEGIN)
                                           ; SOURCE LINE # 43
0000 8D00        R     MOV     Dta,R5
;---- Variable 'Addr' assigned to Register 'R7' ----
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:11:12 PAGE 4   

                                           ; SOURCE LINE # 44
                                           ; SOURCE LINE # 45
0002 C291              CLR     P11
                                           ; SOURCE LINE # 46
0004 120000      R     LCALL   _SPI_Wr_Single
                                           ; SOURCE LINE # 47
0007 120000      E     LCALL   delay_5us
                                           ; SOURCE LINE # 48
000A AF00        R     MOV     R7,Dta
000C 120000      R     LCALL   _SPI_Wr_Single
                                           ; SOURCE LINE # 49
000F D291              SETB    P11
                                           ; SOURCE LINE # 51
0011 22                RET     
             ; FUNCTION _SPI_Wr (END)

             ; FUNCTION _SPI_Rd (BEGIN)
                                           ; SOURCE LINE # 53
;---- Variable 'Addr' assigned to Register 'R7' ----
                                           ; SOURCE LINE # 54
                                           ; SOURCE LINE # 57
0000 C291              CLR     P11
                                           ; SOURCE LINE # 58
0002 120000      R     LCALL   _SPI_Wr_Single
                                           ; SOURCE LINE # 59
0005 120000      E     LCALL   delay_5us
                                           ; SOURCE LINE # 60
0008 120000      R     LCALL   SPI_RD_Single
;---- Variable 'Dta' assigned to Register 'R7' ----
                                           ; SOURCE LINE # 61
000B D291              SETB    P11
                                           ; SOURCE LINE # 63
000D AF86              MOV     R7,SPDAT
                                           ; SOURCE LINE # 64
                                           ; SOURCE LINE # 65
000F         ?C0009:
000F 22                RET     
             ; FUNCTION _SPI_Rd (END)

             ; FUNCTION main (BEGIN)
                                           ; SOURCE LINE # 67
                                           ; SOURCE LINE # 68
                                           ; SOURCE LINE # 70
0000 120000      R     LCALL   Initial_SPI
0003         ?C0010:
                                           ; SOURCE LINE # 72
                                           ; SOURCE LINE # 73
                                           ; SOURCE LINE # 74
0003 B2B5              CPL     P35
                                           ; SOURCE LINE # 75
0005 E4                CLR     A
0006 F500        R     MOV     i,A
0008         ?C0012:
                                           ; SOURCE LINE # 76
                                           ; SOURCE LINE # 77
0008 E500        R     MOV     A,i
000A 547F              ANL     A,#07FH
000C FF                MOV     R7,A
000D 7DAA              MOV     R5,#0AAH
000F 120000      R     LCALL   _SPI_Wr
                                           ; SOURCE LINE # 78
0012 0500        R     INC     i
C51 COMPILER V8.02   MAIN                                                                  01/09/2018 11:11:12 PAGE 5   

0014 E500        R     MOV     A,i
0016 C3                CLR     C
0017 9480              SUBB    A,#080H
0019 40ED              JC      ?C0012
001B         ?C0013:
                                           ; SOURCE LINE # 79
001B E4                CLR     A
001C F500        R     MOV     i,A
001E         ?C0015:
001E E500        R     MOV     A,i
0020 C3                CLR     C
0021 9480              SUBB    A,#080H
0023 50DE              JNC     ?C0010
                                           ; SOURCE LINE # 80
                                           ; SOURCE LINE # 81
0025 E500        R     MOV     A,i
0027 4480              ORL     A,#080H
0029 FF                MOV     R7,A
002A 120000      R     LCALL   _SPI_Rd
002D 7400        R     MOV     A,#LOW TestBuf
002F 2500        R     ADD     A,i
0031 F582              MOV     DPL,A
0033 E4                CLR     A
0034 3400        R     ADDC    A,#HIGH TestBuf
0036 F583              MOV     DPH,A
0038 EF                MOV     A,R7
0039 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 82
003A 0500        R     INC     i
003C 80E0              SJMP    ?C0015
             ; FUNCTION main (END)



MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    137    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =    128    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      1       2
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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