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.

Unable to Get GPIO Interrupt Working Properly (IntDefaultHandler Called Unexpectedly)

Other Parts Discussed in Thread: CC3200

I'm working on a project that uses an IR remote to transmit signals to an IR receiver, that then communicates the IR signal to my cc3200. The IR signal is communicated as a wave, so my goal is to have an interrupt be invoked every time the signal edge (normally high) drops. However, I'm having two (potentially related) problems.

The first problem is that IntDefaultHandler is being called unexpectedly. Inside my main loop, I have an idle loop. If nothing is in the idle loop, then IntDefaultHandler is invoked. However, if I add anything to the loop (e.g. printf("This shouldn't cause any interrupts to occur\n");), then IntDefaultHandler is never invoked. I've tried stepping through the code to understand why, but I've been unable to find the cause. I've also tried looking at the registers, but whatever information they have isn't clear to me.

The second problem is that my interrupt handler for the signal edge drops is only being called twice per pressed button, instead of approximately 30 times per button (I used a Saleae logic analyzer to determine the pattern of each button's waveform, and each button involves 30 or so pulses).

Here's my main.c file:

tBoolean SysTickInit(void){

// Reset period of SysTick counter
SysTickPeriodSet(SYSTICK_RELOAD_VALUE);

// Enable SysTick
SysTickEnable();

return(true);
}

int counter = 0;

void GPIOPinIntHandler(void){
counter++;

unsigned long elapsedTime;

GPIOIntDisable(GPIOA1_BASE, 0x10);

// Clear interrupt for the IR output pin
GPIOIntClear(GPIOA1_BASE, 0x10);

// Calculate elapsed time
elapsedTime = SYSTICK_RELOAD_VALUE - SysTickValueGet();

// if elapsed time is greater than threshold, this is a new signal
// set first pulse flag to 0
if (elapsedTime > 1500){

// print previous result, if
// if (first_pulse_flag == 1)
// printf("Pulse Result: %u\n", pulse_result);

// reset pulse result
pulse_result = 0;

// reset first pulse flag
first_pulse_flag = 0;
}

// increment pulse counter
pulse_counter += 1;

// first pulse
if (first_pulse_flag == 0){

// first pulse has been detected
first_pulse_flag = 1;

// if elapsedTime is greater than some threshold, pulse is 1
if (elapsedTime > 175){
pulse_result = 1;
}
else{
pulse_result = 0;
}
}
// subsequent pulses
else{
// bitshift left
pulse_result = pulse_result << 1;

// if new signal is 1, add 1
if (elapsedTime > 175){
pulse_result += 1;
}
// if new pulse is 0, add 0
else{
pulse_result += 0;
}
}

GPIOIntEnable(GPIOA1_BASE, 0x10);

// reset systick timer
HWREG(NVIC_ST_CURRENT) = 0x0;
}

void GPIOPinIntInit(void){

// Disable further interrupts
GPIOIntDisable(GPIOA1_BASE, 0x10);

// clear any currently pending interrupts
GPIOIntClear(GPIOA1_BASE, 0x10);

// Register interrupt handler for IR output pin
GPIOIntRegister(GPIOA1_BASE, GPIOPinIntHandler);

// Specify interrupt for falling edge
GPIOIntTypeSet(GPIOA1_BASE, 0x10, GPIO_FALLING_EDGE);

// Enable interrupts from IR output
GPIOIntEnable(GPIOA1_BASE, 0x10);
}


void main()
{

// Initialize board configurations
BoardInit();
PinMuxConfig();

// Initialising UART0 (Terminal) to receive
InitTerm();

// Clear the Terminal.
ClearTerm();

// Display Banner
Message("\n\n\n\r");
Message("\t\t ********************************************\n\r");
Message("\t\t CC3200 Lab 3 Application \n\r");
Message("\t\t ********************************************\n\r");
Message("\n\n\n\r");

// Enable SysTick

SysTickInit();

// Enable GPIO pin interrupts
GPIOPinIntInit();

while(1)
{
}
}

Here's my pin_mux_config.c file:

void PinMuxConfig(void)
{
//
// Enable Peripheral Clocks
//
PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);

//
// Configure PIN_03 for GPIO Input
//
PinTypeGPIO(PIN_03, PIN_MODE_0, false);
GPIODirModeSet(GPIOA1_BASE, 0x10, GPIO_DIR_MODE_IN);
}

Here's the relevant portion of the file containing my interrupt vector:

extern void GPIOPinIntHandler(void);

#ifdef USE_FREERTOS
xPortPendSVHandler, // The PendSV handler
xPortSysTickHandler, // The SysTick handler
#else
IntDefaultHandler, // The PendSV handler
IntDefaultHandler, // The SysTick handler
#endif
IntDefaultHandler, // GPIO Port A0
GPIOPinIntHandler, // GPIO Port A1
IntDefaultHandler, // GPIO Port A2
IntDefaultHandler, // GPIO Port A3
0, // Reserved
IntDefaultHandler, // UART0 Rx and Tx
IntDefaultHandler, // UART1 Rx and Tx