工具/软件:Code Composer Studio
两个 MSP430和 MSP432控制器之间的 UART 通信
你(们)好
我正在尝试在 msp430g2553 和 msp432p401r launchpad 之间建立 UART 通信。
首先、我尝试 通过 UART 将数据发送到 msp430g2553、它按预期工作(回波示例)。
然后、我 在每次 传输之间的3秒间隔内使用 msp432p401r 通过 UART 将数据传输到 PC、而且也可以正常工作(TI 驱动程序示例中的 uartecho 示例)。
现在、我将这两个控制器的 UART 连接在一起、
VCC<->VCC
GND <-> GND
TXD <-> RXD
RXD <->TXD
我移除了 msp432上的跳线、并将其连接到 MSP430上的引脚(如上所述) 1.1和1.2。
我可以 通过 示波 器看到432正在正确地传输 Dara、但430出于某种原因未接收数据。
//########################################################################################################################
这是430g2553上的代码:
//########################################################################################################################
#include "msp430g2553.h"
#define TXLED BIT0
#define RXLED BIT6
#define TXD BIT2
#define RXD BIT1
const char 字符串[]={"Hello World\r\n"};
unsigned int i;// Counter
int main (void)
{
WDTCTL = WPW + WDTHOLx
= WDC1 CODx 设置
;选择 WD1 MHZ / DCTL0 = WCTL0 + WDC1;选择 DCL1设置 //设置 DCO
DCOCTL = CALDCO_1MHz;
P2DIR |= 0xFF;//所有 P2.x 输出
P2OUT &= 0x00;//所有 P2.x 复位
P1SEL |= RXD + TXD;// P1.1 = RXD、P1.2=TXP1SEL2
|= RXD + TXD;//
TXD
= P1.1LED | P= 0x1;// TXD = P1.2 = P= P= PLED;P= P1 TXD + P= P= 0x1
UCA0CTL1 |= UCSSEL_2;// SMCLK
UCA0BR0 = 108;// 1MHz 115200
UCA0BR1 = 0x00;// 1MHz 115200
UCA0MCTL = UCBRS2 + UCBRS0;//调制 UCBRSx = 5
UCA0CTL1 &=~UCS0MCTL = UCBRS2 + UCBRXCI_USCI_R0;//初始化 USCI_RST_USCI_TRS**中断
;// UCA0RX0CI_RST_USCI_RST_USCI_RST/ UCA0RST_UCA0X0
//输入 LPM0,带 int 直到字节 RXed
,同时(1)
{}
#pragma vector=USCIAB0TX_vector
__interrupt void USCI0TX_ISR (void)
{
P1OUT |= TXLED;
UCA0TXBUF = string[i++];//如果
(i = sizeTx/)超过字符串,则发送下一个字符串
UC0IE &=~UCA0TXIE;//禁用 USCI_A0 TX 中断
P1OUT &=~TXLED;}
#pragma vector=USCIAB0RX_vector
__interrupt void USCI0RX_ISR (void)
{
P1OUT |= RXLED;
if (UCA0RXBUF ='A')//接收到'A'?
{
i = 0;
UC0IE |= UCA0TXIE;//启用 USCI_A0 TX 中断
UCA0TXBUF = STRING[I++];
}
P1OUT &=~RXLED;
}
//########################################################################################################################
这就是432上的代码:
//########################################################################################################################
/* === uartecho.c ==== */ #include #include /*驱动程序头文件*/ #include #include #include #include /*示例/板头文件*/ #include "Board.h" void timerCallback (Timer_handle myHandle); volatile int sec_cn=0、send_f=0; /* === mainThread ==== // void * mainThread (void * arg0) { const char echoPrompt[]="回显字符:\r\n"; const char echoPrompt2[]="A"; UART_Handle UART; UART_Params uartParams; Timer_handle timer0; Timer_Params params; /*调用驱动程序初始化函数*/ GPIO_init (); UART_init (); Timer_init (); //配置 LED 引脚*/ GPIO_setConfig (Board_GPIO_LED0、GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); //打开用户 LED */ GPIO_WRITE (Board_GPIO_LED0、GPIO_LED0、板 UART_LED0 处理);//创建 GPIO_LED_LED 数据处理。 */ UART_Params_init (&uartParams); uartParams.writeDataMode = UART_DATA_binary; uartParams.readDataMode = UART_DATA_binary; uartParams.readReturnMode = UART_return_Full; uartParams.readEcho = UART_ECHO_ON; uartParams.baudrate = 115200; UART = UART_OPEN (Board_UART0、&uartParams); IF (UART = NULL){ /* UART_open ()失败*/ while (1); } UART_WRITE (UART、echoPrompt、sizeof (sizePrompt) )));//每1、000、000、000次以微秒或1秒的回调模式设置计时器。 */ Timer_Params_init (¶ms); params.period = 1000000; params.periodUnits = Timer_Period_US; params.timerMode = Timer_Continuous_callback; params.timerCallback = timerCallback; timer0 = Timer_open (Board_TIMER0、¶ms); if (timer0 = NULL) { //初始化计时器失败 * while (1); } if (Timer_start (timer0)= Timer_STATUS_ERROR) { // while (1)无法启动计时器*/ while (1); } //循环永久性 (UART = 1、while (tomeon1)、while (1)、while (1)、while (uart_write)/ while (uart_1)、while (uart_1)、while (uart_1) sizeof (echoPrompt2)); send_f=0; } }} void timerCallback (Timer_handle myHandle) { sec_cn++; if (sec_cnt=3)//使用计数 器计数秒{ // GPIO_toggle (A0); send_f=1; sec_cnt=0; }
我是否遗漏了任何内容?
请告诉我。
此致、
Avraham