📄 ex2a-rx433.asm
字号:
;= ex2a-rx433.asm ==============================================================
;
; Copyright (C) 2004 Nordic Semiconductor
;
; This file is distributed in the hope that it will be useful, but WITHOUT
; WARRANTY OF ANY KIND.
;
; Author(s): Ole Saether
;
; DESCRIPTION:
;
; This example should be used together with ex2a-tx433.asm. One nRF9E5
; evaluation board (receiver) should be programmed with the hex-file generated
; from assembling this file and the other evaluation board (transmitter)
; programmed with the hex-file generated from assembling ex2a-tx433.asm.
;
; All switches on the DIP-swith S206 on the receiver must be set to the "on"
; position and all switches on the DIP-swith S205 on the transmitter must be
; set to the "on" position.
;
; When one of the switched SW1-SW4 on the transmitter is pressed the
; corresponding LED on the receiver is turned on.
;
; The functionality is the same as in ex2c-rx.c.
;
; ASSEMBLER:
;
; You need as31.exe to assemble this program. It can be downloaded from this
; web page: http://www.pjrc.com/tech/8051/
;
; $Revision: 2 $
;
;===============================================================================
.equ EXIF, 0x91
.equ P0_DIR, 0x94
.equ P0_ALT, 0x95
.equ P1_ALT, 0x97
.equ SPI_DATA, 0xb2
.equ SPI_CTRL, 0xb3
.equ SPICLK, 0xb4
ljmp start
start: acall init
clr P2.4 ; TXEN = 0
rxpacket: setb P2.5 ; TRX_CE = 1
waitdr: jnb P2.5, waitdr ; Wait for DR = 1
clr P2.3 ; RACSN = 0
mov a, #0x24 ; R_RX_PAYLOAD
acall spi_wr
mov a, #0
acall spi_rd
setb P2.3 ; RACSN = 1
clr P2.5 ; TRX_CE = 0
clr c
rrc a
mov P0, a
ajmp rxpacket
init: mov P0_ALT, #0x00
mov P0_DIR, #0x00
mov SPICLK, #0x00
mov SPI_CTRL, #0x02
clr P2.3 ; RACSN = 0
mov a, #0x03 ; Config address 3 (Rx payload)
acall spi_wr
mov a, #0x01 ; One byte Rx payload
acall spi_wr
mov a, #0x01 ; One byte Tx payload
acall spi_wr
setb P2.3 ; RACSN = 1
ret
delay400: mov r7, #130
delay401: djnz r7, delay401
ret
spi_rd:
spi_wr: anl EXIF, #0xdf ; Clear SPI interrupt
mov SPI_DATA, a ; Move byte to send into SPI_DATA
spi_rdwr1: mov a, EXIF ; Wait until...
jnb acc.5, spi_rdwr1; ...SPI_RX bit is set
mov a, SPI_DATA ; Move byte received into acc
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -