⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 812slave.lst

📁 aduc812的汇编例子
💻 LST
📖 第 1 页 / 共 2 页
字号:
812SLAVE                                                                                                      PAGE 1

                       1    ;********************************************************************
                       2    ;
                       3    ; Author        : ADI - Apps            www.analog.com/MicroConverter
                       4    ;
                       5    ; Date          : 7 March 2000
                       6    ;
                       7    ; File          : SPIslave.asm
                       8    ;
                       9    ; Hardware      : ADuC812
                      10    ;
                      11    ; Include File  : UARTIO.asm - serial I/O routines
                      12    ;
                      13    ; Description   : Demonstrates an example slave mode SPI interface.
                      14    ;                 Code is intended for use with companion code file
                      15    ;                 'SPImstr.asm' running on a second MicroConverter
                      16    ;                 chip.  Chips must have SCLK, MOSI, MISO, & GND pins
                      17    ;                 connected together, and P3.5 pin on master must
                      18    ;                 connect to SS pin on slave.
                      19    ;
                      20    ;                 If using the ADuC812 eval board, you can simply
                      21    ;                 connect the 10-pin J5 header (SPI/I2C) directly to
                      22    ;                 that of the master board.  However, on the slave
                      23    ;                 board you must also remove R6 & C6 to disconnect
                      24    ;                 an op amp output from the SS pin, and you must
                      25    ;                 ensure that LK5 is INSERTED.  To configure the
                      26    ;                 master board, refer to 'SPImstr.asm'.
                      27    ;
                      28    ;                 Once hardware is connected, download code to both
                      29    ;                 master & slave devices ('SPImstr' to the master,
                      30    ;                 'SPIslave' to the slave).  Reset the slave first,
                      31    ;                 and then the master.  The slave will sit with the
                      32    ;                 LED off until the master starts exchanging data
                      33    ;                 with it at which time its LED will start blinking
                      34    ;                 in sync (or 180皁ut of phase) with that of the
                      35    ;                 master.  When first launched, both master and slave
                      36    ;                 are transmitting zeros repeatedly on the SPI port.
                      37    ;                 Pressing the INT0 button on either master or slave
                      38    ;                 increments the value it is transmitting.  Received
                      39    ;                 SPI data is relayed out the UART and can be viewed
                      40    ;                 on any VT100 terminal or terminal emulator at
                      41    ;                 9600baud/8bits/noparity/1stopbit.  Characters sent
                      42    ;                 from the terminal to the MicroConverter will update
                      43    ;                 the value being transmitted by SPI.
                      44    ;
                      45    ;********************************************************************
                      46    
                      47    $MOD812         ; Use 8052 & ADuC812 predefined symbols
                      48    
  00B4                49    LED     EQU     P3.4            ; P3.4 drives red LED on eval board
                      50    
                      51    ;____________________________________________________________________
                      52                                       ; DEFINE VARIABLES IN INTERNAL RAM
----                  53    DSEG
0060                  54    ORG 0060h
0060                  55    INPUT:     DS   1               ; data byte received by SPI
0061                  56    OUTPUT:    DS   1               ; data byte to send by SPI
                      57    
                      58    ;____________________________________________________________________
812SLAVE                                                                                                      PAGE 2

                      59                                                      ; BEGINNING OF CODE
----                  60    CSEG
                      61    
0000                  62    ORG 0000h
0000 02004B           63            JMP     MAIN            ; jump to main program
                      64    
                      65    ;____________________________________________________________________
                      66                                                 ; INTERRUPT VECTOR SPACE
0003                  67    ORG 0003h ; (.................... INT0 ISR)
                      68    
0003 0561             69            INC     OUTPUT
0005 32               70            RETI
                      71    
003B                  72    ORG 003Bh ; (.................... SPI ISR)
                      73    
003B 85F760           74            MOV     INPUT,SPIDAT    ; get data just received by SPI
003E 8561F7           75            MOV     SPIDAT,OUTPUT   ; update next byte to transmit
0041 C3               76            CLR     C               ; clear C indicates transfer complete
0042 32               77            RETI
                      78    
                      79    ;====================================================================
                      80                                                           ; MAIN PROGRAM
004B                  81    ORG 004Bh
                      82    
004B                  83    MAIN:
                      84    
004B 758107           85            MOV     SP,#007h
                      86    
                      87    ; CONFIGURE UART...
                      88    
004E 759852           89            MOV     SCON,#52h       ; configure UART for 9600baud..
0051 758920           90            MOV     TMOD,#20h       ; ..assuming 11.0592MHz crystal
0054 758DFD           91            MOV     TH1,#-3
0057 D28E             92            SETB    TR1
                      93    
                      94    ; CONFIGURE SPI...
                      95    
