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.
Hi Everyone,
I need to Trigger my GPIO Interrupts through a Software call . How do I do this?
My Code Below:
void PortJIntHandler(void) { uint32_t delay=0; GPIOIntClear(GPIO_PORTJ_BASE, GPIO_INT_PIN_0); GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, (GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_1) ^ GPIO_PIN_1)); for(delay=0;delay<10000;delay++); //some delay } void interrupt_initialise(void) { /* Configure the switch on the left of the launchpad, SW1 to a input with internal pull-up. */ GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0); GPIOPadConfigSet(GPIO_PORTJ_BASE ,GPIO_PIN_0,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); GPIOIntDisable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0); GPIOIntTypeSet(GPIO_PORTJ_BASE,GPIO_PIN_0,GPIO_FALLING_EDGE); GPIOIntRegister(GPIO_PORTJ_BASE,PortJIntHandler); for(g_ui32delay=0;g_ui32delay<10000;g_ui32delay++); //some delay GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0); for(g_ui32delay=0;g_ui32delay<25000;g_ui32delay++); //some delay } int main(void) { PinoutSet(); ROM_IntMasterEnable(); interrupt_initialise(); while(1) { SysCtlDelay(16000000); IntTrigger(INT_GPIOJ | GPIO_INT_PIN_0); //I Need to call the Interrupt here!!! } }
Thanks for the Help in advance...
Regards,
Girish.
Hello Amit,
Thanks for your fast response. I have indeed included the interrupt.h file in my code. Attached herewith is the list of include files. still the code does not work.
My Includes list:
#include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/debug.h" #include "driverlib/gpio.h" #include "driverlib/rom.h" #include "driverlib/sysctl.h" #include "pinout.h" #include "userdefines.h" #include "inc/hw_ints.h" #include "driverlib/interrupt.h"
Regards,
Girish.
Dear Amit,
Thanks for your suggestion. In my working code, I shall certainly implement your advice. I am re pasting my code. Hopefully, you can view my code this time.
#include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/debug.h" #include "driverlib/gpio.h" #include "driverlib/rom.h" #include "driverlib/sysctl.h" #include "pinout.h" #include "userdefines.h" #include "inc/hw_ints.h" #include "driverlib/interrupt.h" void PortJIntHandler(void) { GPIOIntClear(GPIO_PORTJ_BASE, GPIO_INT_PIN_0); GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, (GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_1) ^ GPIO_PIN_1)); } void interrupt_initialise(void) { /* Configure the switch on the left of the launchpad, SW1 to a input with internal pull-up. */ GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0); GPIOPadConfigSet(GPIO_PORTJ_BASE ,GPIO_PIN_0,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); GPIOIntDisable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0); GPIOIntTypeSet(GPIO_PORTJ_BASE,GPIO_PIN_0,GPIO_FALLING_EDGE); GPIOIntRegister(GPIO_PORTJ_BASE,PortJIntHandler); GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0); for(g_ui32delay=0;g_ui32delay<25000;g_ui32delay++); //some delay } int main(void) { PinoutSet(); ROM_IntMasterEnable(); interrupt_initialise(); while(1) { SysCtlDelay(16000000); IntTrigger(INT_GPIOJ | GPIO_INT_PIN_0); //I Need to call the Interrupt here!!! } }
Dear Amit,
I did include the IntEnable(INT_GPIOJ) in my initialise code and now my revised initialise code is shown below:
void interrupt_initialise(void) { /* Configure the switch on the left of the launchpad, SW1 to a input with internal pull-up. */ /*GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0); GPIOPadConfigSet(GPIO_PORTJ_BASE ,GPIO_PIN_0,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);*/ GPIOIntDisable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0); GPIOIntTypeSet(GPIO_PORTJ_BASE,GPIO_PIN_0,GPIO_FALLING_EDGE); GPIOIntRegister(GPIO_PORTJ_BASE,PortJIntHandler); GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0); IntEnable(INT_GPIOJ); for(g_ui32delay=0;g_ui32delay<25000;g_ui32delay++); }
But now the program is running to interrupt fault handler routine as shown below:
static void IntDefaultHandler(void) { // // Go into an infinite loop. // while(1) { } }
Please Advice....
Regards,
Girish.
Dear Amit,
Thanks...I tried out the code late evening and it did work....Thanks again, for sparing your valuable time and showing interest in resolving the issue. I do heartily appreciate the involvement of the TI team in extending the much needed support for people who migrate from controllers from other manufacturers to TI Controllers. Keep up the Good work Guys!!!
REgards,
Girish.