1 / 16

USCI

USCI. 彈性極佳的新型通用串列介面 U niversal S erial C ommunication I nterface. USCI. USCI_A. UART ( 支援 IrDA/LIN) 或 SPI 波特率 (Baud-rate) 產生器及自動波特率偵測 雙 Buffer TX/RX. USCI_B. 支援高達 400kHz 的 I2C master 或 slave 模式或 SPI Bit clock 產生器 雙 Buffer TX/RX. Lab ( 主程式 ). #include "msp430x54x.h"

sancha
Download Presentation

USCI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. USCI 彈性極佳的新型通用串列介面Universal Serial Communication Interface

  2. USCI USCI_A • UART (支援IrDA/LIN) 或SPI • 波特率(Baud-rate)產生器及自動波特率偵測 • 雙Buffer TX/RX USCI_B • 支援高達400kHz的I2C master或slave 模式或 SPI • Bit clock產生器 • 雙Buffer TX/RX

  3. Lab (主程式) #include "msp430x54x.h" void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P5SEL = BIT6+BIT7; // P5.7 5.6 = USCI_A1 TXD/RXD UCA1CTL1 |= UCSWRST; // **Put state machine in reset** UCA1CTL1 |= UCSSEL_1; // CLK = ACLK UCA1BR0 = 0x03; // 32kHz/9600=3.41 (see User's Guide) UCA1BR1 = 0x00; // Baud rate的設定可參考user’s guide UCA1MCTL = UCBRS_3+UCBRF_0; // Modulation UCBRSx=3, UCBRFx=0 UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine** UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt __bis_SR_register(LPM3_bits + GIE); // Enter LPM3, interrupts enabled } 在電子通訊領域,鮑率(Baud rate)即調制速率,指的是信號被調制以後在單位時間內的變化,即單位時間內載波參數變化的次數。它是對符號傳輸速率的一種度量,1鮑即指每秒傳輸1個符號。 單位「鮑」本身就已經是代表每秒的調制數,以「鮑每秒」(Baud per second)為單位是一種常見的錯誤。

  4. Lab (中斷服務程式) // Echo back RXed character, confirm TX buffer is ready first #pragma vector=USCI_A1_VECTOR __interrupt void USCI_A1_ISR(void) { switch(__even_in_range(UCA1IV,4)) { case 0:break; case 2: // Vector 2 - RXIFG while (!(UCA1IFG&UCTXIFG)); // USCI_A1 TX buffer ready? UCA1TXBUF = UCA1RXBUF; // TX -> RXed character break; case 4:break; default: break; } }

  5. USCI

  6. USCI-模式選擇

  7. USCI-初始化

  8. USCI-傳送致能

  9. USCI-傳送格式

  10. USCI-中斷

  11. USCI-中斷

  12. USCI-中斷

  13. USCI-鮑率計算

  14. USCI-鮑率計算(低頻)

  15. USCI-鮑率計算(高頻)

  16. 課堂實驗 • 因器材不足無法看到結果,所以直接判斷程式修改 • LAB1:將範例波特率由9600改為4800 • LAB2:將程式修改頻率為10mhz 波特率為115200 其中初始CLK “ACLK = REFO = 32768Hz, MCLK = SMCLK = default DCO/2 = 1048576Hz” • LAB3:將範例由”傳出所接收到的資料”改為傳出字元’E’

More Related