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.

Configuring GPIO-based interrupts

Other Parts Discussed in Thread: TM4C123GH6PM

Hello

I am just trying to figure out how to configure GPIO-based interrupts. I put together a little test program where I wanted the ISR to turn on or off the PORT F LED whenever PORT C, pin 4 is subjected to a rising or falling voltage edge. However, whenever I try to compile I get the following error:

Microcontroller is the TM4C123GH6PM.

The source code in the main.c file is as follows:

//#includes for required standard C libraries
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <math.h>

//Tivaware #includes allowing use of Tivaware API functions for easy to use and convenient control and
//initialisation of microcontroller peripherals and pre-defined microcontroller register address labels
//for more convenient direct register access
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"

int light = 0;

int main(void)
{

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIODirModeSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
GPIOIntRegister(GPIO_PORTC_BASE, lightChange);
GPIOIntTypeSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_BOTH_EDGES);
GPIOIntEnable(GPIO_PORTC_BASE, GPIO_PIN_4);

//Enable processor to respond to interrupts
IntMasterEnable();

while(1)
{
//wait in endless loop for next interrupt
}
}

void lightChange(void)
{
light++;
if(light%2 == 0)
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1 | GPIO_PIN_2,0x06);
}
else
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1 | GPIO_PIN_2,0x00);
}
}

I would also like to add I changed the startup file and added the pre-defined name "PART_TM4C123GH6PM" as per page 103 of the TM4C123G launchpad workshop. I called the new ISR "lightChange" and replaced the  "intDefaultHandler" with this name at the GPIO Port C vector, as shown below in this excerpt of the amended startup file:

extern void _c_int00(void);
extern void lightChange(void);
//*****************************************************************************
//
// Linker variable that marks the top of the stack.
//
//*****************************************************************************
extern uint32_t __STACK_TOP;

//*****************************************************************************
//
// External declarations for the interrupt handlers used by the application.
//
//*****************************************************************************
// To be added by user

//*****************************************************************************
//
// The vector table. Note that the proper constructs must be placed on this to
// ensure that it ends up at physical address 0x0000.0000 or at the start of
// the program if located at a start address other than 0.
//
//*****************************************************************************
#pragma DATA_SECTION(g_pfnVectors, ".intvecs")
void (* const g_pfnVectors[])(void) =
{
(void (*)(void))((uint32_t)&__STACK_TOP),
// The initial stack pointer
ResetISR, // The reset handler
NmiSR, // The NMI handler
FaultISR, // The hard fault handler
IntDefaultHandler, // The MPU fault handler
IntDefaultHandler, // The bus fault handler
IntDefaultHandler, // The usage fault handler
0, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
IntDefaultHandler, // SVCall handler
IntDefaultHandler, // Debug monitor handler
0, // Reserved
IntDefaultHandler, // The PendSV handler
IntDefaultHandler, // The SysTick handler
IntDefaultHandler, // GPIO Port A
IntDefaultHandler, // GPIO Port B
lightChange, // GPIO Port C

I am sure it is a very simple mistake as what i am trying to do is pretty basic. Could anyone shed any light on to what I'm doing wrong?