This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP430FR2355:MSP430FR2355开发板上的 UART1 TX --需要很长时间才能发送??

Guru**** 2387080 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1112561/msp430fr2355-uart1-tx-on-msp430fr2355-dev-board-----takes-a-long-time-to-transmit

器件型号:MSP430FR2355

你好。

我在上述使用者开发板上的19200处运行 UART1。  在 Putty 和 CCS 控制台中、我可以向 DUT 发送字符并立即做出响应、但是当我将字符从 DUT 发送到 Putty 或 CCS 控制台时、数据流显示大约需要10秒。  数据流是来自 DUT 的12位无符号 A/D 值。  我已使用断点验证 A/D 是否按预期立即发生、似乎我进入了 ISR 的 TX UART 部分。  我甚至可以看到、如果我在加载 TXBUF 后放置我的断点、该断点会立即发生、但进入控制台的数据流需要花费很长时间。

我已经验证它也是在115200波特下发生的。  我正在使用 LPM3。  我已经尝试使用 LPM0、也没有 LPM、我也得到了相同的结果。

我可以尝试的任何事情都将有帮助、因为我没有想法????

以下是我认为相关的代码片段:

ISR TX 部分:

      case USCI_UART_UCTXIFG:
          UCA1TXBUF = itoa((((uint16_t)avg) >> (4 * lowByte)) & 0x0F);
          while (!(UCA1IFG & UCTXIFG)); //wait until buffer empty
          if (lowByte == 0)
           {
               UCA1IE &= ~UCTXIE;
               lowByte = 2;
           }
           else
               lowByte --;
          break;

itoa 函数:

uint16_t itoa(uint16_t k)
{
    if (k <= 9)
        return '0' + k;
    else
        return 'A' + (k - 10);
}

低字节声明:

__vo uint16_t i = 0, lowByte = 2;

UART 初始化:  

void UART_Init(void)
{
    P4SEL0 |= BIT3 | BIT2;
    UCA1CTLW0 |= UCSWRST;
    UCA1CTLW0 |= UCSSEL__SMCLK;
    UCA1BR0 = 52; //19200
    //UCA1BR0 = 8; //115200
    UCA1BR1 = 0x00;
    UCA1MCTLW = 0x4900 | UCOS16 | UCBRF_1; //19200
    //UCA1MCTLW = 0xF700 | UCOS16 | UCBRF_10; //115200
    UCA1CTLW0 &= ~UCSWRST;

    UCA1IFG &= ~UCRXIFG;
    UCA1IE |= UCRXIE;

}

主函数中启用 TX UART 的部分:

        if (ISR.ADComplete)
        {
            ISR.ADComplete = F;
            sum += adcResult;
            cntSamples--;
            if (cntSamples == 0)
                {
                    avg = (float)sum / numberADSamples;
                    sum = 0;
                    AppADC.pADC->ADC_CTL[0] &= ~ADCENC;
                    AppADC.pADC->ADC_IFG &= ~ADCIFG0;
                    UCA1IE |= UCTXIE;
                }
        }

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    问题迎刃而解!  事实上、调试器和 UART 正处于运行状态、这会减慢所有速度。。。如果我关闭 CCS 并运行应用程序、它可以正常工作。