1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

msp430g2x21 usi 04 s43

1 117 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1
Dung lượng 3,47 KB

Nội dung

;******************************************************************************* ; MSP430G2x21/G2x31 Demo - USI SPI Interface to HC165/164 Shift Registers ; ; Description: Demonstrate USI in two-way SPI mode Data are read from ; an HC165, and same data written back to the HC164 ; ACLK = n/a MCLK = SMCLK = Default DCO, USI = SMCLK/2 ; ; MSP430G2x21/G2x31/3 ; ; /|\| XIN|; | | | ^ HC164 ; HC165 |RST XOUT|| ; -| | |-|/CLR,B | ; | /LD|< -|P1.1 SIMO0/P1.6| >|A Qx| \-> ; -\->|A-H CLK|< -|P1.5/SCLK - P1.5| >|CLK | ; |-|INH QH| ->|P1.7/SOMI | | | ; |-|SER | | | | | ; - | | | | | | ; ; D Dang ; Texas Instruments Inc ; October 2010 ; Built with IAR Embedded Workbench Version: 5.10 ;******************************************************************************* #include "msp430g2221.h" ; ORG 0F800h ; Program Reset ; RESET mov.w #0280h,SP ; Initialize stackpointer StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer SetupP1 bis.b #02h,&P1OUT ; bis.b #02h,&P1DIR ; SetupUSI bis.b #USIPE7+USIPE6+USIPE5+USIMST+USIOE,&USICTL0; Port, SPI master bis.b #USICKPH+USIIE,&USICTL1 ; Counter interrupt, flag remains mov.b #USIDIV_1+USISSEL_2,&USICKCTL ; /2 SMCLK bic.b #USISWRST,&USICTL0 ; Enable USI mov.b #08h,&USICNT ; init-load counter, clears flag ; Mainloop call #RXTX_HC16x ; Exchange data Delay push.w #0 ; Software delay D1 dec.w 0(SP) ; jnz D1 ; incd.w SP ; jmp Mainloop ; Repeat ; ; RXTX_HC16x; HC165 > URXBUF0 UTXBUF0 > HC164 ; TX0 bit.b #USIIFG,&USICTL1 ; USART0 TX buffer ready? jz TX0 ; Jump > TX buffer not ready bic.b #02h,&P1OUT ; Latch data into 'HC165 bis.b #02h,&P1OUT ; ; ******************** ; Read data are ready to be written mov.b #08h,&USICNT ; Load counter, clears flag ret ; Return from subroutine ; ; ; Interrupt Vectors Used ; ORG 0FFFEh ; MSP430 RESET Vector DW RESET ; END

Ngày đăng: 26/12/2017, 08:42

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w