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

📄 ex3a.asm

📁 利用51系列芯片,通过汇编语言编写,实现无线的接收与解码.
💻 ASM
字号:
;= ex3a.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:
;
;  nRF9E5 Hello World program (19200 baud).
;
;  The functionality is the same as in ex3c.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 CKCON,       0x8E
           .equ EXIF,        0x91
           .equ P0_DIR,      0x94
           .equ P0_ALT,      0x95
           .equ SPI_DATA,    0xB2
           .equ SPI_CTRL,    0xB3
           .equ SPICLK,      0xB4

           ljmp  start

start:     acall init

           mov   dptr, #msg
           acall puts
loop:      ajmp  loop

puts:      mov   a, #0
           movc  a, @a+dptr
           jz    puts2
           acall putc
           inc   dptr
           ajmp  puts
puts2:     ret

putc:      jnb   TI, putc
           clr   TI
           mov   SBUF, A
           ret

init:      mov   TH1, #243       ; 19200@16MHz (when T1M=1 and SMOD=1)
           orl   CKCON, #0x10    ; T1M=1 (/4 timer clock)
           mov   PCON, #0x80     ; SMOD=1 (double baud rate)
           mov   SCON, #0x52     ; Serial mode1, enable receiver
           mov   TMOD, #0x20     ; Timer1 8bit auto reload
           setb  TR1             ; Start timer1
           orl   P0_ALT, #0x06   ; Select alternate function on P01 and P02
           orl   P0_DIR, #0x02   ; Configure P01 (RxD) as input

           mov   SPICLK, #0x00   ; Max SPI clock
           mov   SPI_CTRL, #0x02
           clr   P2.3            ; RACSN = 0
           mov   a, #0x19        ; RRC + 0x09
           acall spi_wr
           acall spi_rd
           orl   a, #0x04
           mov   r0, a
           setb  P2.3            ; RACSN = 1
           clr   P2.3            ; RACSN = 0
           mov   a, #0x09        ; WRC + 0x09
           acall spi_wr
           mov   a, r0
           acall spi_wr
           setb  P2.3            ; RACSN = 1
           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

msg:       .db   "Hello World!\n", 0

⌨️ 快捷键说明

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