LanchPad MSP430G2553 UART問題

509 views
Skip to first unread message

Ray Hsu

unread,
Apr 22, 2013, 12:55:04 AM4/22/13
to msp430lau...@googlegroups.com
想請教一下 :
我用LanchPad搭配MSP430G2553,想測試Hardware UART的功能,
TI sample code如下,功能為echo傳送的資料 --
(軟體是CCS5.3)
---------------------------------------------------------------------------------------------------------------------
#include <msp430.h>

int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  /*
  if (CALBC1_1MHZ==0xFF)                    // If calibration constant erased
  {                                           
    while(1);                               // do not load, trap CPU!!   
  }
  */
  DCOCTL = 0;                               // Select lowest DCOx and MODx settings
  BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
  DCOCTL = CALDCO_1MHZ;
  P1SEL = BIT1 + BIT2;                     // P1.1 = RXD, P1.2=TXD
  P1SEL2 = BIT1 + BIT2;                     
  UCA0CTL1 |= UCSSEL_2;                     // SMCLK
  UCA0BR0 = 8;                              // 1MHz 115200
  UCA0BR1 = 0;                              // 1MHz 115200
  UCA0MCTL = UCBRS2 + UCBRS0;               // Modulation UCBRSx = 5
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt

  __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, interrupts enabled
}

// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
  while (!(IFG2&UCA0TXIFG));                // USCI_A0 TX buffer ready?
  UCA0TXBUF = UCA0RXBUF;                    // TX -> RXed character
}
---------------------------------------------------------------------------------------------------------------------------

jumper有調成垂直,即選擇HW UART,
但用AccessPort送資料,並沒有收到相同的資料回來,
想請教哪裡出了問題呢?謝謝!


Ray Hsu

unread,
Apr 22, 2013, 4:10:52 AM4/22/13
to msp430lau...@googlegroups.com
我是原po..

後來試baud rate是9600的TI sample code可以,將code貼於下方,
但115200的就是不行,
不知道什麼原因,希望有人可以解答,
謝謝!


#include <msp430.h>

int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  if (CALBC1_1MHZ==0xFF)                    // If calibration constant erased
  {                                           
    while(1);                               // do not load, trap CPU!!   
  }
  DCOCTL = 0;                               // Select lowest DCOx and MODx settings
  BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
  DCOCTL = CALDCO_1MHZ;
  P1SEL = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD
  P1SEL2 = BIT1 + BIT2 ;                    // P1.1 = RXD, P1.2=TXD

  UCA0CTL1 |= UCSSEL_2;                     // SMCLK
  UCA0BR0 = 104;                            // 1MHz 9600
  UCA0BR1 = 0;                              // 1MHz 9600
  UCA0MCTL = UCBRS0;                        // Modulation UCBRSx = 1

板主

unread,
Sep 15, 2013, 6:22:34 AM9/15/13
to msp430lau...@googlegroups.com

調查了一下。msp430g2553規格書上明明就有支援到115200
原來是基板上的虛擬usb的部分受限制。只能以最多9600的速度。如果利用其他的 usb 轉 ttl直接與msp430g2553作連結TXD RXD的跳線。則沒有受到速度限制可以上115200。


最近的小小使用心得

Reply all
Reply to author
Forward
0 new messages