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.

[参考译文] TM4C129DNCPDT:未获得所需的输出

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

https://e2e.ti.com/support/interface-group/interface/f/interface-forum/1634320/tm4c129dncpdt-not-getting-the-desired-output

器件型号: TM4C129DNCPDT

#include
#include

#include “inc/hw_memmap.h"</s>“
#include “driverlib/sysctl.h"</s>“
#include “driverlib/gpio.h"</s>“
#include “driverlib/uart.h"</s>“
#include “driverlib/pin_map.h"</s>“

内部 main (void)

  uint32_t sysClock;

  //将系统时钟设置为 120MHz
  sysClock = SysCtlClockFreqSet (
    SYSCTL_XTAL_25MHz |
    SYSCTL_OSC_MAIN |
    SysCtl_USE_PLL |
    SYSCTL_CFG_VCO_480、
    120000000
  );

  //启用 GPIOA
  SysCtlPeripheralEnable (SysCtl_Periph_GPIOA);
  while(!SysCtlPeripheralReady (SYSCTL_PERIPH_GPIOA));

  //启用 UART0
  SysCtlPeripheralEnable (SYSCTL_PERIPH_UART0);
  while(!SysCtlPeripheralReady (SYSCTL_PERIPH_UART0));

  //为 UART0 配置 PA0 (RX) 和 PA1 (TX)
  GPIOPinConfigure (GPIO_PA0_U0RX);
  GPIOPinConfigure (GPIO_PA1_U0TX);
  GPIOPinTypeUART (GPIO_PORTA_BASE、GPIO_PIN_0 | GPIO_PIN_1);

  //配置 UART0:9600 波特、8 个数据位、无奇偶校验、1 个停止位
  UARTConfigSetExpClk (
    UART0_BASE、
    sysClock、
    9600、
    UART_CONFIG_WLEN_8 |
    UART_CONFIG_STOP_ONE |
    UART_CONFIG_PAR_NONE
  );

  //启用 UART0
  UARTEnable (UART0_BASE);

  //主循环
  while (1)
  {
    UARTCharPut (UART0_BASE、“H")“);
    UARTCharPut (UART0_BASE、“i")“);
    UARTCharPut (UART0_BASE、'\r');
    UARTCharPut (UART0_BASE、'\n');

    SysCtlDelay (sysClock / 3);//~1 秒延迟
  }
}

这是 我用于 UART 通信的代码,我使用 TTL 到 USB 转换器和 PuTTY 终端,我使用过其他 UART 端口,也接收器部分工作完全正常,但发送器部分不工作,所以指导我得到所需的输出,当我调试代码时,我看到 PuTTY 中的空白屏幕

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

    您好:

    您能否尝试使用内部振荡器而不是外部振荡器来查看这是否有任何影响? 乍一看、使用外部 MY 会导致系统时钟不同步、这可能会导致波特率出现问题。