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.

Interrupt problems with LM4F120XL

Hi everyone! First, i'm sorry for my english, this isn´t my native language. I'm new in the field of Texas boards. In my project, i´m trying to make a data logger, basically. I have a LM4F120XL board, very similar to new tiva board. My problem is when I want to use interrupts. I read declaration steps about that, but maybe i've forgotten something. One of errors that i get when I run the program is "identifier my_interrupt_handler is undefined" in the line that includes IntRegister() function, where my_interrupt_handler is the function that manage the interrupt. I configure the startup_ccs.c file, adding "my_interrupt_handler" how an external declaration for the reset handler that is to be called when the processor is started, and adding my_interrupt_handler in vector table in the correct position.

 Below you can see my code for a better undertanding.

#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include <string.h>

int main(void)
{

SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL |SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN );

SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

GPIOPinConfigure(GPIO_PB0_U1RX);
GPIOPinConfigure(GPIO_PB1_U1TX);

GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

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

UARTFIFOLevelSet(UART1_BASE,UART_FIFO_TX7_8,UART_FIFO_RX7_8); 
//UARTTxIntModeSet(UART1_BASE, UART_TXINT_MODE_FIFO);

IntRegister(UART1_BASE, my_interrupt_handler);
//UARTIntRegister(UART1_BASE, my_interrupt_handler);
UARTIntClear(UART1_BASE, UART_INT_TX | UART_INT_RX);
UARTEnable(UART1_BASE); 
IntEnable(INT_UART1); 
UARTIntEnable(UART1_BASE, UART_INT_RX);
UARTFIFOEnable(UART1_BASE);
IntMasterEnable();

return(0);
}

void my_interrupt_handler(void)
{...
}

 I hope I have been clear and I hope someone can help me..

Thanks, best regards!

  • Hi Jose,

    Does it get rid of the error if you move the definition of my_interrupt_handler() up above main()? Or if you put a function prototype for it above main()?

    If that doesn't help, I'll see if I can get this post moved to the appropriate Tiva forum. I'm guessing you aren't using SYS/BIOS, correct?

    Whitney

  • Thank you for your answer Whitney. I tried to do that you suggest me but the problem persist. I verified the parameters of the IntRegister() function but nothing. Do you have another possible mistake? If you want, try to move this post to tiva forum or i can add this like a tag for my question. I´m using Code Composer Studio right now.

    Thanks, José.

  • So even after making sure you had extern void my_interrupt_handler(void); at the top of your startup_ccs.c file and putting void my_interrupt_handler(void); above main() in your application, you're still getting the "identifier my_interrupt_handler is undefined" error?

    I'm not sure that you have to use IntRegister() if you are specifying a vector table in startup_ccs.c (look up the IntRegister() API in your driverlib User's Guide), so maybe try commenting out the IntRegister() line.

    I've asked someone to move this post.

    Whitney

  • Hello Jose,

    You do not need to call IntRegister if you are adding the interrupt function directly to the vector table as Whitney has pointed out.  For reference, in the boards folder for TivaWare there should be an example project for interrupts.  If you take a look at that you can see how the interrupt functions are declared and used in the application file and the startup file. 

    Hope that helps.

    Regards,

    Craig

  • Hello, I can fix the problem finally! Is like you tell me...I was reading about the subject. There are two possible ways to configure an interrupt: statically at compile time and dinamically at run time. The first one, is by editing the interrupt handler table in the application’s startup code. The second one is using IntRegister() function.

    Very grateful, best regards!