0059 75F824           96            MOV     SPICON,#024h    ; configure SPI port for:
                      97                                    ;   CPHA=1, CPOL=0, slave
                      98    
                      99    ;==> NOTE:  it is important that CPHA and CPOL be the same for both
                     100    ;           the master and all slave devices.  otherwise, data will
                     101    ;           be transitioning at the same time as it's being latched.
                     102    
005C C295            103            CLR     P1.5            ; enable SS pin as input
005E 75A901          104            MOV     IE2,#1          ; enable SPI interrupt
                     105    
                     106    ; CONFIGURE INTERRUPT 0...
                     107    
0061 D288            108            SETB    IT0             ; INT0 edge triggered
0063 D2A8            109            SETB    EX0             ; enable INT0 interrupt
                     110    
                     111    ; ENABLE INTERRUPTS & ENTER MAIN LOOP...
                     112    
0065 756100          113            MOV     OUTPUT,#0       ; set initial value for output byte..
0068 75F700          114            MOV     SPIDAT,#0       ; ..including very fisrt output byte
006B D2AF            115            SETB    EA              ; enable inturrupts
                     116    
812SLAVE                                                                                                      PAGE 3

006D B2B4            117    LOOP:   CPL     LED             ; flash the LED on the eval board
006F D3              118            SETB    C
0070 40FE            119            JC      $               ; wait here to receive SPI transfer
0072 E560            120            MOV     A,INPUT         ; send value received by SPI..
0074 1200A7          121            CALL    SENDVAL         ; ..out the UART as 2 hex chars
0077 900122          122            MOV     DPTR,#SEPERATOR ; send line-feed & crdg-return..
007A 120087          123            CALL    SENDSTRING      ; ..out the UART
007D 3098ED          124            JNB     RI,LOOP         ; repeat (unless UART data received)
                     125    
                     126    ; WHEN UART DATA RECEIVED, MOVE DATA TO SPI OUTPUT...
                     127    
0080 859961          128            MOV     OUTPUT,SBUF     ; update OUTPUT byte to new value
0083 C298            129            CLR     RI              ; must clear RI
0085 80E6            130            JMP     LOOP            ; back to main loop
                     131    
                     132    ;____________________________________________________________________
                     133                                                ; SUBROUTINE INCLUDE FILE
                     134    
                =1   135    $INCLUDE(UARTIO.asm)
                =1   136    ;********************************************************************
                =1   137    ;
                =1   138    ; Author        : ADI - Apps            www.analog.com/MicroConverter
                =1   139    ;
                =1   140    ; Date          : 12 October 1999
                =1   141    ;
                =1   142    ; File          : UARTIO.hex
                =1   143    ;
                =1   144    ; Hardware      : any 8051 based microcontroller or MicroConverter
                =1   145    ;
                =1   146    ; Description   : standard UART I/O subroutines.  total size of this
                =1   147    ;                 code when assembled is 155 bytes.  routines for use
                =1   148    ;                 external to this file are:
                =1   149    ;
                =1   150    ;                 SENDSTRING - sends a string of characters
                =1   151    ;                 SENDCHAR   - sends a single character
                =1   152    ;                 SENDVAL    - sends a byte as 2 ASCII characters
                =1   153    ;                 HEX2ASCII  - converts from HEX to ASCII
                =1   154    ;                 ASCII2HEX  - converts from ASCII to HEX
                =1   155    ;                 GETCHAR    - gets a single character
                =1   156    ;                 GETVAL     - gets a byte as 2 ASCII characters
                =1   157    ;
                =1   158    ;********************************************************************
                =1   159    
                =1   160    ;____________________________________________________________________
                =1   161                                                             ; SENDSTRING
                =1   162    
0087            =1   163    SENDSTRING:     ; sends ASCII string to UART starting at location
                =1   164                    ; DPTR and ending with a null (0) value
                =1   165    
0087 C0E0       =1   166            PUSH    ACC
0089 C0F0       =1   167            PUSH    B
008B E4         =1   168            CLR     A
008C F5F0       =1   169            MOV     B,A
008E E5F0       =1   170    IO0010: MOV     A,B
0090 05F0       =1   171            INC     B
0092 93         =1   172            MOVC    A,@A+DPTR
0093 6005       =1   173            JZ      IO0020
0095 12009F     =1   174            CALL    SENDCHAR
812SLAVE                                                                                                      PAGE 4

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -