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 on Cortex-M4



Hi,

First of all, I'm a newbie..

I'm trying to make my board act on an interrupt but although I've browsed the web and this forum in search of an answer I'm still missing out on something.
I would definitely appreciate it if somebody could help me out with this. I've set up Pin 4 on Port F to interrupt on a falling edge but it won't do anything.

Although I want to initiate a timer on this interrupt, I've commented this out and added some blinky led stuff but even this will not work.

My code is the following:

#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "inc/lm4f120h5qr.h"
#include "driverlib/fpu.h"
#include "driverlib/pin_map.h"
#include "driverlib/timer.h"
#include "utils/uartstdio.h"
#include "utils/cmdline.h"

int i = 0;
int j = 0;
int k = 0;
int l = 0;
int GPIOarrays[];

void PortFIntHandler(void);
void Timer0IntHandler(void);

int main(void)
{

    unsigned long ulPeriod;

SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); //zet kloksnelheid op 40mhz
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);


//LEDs
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);


//Interrupt
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);
IntPrioritySet(INT_GPIOF, GPIO_PIN_4);
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_FALLING_EDGE);
GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_4);
IntEnable(INT_GPIOF);


//Set LEDs off
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x0F);


//Timer
TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_ONE_SHOT);
ulPeriod = (SysCtlClockGet() / 637) /2;
TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod -1);
TimerEnable(TIMER0_BASE, TIMER_A);
IntEnable(INT_TIMER0A);


//UART
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioInit(0);

UARTprintf("UART Shoutbox:");
UARTprintf("\n");

IntMasterEnable();

while(1){}
}
void Timer0IntHandler(void){

    if(i == 17){
        i = 0;
    }else{
        i++;
    }
    if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_4)){
        GPIOarrays[i] = 1;
    }else{
        GPIOarrays[i] = 0;
    }
    if(i == 16){
        for(j=0; j<=i; j++){
            UARTprintf("%i", GPIOarrays[j]);
        }
    }
    TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
}
void PortFIntHandler(void){
    //Timer0IntHandler();
    GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_4);
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00);
    SysCtlDelay(400000);
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x02);
    SysCtlDelay(400000);
}



  • Have you modified your startup file to include the correct pointers to your interrupt handlers?

  • I told you I'm a newbie :-)..

    Thanx Slandrum!!

  • Hi Slandrum,

    I am using SysTick and getting some issue.

    Currently, my project built from an example one in TI REsource Explorer/TI-RTOS/ARM/Tiva C Series/Tiva TM4C123GHPGE/Example Projects. I just config SysTick by the code:

    	SysTickPeriodSet(SysCtlClockGet() / 5);
    	//SysTickIntRegister(&SysTickIntHandler);
    	SysTickIntEnable();
    	SysTickEnable();

    However when the board run, I got the error:

    ti.sysbios.family.arm.m3.Hwi: line 1120: E_noIsr: id = 15, pc = 00008c22

    Maybe the SysTick interrupt handler could not be invoked, interrupt vector for systick did not located?

    I search through the forum and found that we need to modify "startup_ccs.c". But there is no such startup file in example project imported from TI-RTOS/ARM/Tiva C Series/Tiva TM4C123GHPGE/Example Projects.

    Could you please clarify me how to find/modify startup file?

    Thank you,

    Tin Phan

    PS: I just tried an example from TI REsource Explorer/StellarisWare/boards/... and startup_ccs.c existed in the projects. And SysTickHandler running OK from StellarisWare examples. Can I use this startup_ccs.c for the project in TI-RTOS?

  • Sorry, I can't help you with registering interrupt handlers under an RTOS.  I never used an RTOS when i worked on Stellaris projects.  You will get better visibility to your question if you start your own thread, and if you do not direct your question to an individual.

    Tacking a new question onto an old existing thread means that it may not get seen especially if the thread already has a verified answer in it.  Directing your question to an individual (especially one that doesn't work for TI) may mean that your question is not seen by the individual for months if at all, and others may refrain from providing useful answers.