?? fet140_spi0_0549.s43
字號:
#include "msp430x14x.h"
;******************************************************************************
; MSP-FET430P140 Demo - USART0 SPI Interface to TLC549 8-bit ADC
;
; Description: This program demonstrate a USART0 in SPI mode interface to a
; TLC549 8-bit ADC. The TLC is read, with the conversion code save in R15.
; //** VCC must be at least 3v for TLC549 **//
; //**SWRST** please see MSP430x1xx Users Guide for description //
;
; MSP430F149
; -----------------
; /|\| XIN|-
; TLC549 | | |
; ------------- --|RST XOUT|-
; | CS|<---|P3.0 |
; | DATAOUT|--->|P3.2/SOMI |
; ~>| IN+ I/O CLK|<---|P3.3/UCLK0 |
;
; M.Buccini
; Texas Instruments, Inc
; January 2002
;******************************************************************************
;------------------------------------------------------------------------------
ORG 01100h ; Progam Start
;------------------------------------------------------------------------------
RESET mov.w #0A00h,SP ; Initialize 'F149 stackpointer
call #Init_Sys ; Initialize system
;
Mainloop ;
Read_549 bic.b #01h,&P3OUT ; Enable TLC549
mov.b #00h,&TXBUF0 ; Dummy write to start SPI
L1 bit.b #URXIFG0,&IFG1 ; RXBUF ready?
jnc L1 ; 1 = ready
bis.b #01,&P3OUT ; Disable TLC549
;
mov.b &RXBUF0,R15 ; Data in R15
jmp Mainloop ; Repeat
;
;-----------------------------------------------------------------------------
Init_Sys; Subroutine to Initialize MSP430F149 Peripherials
;-----------------------------------------------------------------------------
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer
SetupP3 bis.b #0Ch,&P3SEL ; P3.2,3 SPI option select
bis.b #09h,&P3DIR ; P3.3,0 output direction
SetupSPI bis.b #040h,&ME1 ; Enable USART0 SPI
bis.b #CKPH+SSEL1+SSEL0+STC,&UTCTL0 ; SMCLK, 3-pin, clock inv.
mov.b #CHAR+SYNC+MM,&UCTL0 ; 8-bit SPI Master **SWRST**
mov.b #02h,&UBR00 ; SMCLK/2 for baud rate
clr.b &UBR10 ; SMCLK/2 for baud rate
clr.b &UMCTL0 ; Clear modulation
ret ; Return from subroutine
;
;-----------------------------------------------------------------------------
; Interrupt Vectors Used MSP430x13x/14x
;-----------------------------------------------------------------------------
ORG 0FFFEh ; POR, ext. Reset, Watchdog, Flash
DW RESET ;
END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -