📄 fet140_uart07_09600.s43
字号:
;******************************************************************************
; MSP-FET430P140 Demo - USART0, Ultra-Low Pwr UART 9600 RX/TX, 32kHz ACLK
;
; Description: This program demonstrates a full-duplex 9600-baud UART using
; USART0 and a 32kHz crystal. The program will wait in LPM3, and receive
; a string1 into RAM starting at 200h, and echo back the complete string.
; ACLK = LFXT1 = UCLK0, MCLK = SMCLK = default DCO ~ 800KHz
; Baud rate divider with 32768hz XTAL @9600 = 32768Hz/9600 = 3.41 (0003h 4Ah )
; //* An external watch crystal is required on XIN XOUT for ACLK *//
;
; MSP430F149
; -----------------
; /|\| XIN|-
; | | | 32kHz
; --|RST XOUT|-
; | |
; | P3.4|----------->
; | | 9600 - 8N1
; | P3.5|<-----------
;
; CPU registers used
#define PointerTX R4
#define PointerRX R5
;
String1 EQU 0200h
;
; M. Buccini
; Texas Instruments Inc.
; Feb 2005
; Built with IAR Embedded Workbench Version: 3.21A
;******************************************************************************
#include <msp430x14x.h>
;-----------------------------------------------------------------------------
ORG 0F000h ; Program Reset
;-----------------------------------------------------------------------------
RESET mov.w #0A00h,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
SetupP3 bis.b #030h,&P3SEL ; P3.4,5 = USART0 TXD/RXD
SetupUART0 bis.b #UTXE0+URXE0,&ME1 ; Enable USART0 TXD/RXD
bis.b #CHAR,&UCTL0 ; 8-bit characters
mov.b #SSEL0,&UTCTL0 ; UCLK = ACLK
mov.b #003h,&UBR00 ; 32k/9600 - 3.41
mov.b #000h,&UBR10 ;
mov.b #04Ah,&UMCTL0 ; Modulation
bic.b #SWRST,&UCTL0 ; **Initialize USART state machine**
bis.b #URXIE0+UTXIE0,&IE1 ; Enable USART0 RX/TX interrupt
bic.b #UTXIFG0,&IFG1 ; Clear inital flag on POR
clr.w PointerRX ;
;
Mainloop bis.w #LPM3+GIE,SR ; Enter LPM3 w/ int until Byte RXed
nop ; Required only for debugger
;
;------------------------------------------------------------------------------
USART0TX_ISR;
;------------------------------------------------------------------------------
cmp.w #String1+8,PointerTX ; Complete string TX'ed?
jeq Done ;
mov.b @PointerTX+,&TXBUF0 ;
Done reti ;
;
;-----------------------------------------------------------------------------
USART0RX_ISR;
;-----------------------------------------------------------------------------
mov.b &RXBUF0,String1(PointerRX) ; Store RX data
inc.w PointerRX ;
cmp.b #8,PointerRX ;
jne USART_Done ;
clr.w PointerRX ;
mov.w #String1,PointerTX ;
mov.b @PointerTX+,&TXBUF0 ;
USART_Done reti ;
;
;------------------------------------------------------------------------------
; Interrupt Vectors
;------------------------------------------------------------------------------
ORG 0FFFEh ;
DW RESET ; POR, ext. Reset, Watchdog
ORG 0FFF2h ;
DW USART0RX_ISR ; USART0 receive
ORG 0FFF0h ;
DW USART0TX_ISR ; USART0 transmit
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -