📄 tx11to20.lst
字号:
TX11TO20 PAGE 1
1 ;====================================================================
2 ;
3 ; Author : ADI - Apps
4 ;
5 ; Date : October 2003
6 ;
7 ; File : tx11to20.asm
8 ;
9 ; Hardware : ADuC842/ADuC843
10 ;
11 ; Description : This slave program transmits the numbers 11-20 in
12 ; binary form continuously down the spi port after
13 ; receiving a clock signal.
14 ;
15 ; After the transmission of each byte the incoming
16 ; byte is saved in order at a internal RAM address
17 ; between #40h and #50h
18 ;
19 ; This program can be used with the master program
20 ; spimast.asm (which generates a clock signal for
21 ; the slave)
22
23 ; The Slave program tx11to20 should be started
24 ; after the master program (842mstr.asm) but within
25 ; the time delay of 5s in order that the slave
26 ; program is synchronised by the first outputted
27 ; clock of the master.
28 ;
29 ; The clock is inputted at sclock (pin 26)
30 ; The data is outputted at MISO (pin 14)
31 ; The data is inputted at sdata/MOSI (pin 27)
32 ;
33 ;====================================================================
34 ;
35 $MOD842 ;Use 8052 predefined Symbols
36
00B4 37 LED EQU P3.4
0000 38 FLAG BIT 00H
39
40
41 ;____________________________________________________________________
42 ; BEGINNING OF CODE
---- 43 CSEG
0000 44 ORG 0000H
45
0000 020060 46 JMP MAIN
47 ;____________________________________________________________________
48 ; SPI INTERRUPT ROUTINE
003B 49 ORG 003BH
003B C200 50 CLR FLAG ; Clear flag to leave loop
51
003D A7F7 52 MOV @R1, SPIDAT ; move input into memory
003F 09 53 INC R1 ; increment memory location so new
54 ; data is stored in new address
55
0040 B95002 56 CJNE R1, #50H, CONT ; reset memory location to 40h when
57 ; memory location reaches 50h saving
58 ; 16 bytes of data
TX11TO20 PAGE 2
0043 7940 59 MOV R1, #40H
0045 32 60 CONT: RETI
61
62
63 ;====================================================================
64
0060 65 ORG 0060H ; Start code at address above interrupts
66
67
68
0060 69 MAIN: ; Main program
70
0060 75F824 71 MOV SPICON,#24h ; Initialise SPICON to have
72 ; -Enable SPI serial port
73 ; -slave mode select
74 ; -CPOL=0, clk idling low
75 ; -CPHA=1
76 ; note: it is important to have CPHA in the master and the slave
77 ; program equal, otherwise uncertainty will exist, as the input
78 ; will be measued during its change of state, and not is at
79 ; its final value.
80
0063 75A901 81 MOV IEIP2, #01h ; Enable SPI interrupt
82
0066 780A 83 MOV R0, #0AH ; initialise R0 to 10 to start
84 ; transmission from 11
0068 7940 85 MOV R1, #40h ; initialise R1 to 40 to store the
86 ; input data from memory location 40
87
006A D2AF 88 SETB EA ; Enable interrupts
89
006C 90 TRNSMT:
006C 08 91 INC R0
006D 88F7 92 MOV SPIDAT, R0 ; transmit the current value on R0
006F D200 93 SETB FLAG ; set flag so that we wait here until
94 ; the spi interrupt routine clears
95 ; the FLAG
96
0071 2000FD 97 JB FLAG, $ ; stay here until flag is cleared
98 ; by interrupt
99
100 ; check if R0 is equal to 20. If so the number 20 has been
101 ; transmitted and we should reset R0 to 10 to start transmission
102 ; from 11 again.
0074 E8 103 MOV A, R0
0075 B414F4 104 CJNE A, #14H, TRNSMT ; if R0 is not 20, jump to TRNSMT
0078 780A 105 MOV R0, #0AH ; if R0=20 make R0=10 & jump to TRNSMT
007A 80F0 106 JMP TRNSMT
107
108 END
VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
TX11TO20 PAGE 3
CONT . . . . . . . . . . . . . . C ADDR 0045H
EA . . . . . . . . . . . . . . . B ADDR 00AFH PREDEFINED
FLAG . . . . . . . . . . . . . . B ADDR 0000H
IEIP2. . . . . . . . . . . . . . D ADDR 00A9H PREDEFINED
LED. . . . . . . . . . . . . . . NUMB 00B4H NOT USED
MAIN . . . . . . . . . . . . . . C ADDR 0060H
P3 . . . . . . . . . . . . . . . D ADDR 00B0H PREDEFINED
SPICON . . . . . . . . . . . . . D ADDR 00F8H PREDEFINED
SPIDAT . . . . . . . . . . . . . D ADDR 00F7H PREDEFINED
TRNSMT . . . . . . . . . . . . . C ADDR 006CH
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -