I am trying to use the peripheral driver library for the TIVA TM4C123 development board instead of accessing the registers directly. I have tried to copy the programming example in the GPIO section (page 280 of this attached link, See Link to TIVA library PDF) but I have an error message. I have downloaded the driver libraries and they are saved in the same location as my code files. I have included them all in my C file and I can see they are included in my source file targets.

In the attached code below, every time I pass GPIO_PORTA_BASE into one of the GPIO library functions, it says "error: use of undeclared identifier".

I don't see GPIO_PORTA_BASE inside the GPIO header file (or any others that I checked), which maybe explains why but I am unsure of how to fix this. Any ideas?

EDIT, ADDED MCU DATSHEET: This is the datasheet for my MCU

#include "include/tm4c123gh6pm.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include "include/driverlib/cpu.h"
#include "include/driverlib/gpio.h"
#include "include/driverlib/interrupt.h"
#include "include/driverlib/pin_map.h"
#include "include/driverlib/sysctl.h"
#include "include/driverlib/sysexc.h"
#include "include/driverlib/systick.h"

int32_t i32Val;

 int main()

//Enable the GPIOA peripheral  


//Wait for the GPIOA module to be ready. 


// Register the port-level interrupt handler. This handler is the first 
// level interrupt handler for all the pin interrupts. 

GPIOIntRegister(GPIO_PORTA_BASE, PortAIntHandler);
// Initialize the GPIO pin configuration. 
// Set pins 2, 4, and 5 as input, SW controlled. 


// Set pins 0 and 3 as output, SW controlled. 


// Make pins 2 and 4 rising edge triggered interrupts. 


// Make pin 5 high level triggered interrupts. 


// Read some pins. 


// Write some pins. Even though pins 2, 4, and 5 are specified, those pins 
//are unaffected by this write because they are configured as inputs. 
//At the end of this write, pin 0 is low, and pin 3 is high. 


// // Enable the pin interrupts. 


  • \$\begingroup\$ Your link is dead. Also, if you only want to use gpios, most of your includes are unnecessary. Finally, it's a better practice to use a compiler option such as -I to include files or folders or use your tool to deal with it instead of hardcore the file paths in your C file. \$\endgroup\$
    – Welgriv
    May 15, 2020 at 11:06
  • \$\begingroup\$ @Welgriv, I have fixed the link, thanks for letting me know. Yeah I know most header files aren't needed, I have removed some unnecessary ones. \$\endgroup\$
    – David777
    May 15, 2020 at 18:28

2 Answers 2


Their GPIO example is pretty shite for something that was supposedly revised just last month. It just dumps code in your lap, without letting you know exactly you need to include to get it to compile. And LED blinky stuff is usually the very first thing one does to test out a new MCU.

Anyways, it would seem that you're missing the header file inc/hw_memmap.h. You'll need to include this to get access to the base addresses for the GPIO ports. You can probably use this example as a reference for setting up GPIO. Alternatively, if you get this error use of undeclared identifier for any other name (that should be predefined), you can just run a search from the command line, positioned at the root of the driver library, for all mentions of that name in any header file. For instance, on Windows: findstr /S /I GPIO_PORTA_BASE *.h should work.

  • \$\begingroup\$ Yeah it is a terrible example. Thanks, I have removed the undeclared identifier error by adding that header file, however I now have another error saying (error: : cannot open source input file "inc/hw_memmap.h": No such file or directory). I have it saved in the same folder and have included it at the top of my C file? \$\endgroup\$
    – David777
    May 16, 2020 at 14:16
  • 1
    \$\begingroup\$ @David777 Search your library for that file. Or even better, run the command as I said, to find where the identifier is defined exactly. That'll both tell you which file contains the name and also where the file is located, basically killing 2 birds with one stone. \$\endgroup\$ May 16, 2020 at 14:20
  • \$\begingroup\$ I'm still unsure. I actually created my own header files and copied the text from the TIVA header files instead of including theirs. I have checked and it in saved in the same folder as the C file. Sorry, forgive my lack of knowledge on this subject. \$\endgroup\$
    – David777
    May 16, 2020 at 14:30
  • \$\begingroup\$ As you have solved my problem from the initial question, I will accept your answer and re-post a new question with my new problem. Thanks for your help. \$\endgroup\$
    – David777
    May 16, 2020 at 15:50
  • 1
    \$\begingroup\$ @David777 You're welcome. Regarding copying the header files, I'd strongly recommend you don't do that, at least not till you know what you're doing. Simply download the library as is, add it to your Keil project, and then try to build the most simple application, like the LED blink stuff I linked to in the answer. Simplest way to do this is probably to download the Keil Device Family Pack for that board from here: keil.com/dd2/texasinstruments/tm4c123gh6pm. The peripheral library and examples are probably all included. \$\endgroup\$ May 16, 2020 at 19:37

If the compiler says "use of undeclared identifier" it's because GPIO_PORTA_BASE is not declared anywhere within the various files you includes, as you guess. Three solutions:

  1. You define it yourself.
  2. You do not use it and give to the functions an expected parameter. To achieve this you can go to the function definition and/or prototype and see the type expected. If this type is an enumerated value (which is what I presume regarding what you are trying to do) look for the enumerated value definition (which hopefully be in the same header file) to see what parameters you can give.
  3. Find the correct file to include that define the symbol.
  • \$\begingroup\$ Thanks for your answer. How can I find the value for GPIO_PORTA_BASE to define it myself or find the header file(s) that I must be missing that includes it? I have added the MCU datasheet link in as well if it helps. \$\endgroup\$
    – David777
    May 15, 2020 at 21:06
  • 1
    \$\begingroup\$ Just do some grep -r GPIO_PORTA_BASE --include \*.h among your directory. \$\endgroup\$
    – Welgriv
    May 19, 2020 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.