我正在尝试将数据从 Msp430fr5969 Launchpad 发送到 rn-52-ek,以便它可以通过蓝牙传递数据。
#include <msp430.h>
void uartSend(unsigned char *pucData, unsigned char ucLength)
{
while(ucLength>0)
{
// Wait for TX buffer to be ready for new data
while(!(UCA1IFG & UCTXIFG));
// Push data to TX buffer
UCA1TXBUF = *pucData;
// Update variables
ucLength--;
pucData++;
}
}
void initUART()
{
/* Place UCA0 in Reset to be configured */
UCA0CTL1 = UCSWRST;
//Set BRCLK = SMCLK
UCA0CTL1 |= UCSSEL_2;
//Values found using table for 16Mhz and 115200 baudrate
UCA0BR0=8;
UCA0BR1=0;
UCA0MCTLW = 0xF7 << 8;
UCA0MCTLW |= 10 << 4;
UCA0MCTLW |= UCOS16;
//UCA0 out of reset
UCA0CTL1 &= ~UCSWRST;
}
int main(void) {
// disable watchdog timer
//------------------------
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
initUART();
unsigned char sendString[] = "Banana";
unsigned char length=6;
while(1)
{
uartSend(sendString,length);
}
return 0;
}
当我运行上面的代码时没有任何反应,甚至没有在万用表上读取任何内容。我错过了什么?
我知道有一些不好的做法,我只是想让它正常工作,稍后我会添加基于中断的发送。
最佳答案
您应该将端口 2.5 设置为 UART 的 Tx
关于c - 使用 Msp430fr5969 通过 Tx 发送字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26550842/