📄 fet140_spi0_016x.s43
字号:
#include "msp430x14x.h"
;******************************************************************************
; MSP-FET430P140 Demo - USART0 SPI Interface to HC165/164 Shift Registers
;
; Description: Demonstrate USART0 in two-way SPI mode. Data are read from
; an HC165, and same data written back to the HC164.
; ACLK = n/a MCLK = SMCLK = UCLK0 = DCOCLK = default value
; //**SWRST** please see MSP430x1xx Users Guide for description //
; //*USART0 control bits are in different SFR's from other MSP430's//
;
; MSP430F149
; -----------------
; /|\| XIN|-
; | | | ^ HC164
; HC165 --|RST XOUT|- | -------------
; ---------- | | |-|/CLR,B | 8
; 8 | /LD|<---|P3.0 SIMO0/P3.1|------>|A Qx|--\->
; -\->|A-H CLK|<---|P3.3/UCLK0 - P3.3|------>|CLK |
; |-|INH QH|--->|P3.2/SOMI0 | | |
; |-|SER | | | | |
; - | | | | | |
;
; M.Buccini
; Texas Instruments, Inc
; January 2002
;******************************************************************************
;------------------------------------------------------------------------------
ORG 01100h ; Program Start
;------------------------------------------------------------------------------
RESET mov.w #0A00h,SP ; Initialize '449 stackpointer
call #Init_Sys ; Initialize system
;
Mainloop call #RXTX_HC16x ; Exchange data
; Software delay
Delay push.w #0 ;
D1 dec.w 0(SP) ;
jnz D1 ;
incd.w SP ;
jmp Mainloop ; Repeat
;
;------------------------------------------------------------------------------
Init_Sys; Subroutine to Initialize MSP430F44x Peripherials
;------------------------------------------------------------------------------
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer
SetupP3 bis.b #0Eh,&P3SEL ; P3.1-3 SPI option select
bis.b #01h,&P3DIR ; P3.0 output direction
SetupSPI bis.b #USPIE0,&ME1 ; Enable USART0 SPI mode
mov.b #CKPH+SSEL1+SSEL0+STC,&UTCTL0 ; SMCLK, 3-pin mode
mov.b #CHAR+SYNC+MM,&UCTL0 ; 8-bit SPI Master **SWRST**
mov.b #02h,&UBR00 ; SMCLK/2 for baud rate
clr.b &UBR10 ;
clr.b &UMCTL0 ; Clear modulation
ret ; Return from subroutine
;
;------------------------------------------------------------------------------
RXTX_HC16x; HC165--> URXBUF0 UTXBUF0 --> HC164
;------------------------------------------------------------------------------
TX0 bit.b #UTXIFG0,&IFG1 ; USART0 TX buffer ready?
jz TX0 ; Jump --> TX buffer not ready
bic.b #01h,&P3OUT ; Latch data into 'HC165
bis.b #01h,&P3OUT ;
mov.b &RXBUF0,&TXBUF0 ; Previous data to TX, RX next
ret ; Return from subroutine
;
;------------------------------------------------------------------------------
; Interrupt Vectors Used MSP430x13x/14x
;------------------------------------------------------------------------------
ORG 0FFFEh ; MSP430 RESET Vector
DW RESET ;
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -