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.

UART Code Error

Hello I have written a code to implement UART with the Stellaris Launchpad and I am having a problem when building it. Bellow is my code

#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"

int main(void) {

SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_1);

UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

UARTCharPut(UART0_BASE, 'E');
UARTCharPut(UART0_BASE, 'n');
UARTCharPut(UART0_BASE, 't');
UARTCharPut(UART0_BASE, 'e');
UARTCharPut(UART0_BASE, 'r');

while (1)
{

}

}

I am having problems with this line "GPIOPinConfigure(GPIO_PA1_U0TX);" when building, I get this error "#20 identifer "GPIO_PA1_U0TX" is undefined"

Any suggestion on how to solve that error. Thanks in advance

  • Hello Mahmoud

    i tested your code on Keil(tool).No building errors found.i think problem may be due to the incorrect include path you have given.if you are using keil, then open the project window , right click on the folder at the top,select options for target, click on c++tab,include the correct path on the coloum given.

    for eg: C:/launchpad/ek_lm4f120xl/boards/project name

    give proper path exactly with same names as saved in your folders 

  • Hello George,

    Sorry I didn't specify in the earlier post what tool I was using. I am using Code Composer Studio IDE v5. I don't use KIEL. I have a question how is it possible that it is running normal when you build it on KIEL and its giving me an error when I am building it on Code Composer Studio? 

  • Hi,

    Search the forum- this is "usual" - happened to others too - you should add this: PART_IS_LM4FXXX or PART_IS_TM4CXXX (the type of your micro - you did not told us what do you use so I can't give you exact define). The add should be done in Compiler predefined symbols tab. Search the forum, there are also pictures showing that (or review the documentation received with your board, or open an already made example from TI and look for compiler setting). 

    Petrei

  • HAI

    Consider the preprocessor directive (#include"driverlib/gpio.h";) given at the top of your code. If "gpio.h" was not found by the compiler in the "driverlib" folder ,it wiil show building errors as "GPIO_PA1_U0TX" is undefined".

    Also  when you doesn,t give proper include paths in your compiler settings same errors will be produced. i also met with this problem in keil earlier before giving proper include paths.I am not familiar with code composer studio,download "launchpad workshop" from TI site,all the compiler settings regarding code composer studio is given there. Otherwise test the instructions given by petrie