c - 使用 Msp430fr5969 通过 Tx 发送字符串

标签 c embedded msp430

我正在尝试将数据从 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/

相关文章:

c - 排序插入到具有重复项的固定大小数组中

c - 如何从 Texas Instruments Code Composer 中的现有项目创建新项目?

复制不同数据类型的缓冲区内容

c - 由于看门狗 (IAR/MSP430),我的嵌入式应用程序从未完成初始化以进入 main()

C:如何在结构中存储二维字符数组?

c - 未知段错误

c++ - X Window 系统上的顶级窗口

c - 如何在C中把帕斯卡三角形倒过来,让第一行最后打印,最后一行最先打印?

operating-system - 使用抢占式内核时的信号量

embedded - 是否有可用的 FreeRTOS 解释语言库?