我是使用的是LaunchPad开发板,将原来的msp430g2231换成msp430g2553,使用msp430g2553的TI提供的uart例程,无法发送和接收到数据?请问是怎么回事?
Young Hu:
您好,
把TX和RX调换一下!2553片上集成UART,引脚P1.1为RXD,引脚P1.2为TXD。与launchpad的跳线处正好反着。
Young Hu:
回复 Young Hu:
如下图所示!把RX,TX的两个跳线帽去掉
iceman:
回复 Young Hu:
我按照那个方法使用杜邦线连接了,但是还是我在串口调试助手上还是看不到数据。程序如下:
//******************************************************************************
// MSP430G2xx3 Demo – USCI_A0, 115200 UART Echo ISR, DCO SMCLK, LPM4
//
// Description: Echo a received character, RX ISR used. Normal mode is LPM4.
// Automatic clock activation for SMCLK through the USCI is demonstrated.
// All I/O configured as low outputs to eliminate floating inputs.
// USCI_A0 RX interrupt triggers TX Echo.
// Baud rate divider with 1MHz = 1MHz/115200 = ~8.7
// ACLK = n/a, MCLK = SMCLK = CALxxx_1MHZ = 1MHz
//
// MSP430G2xx3
// —————–
// /|\| XIN|-
// | | |
// –|RST XOUT|-
// | |
// | P1.4|–>SMCLK = 1MHz (active on demand)
// | |
// | P1.2/UCA0TXD|————>
// | | 115200 – 8N1
// | P1.1/UCA0RXD|<————
//
// D. Dang
// Texas Instruments Inc.
// February 2011
// Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
//******************************************************************************
#include "msp430g2553.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1DIR = 0xFF; // All P1.x outputs
P1OUT = 0; // All P1.x reset
P1SEL = BIT1 + BIT2 + BIT4; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2; // P1.4 = SMCLK, others GPIO
P2DIR = 0xFF; // All P2.x outputs
P2OUT = 0; // All P2.x reset
P3DIR = 0xFF; // All P3.x outputs
P3OUT = 0; // All P3.x reset
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(LPM4_bits + GIE); // Enter LPM4, 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
}
iceman:
回复 iceman:
好像LaunchPad开发板在115200的波特率下就没有办法收发数据。是不是仿真器上的串口转USB的问题。
iceman:
回复 iceman:
我用程序测试2400、9600、19200都可以正常收发数据,使用P1.1-RXD ,P1.2-TXD
Young Hu:
回复 iceman:
您好,
具体的速度我没有去测过,一般是用9600。
在LaunchPad的User's Guide的section1.1中有以下说明:
USB debugging and programming interface featuring a driverless installation and application UART serial communication with up to 9600 Baud。
建议你使用9600