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.

串口问题

Other Parts Discussed in Thread: TM4C123GH6PM, TM4C123GE6PM

我从qs-rgb复制了

void
ConfigureUART(void)
{
//
// Enable the GPIO Peripheral used by the UART.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

//
// Enable UART0
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

//
// Configure GPIO Pins for UART mode.
//
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

//
// Use the internal 16MHz oscillator as the UART clock source.
//
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, 16000000);
}

build 后出现这样的错误,

"../test1.c", line 40: warning #225-D: function "ROM_SysCtlPeripheralEnable" declared implicitly "../test1.c", line 50: warning #225-D: function "ROM_GPIOPinConfigure" declared implicitly "../test1.c", line 50: error #20: identifier "GPIO_PA0_U0RX" is undefined "../test1.c", line 51: error #20: identifier "GPIO_PA1_U0TX" is undefined "../test1.c", line 52: warning #225-D: function "ROM_GPIOPinTypeUART" declared implicitly

我把上面的代码改成了下面的,上面的错误没了

void
ConfigureUART(void)
{
//
// Enable the GPIO Peripheral used by the UART.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

//
// Enable UART0
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

//
// Configure GPIO Pins for UART mode.
//
GPIOPinConfigure(0x00000001);
GPIOPinConfigure(0x00000401);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

//
// Use the internal 16MHz oscillator as the UART clock source.
//
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, 16000000);
}

不过出现了这样的问题:

warning #10210-D: creating ".stack" section with default size of 0x800; use the -stack option to change the default size


>> Compilation failure
undefined first referenced
symbol in file
--------- ----------------
UARTStdioConfig ./test1.obj
UARTprintf ./test1.obj

error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "test1.out" not built
gmake: *** [test1.out] Error 1
gmake: Target `all' not remade because of errors.

这是include部分

#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"

请问怎么解决,然后rom.h这个头文件用来干嘛的?

  • Frank

    1.rom.h文件定义了固化在ROM中的driverlib的函数,函数名字以ROM_开头。

    2.

    lin frank 说:
    >> Compilation failure
    undefined first referenced
    symbol in file
    --------- ----------------
    UARTStdioConfig ./test1.obj
    UARTprintf ./test1.obj

    针对这个错误,请在工程设置按照下图配置添加相应的lib和lib路径

    3.

    lin frank 说:
    warning #10210-D: creating ".stack" section with default size of 0x800; use the -stack option to change the default size

    针对该警告,请打开工程属性按照下图修改Stack值

  • "./tm4c123ge6pm_startup_ccs.obj" "./test1.obj" "E:/Program Files (x86)/TI/TivaWare_C_Series-2.0.1.11577/driverlib/ccs/Debug/driverlib.lib" "../tm4c123ge6pm.cmd" -l"E:/Program Files (x86)/TI/TivaWare_C_Series-2.0.1.11577/driverlib/ccs/Debug/driverlib.lib" -l"libc.a" -l"E:/Program Files (x86)/TI/TivaWare_C_Series-2.0.1.11577/grlib/ccs/Debug/grlib.lib"
    <Linking>

    undefined first referenced
    symbol in file
    --------- ----------------
    UARTStdioConfig ./test1.obj
    UARTprintf ./test1.obj

    error #10234-D: unresolved symbols remain

    修改之后还是不行。

    函数名字以ROM_开头要怎么使用?

    谢谢

  • Frank 

    能把你的工程发一下吗?

    另外,ROM函数库的使用只需加入ROM.h头文件。

    然后在函数名之前添加ROM_前缀即可。详细请查看TivaWare Peripheral Driver Library User’s Guide 中的“Using the ROM” 章节。

  • Frank

    请对工程做如下修改:

    1. 工程中加入uartstdio.c文件

    2.工程属性预编译选项(bulid>ARM compiler>advanced option>Predefined symbols)中加入PART_TM4C123GE6PM和TARGET_IS_BLIZZARD_RA1

    3. text1头文件作如下修改:

    //#include "inc/tm4c123gh6pm.h"
    #include "inc/hw_ints.h"

    另外,如果对工程环境设置不太熟悉,建议先采用例程的工程环境配置。

  • 能否解释一下第二步修改里的两项分别是什么意思?

    另能否帮忙看一下这篇帖子 http://www.deyisupport.com/question_answer/microcontrollers/tiva_arm_cortex/f/96/p/65191/149519.aspx#149519

  • 你好,请问能解释一下第二步添加的预定义是什么意思吗?

    还有能否麻烦看一下 http://www.deyisupport.com/question_answer/microcontrollers/tiva_arm_cortex/f/96/t/65191.aspx

  • Zhengguan

    已经在你标注的帖子里做出解释。另外提个小小的建议,请不要重复发帖昂!我们的同事看到会给出及时的解答的。谢谢你的支持!