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.

[参考译文] CCS/TM4C123GH6PZ:UARTCharPut 在 UARTPrintf 不#39;t 时工作

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/743388/ccs-tm4c123gh6pz-uartcharput-works-while-uartprintf-doesn-t

器件型号:TM4C123GH6PZ
Thread 中讨论的其他器件:EK-TM4C123GXL

工具/软件:Code Composer Studio

您好!

我尝试使用 TM4C Launchpad 上的 UART 外设与主机 PC 进行通信。

我使用以下代码:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include 
#include 
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/pwm.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "inc/hw_gpio.h"
#include "#include "包含"hw_map.h"#include "#include

//使用 NULL 指针

#define PWM_FREQUENCY 55

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//我的 I2C 定义并包括
#include "driverlib/i2c.h"
#include "driverlib/interrv.h"
#include "inc/hw_i2c.h"
#include
"sensorlib/i2cm_drv.h"
#include "sensorlib/mpu6050.h"////

/////////////////////////////////////////////////////////////#////#//////////////////////////#//////////////////////////#///////////////////////////////////////////



//我的 UART 定义并包括
#include "driverlib/uartstdio.h"
#include "utils/uartstdio.h"

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main (void)
{

//配置时钟
SysCtlClockSet (SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHz);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//我的 UART 初始化代码
SysCtlPeripheralEnable (SYSCTL_Periph_UART0);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOA);
GPIOPinConfigure (GPIO_PA0_U0RX);
GPIOPinConfigure (GPIO_PA1_U0TX);
GPIOPinTypeUART (GPIO_Porta_base、GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk (UART0_BASE、SysCtlClockGet ()、115200、(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

UARTCharPut (UART0_BASE、"X");

UARTprintf ("Y");

while (1)
{

}
} 

当我运行代码时、字母 X 打印正确、但字母 Y 不打印。

我出了什么问题?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    如果使用"UARTprintf()",则必须首先调用"UARTStdioConfig()"。 请查看中的示例:
    C:\ti\TivaWare_C_Series-2.1.4.178\examples\boards\ek-tm4c123gxl\hello
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    谢谢。
    它现在可以工作了。

    是否有能够接收参数(int/float/et等)的函数 并以与 UARTprintf 相同的方式通过 UART 发送它?