Tool/software: Code Composer Studio
I am trying to setup a GPIO interrupt triggering on a high level to detect a keypad button press. I am using the EK-TM4C1294XL. All the ports that have 8 pins available are being used for something else. A code snippet is contained below. What am I doing wrong that I am not seeing. The debugger does not get past the line "GPIOIntTypeSet(rowPort, KEYPAD_ROWS, GPIO_HIGH_LEVEL);" in the initKeypad function.
//
// Includes
//
#include <stdbool.h>
#include <stdint.h>
#include <math.h>
#include "inc/tm4c1294ncpdt.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/interrupt.h"
//
// Defines
//
#define PORTC GPIO_PORTC_AHB_BASE
#define PORTP GPIO_PORTP_BASE
#define KEYPAD_ROW_0 GPIO_PIN_0 // The row beginning with 1.
#define KEYPAD_ROW_1 GPIO_PIN_1 // The row beginning with 4.
#define KEYPAD_ROW_2 GPIO_PIN_2 // The row beginning with 7.
#define KEYPAD_ROW_3 GPIO_PIN_3 // The row beginning with P(*).
#define KEYPAD_ROWS (KEYPAD_ROW_0|KEYPAD_ROW_1|KEYPAD_ROW_2|KEYPAD_ROW_3)
#define KEYPAD_COL_0 GPIO_PIN_4 // The column beginning with 1.
#define KEYPAD_COL_1 GPIO_PIN_5 // The column beginning with 2.
#define KEYPAD_COL_2 GPIO_PIN_6 // The column beginning with 3.
#define KEYPAD_COL_3 GPIO_PIN_7 // The column beginning with H(A).
#define KEYPAD_COLS (KEYPAD_COL_0|KEYPAD_COL_1|KEYPAD_COL_2|KEYPAD_COL_3)
#define keypadRow 4
#define keypadCol 4
//
// Global Constants/Variables
//
// Constants
//
const uint8_t keys[keypadRow][keypadCol] =
{{'1','2','3','h'},
{'4','5','6','k'},
{'7','8','9','m'},
{'p','0','f','e'}};
// Volatile Variables
//
// Standard Variables
//
uint32_t KEYPAD_ROW_PORT = 0, KEYPAD_COL_PORT = 0;
int32_t LAST_KEY_PRESSED = -2;
// Booleans
//
bool NEW_KEY_PRESSED = false;
//
// Function Portotype Definitions
//
initKeypad(uint32_t rowPort, uint32_t colPort);
void keyPressISR(void);
//
// Main Program
//
void main (void)
{
//
// Use external 25MHz Precision Oscillator to Generate an 120MHz System
// Clock using the PLL
//
SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);
SYS_CLK_ACT = SysCtlClockFreqSet(SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480, SYS_CLK_REQ);
//
// Enable Peripherals
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
//
// Enable GPIO AHB
//
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOC);
//
// Initialize the keypad interface
//
initKeypad(PORTP, PORTC);
while (1)
{
//
// Loop Code
//
}
}
void initKeypad (uint32_t rowPort, uint32_t colPort)
{
//
// Configure GPIO Type
//
// Output
//
GPIOPinTypeGPIOOutput(colPort, KEYPAD_COLS);
// Input
//
GPIOPinTypeGPIOInput(rowPort, KEYPAD_ROWS);
//
// Set GPIO Direction
//
// Output
//
GPIODirModeSet(colPort, KEYPAD_COLS, GPIO_DIR_MODE_OUT);
// Input
//
GPIODirModeSet(rowPort, KEYPAD_ROWS, GPIO_DIR_MODE_IN);
//
// Configure GPIO Pad Properties
//
// Standard
//
GPIOPadConfigSet(colPort, KEYPAD_COLS, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(rowPort, KEYPAD_ROWS, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
//
// Configure the GPIO Interrupt
//
GPIOIntTypeSet(rowPort, KEYPAD_ROWS, GPIO_HIGH_LEVEL);
GPIOIntRegister(rowPort, keyPressISR);
GPIOIntEnable(rowPort, KEYPAD_ROWS);
GPIOPinWrite(colPort, KEYPAD_COLS, KEYPAD_COLS); // turn on every column
KEYPAD_ROW_PORT = rowPort;
KEYPAD_COL_PORT = colPort;
}
void keyPressISR(void)
{
LAST_KEY_PRESSED = checkKeypad(); //poll the keypad
NEW_KEY_PRESSED = true;
GPIOPinWrite(KEYPAD_COL_PORT, KEYPAD_COLS, KEYPAD_COLS);
GPIOIntClear(KEYPAD_ROW_PORT, KEYPAD_ROWS);
}