I'm struggling to get interrupts working on Port 2 of the MSP-EXP432P401R dev board. I've disconnected the jumpers going to the LEDs and tied in external switches. I can see the lines being pulled low when exercising an external switch with internal pullups.
I have no issues with interrupts on Port 1,3 or 5 (with similar struggles seeing interrupts on Port 4). I've boiled the code down to setting up interrupts on pin1.1, pin2.0, and pin 2.2. Under debug, I can always see the pin1.1 interrupt but neither of the Port 2 pins. Am I missing a register somewhere?
Here is the code, using MSP432 DriverLib - v3_10_00_09.
#include "driverlib.h" /* MSPWare Driver Library Include. */
/*********************************************************************/
/* Defines, Enumerations, & Type Definitions */
/*********************************************************************/
/* The following constant specifies the high-frequency external */
/* oscillator's clock frequency. */
#define HFXTCLK_FREQUENCY 48000000
/* The following constants specify information about MCLK. */
#define MCLK_SOURCE CS_HFXTCLK_SELECT
#define MCLK_DIVIDER 1
#define MCLK_FREQUENCY (HFXTCLK_FREQUENCY / MCLK_DIVIDER)
/* The following constants specify information about HSMCLK. */
#define HSMCLK_SOURCE CS_HFXTCLK_SELECT
#define HSMCLK_DIVIDER 2
#define HSMCLK_FREQUENCY (HFXTCLK_FREQUENCY / HSMCLK_DIVIDER)
/* The following constants specify information about SMCLK. Note */
/* that: 1) SMCLK can only be sourced by HSMCLK, 2) the MSPWare APIs */
/* require you specify HSMCLK's clock source when configuring SMCLK, */
/* and 3) the divider is relevant to HSMCLK's source. Also note that*/
/* in order to support a 2 Mbps UART baud rate SMCLK must run at 24 */
/* MHz or faster. */
#define SMCLK_SOURCE HSMCLK_SOURCE
#define SMCLK_DIVIDER 2
#define SMCLK_FREQUENCY ((HSMCLK_FREQUENCY * HSMCLK_DIVIDER) / SMCLK_DIVIDER)
/* The following macros are used to concatenate macro values. */
#define CONCAT_(A,B) A##B
#define CONCAT(A,B) CONCAT_(A,B)
/* The following constants define interrupt priorities used by this */
/* module. Note that the there are 8 bits used to set the priority */
/* level, but only the upper 3 bits are currently used by MSP432 */
/* MCUs, please see the MSP432 Technical Reference Manual and the */
/* MSP432 Driver Library's User's Guide for more information. */
#define PRIORITY_HIGH (0)
#define PRIORITY_NORMAL (1 << 5)
/* The following function configures the system clocks. */
static void ConfigureClocks(void)
{
/* Configure the HFXT external oscillator pins. */
GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ, GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
/* Set the external clock source frequencies for LFXTCLK and HFXTCLK.*/
/* Note that we haven't configured LFXTCLK so we set it to 0 here. */
CS_setExternalClockSourceFrequency(0, 48000000);
/* Starting HFXT in non-bypass mode without a timeout. Before we */
/* start we have to change VCORE to 1 to support the 48 MHz */
/* frequency. */
PCM_setCoreVoltageLevel(PCM_VCORE1);
FlashCtl_setWaitState(FLASH_BANK0, 2);
FlashCtl_setWaitState(FLASH_BANK1, 2);
CS_startHFXT(false);
/* Initialize the clock sources. */
CS_initClockSignal(CS_MCLK, MCLK_SOURCE, CONCAT(CS_CLOCK_DIVIDER_,MCLK_DIVIDER));
CS_initClockSignal(CS_HSMCLK, HSMCLK_SOURCE, CONCAT(CS_CLOCK_DIVIDER_,HSMCLK_DIVIDER));
CS_initClockSignal(CS_SMCLK, SMCLK_SOURCE, CONCAT(CS_CLOCK_DIVIDER_,SMCLK_DIVIDER));
}
void Port_Handler_Test_ISR(void)
{
uint_fast16_t interrupts;
interrupts = GPIO_getEnabledInterruptStatus(GPIO_PORT_P1);
if(interrupts & GPIO_PIN1)
{
GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1);
}
interrupts = GPIO_getEnabledInterruptStatus(GPIO_PORT_P2);
if(interrupts & GPIO_PIN2)
{
GPIO_clearInterruptFlag(GPIO_PORT_P2, GPIO_PIN2);
}
if(interrupts & GPIO_PIN0)
{
GPIO_clearInterruptFlag(GPIO_PORT_P2, GPIO_PIN0);
}
}
int main(void)
{
/* Hold the Watchdog Timer. */
WDT_A_holdTimer();
/* Disable interrupts. */
Interrupt_disableMaster();
/* Configure the clocks. */
ConfigureClocks();
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN1);
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P2, GPIO_PIN2);
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P2, GPIO_PIN0);
GPIO_interruptEdgeSelect(GPIO_PORT_P1, GPIO_PIN1, GPIO_HIGH_TO_LOW_TRANSITION);
GPIO_interruptEdgeSelect(GPIO_PORT_P2, GPIO_PIN2, GPIO_HIGH_TO_LOW_TRANSITION);
GPIO_interruptEdgeSelect(GPIO_PORT_P2, GPIO_PIN0, GPIO_HIGH_TO_LOW_TRANSITION);
Interrupt_setPriority(INT_PORT1, 0xC0);
Interrupt_setPriority(INT_PORT2, 0xC0);
GPIO_registerInterrupt(GPIO_PORT_P1, Port_Handler_Test_ISR);
GPIO_registerInterrupt(GPIO_PORT_P2, Port_Handler_Test_ISR);
GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN1);
GPIO_enableInterrupt(GPIO_PORT_P2, GPIO_PIN2);
GPIO_enableInterrupt(GPIO_PORT_P2, GPIO_PIN0);
GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1);
GPIO_clearInterruptFlag(GPIO_PORT_P2, GPIO_PIN2);
GPIO_clearInterruptFlag(GPIO_PORT_P2, GPIO_PIN0);
Interrupt_enableMaster();
while(1);
}
My startup_MSP432P4.s file points to Port_Handler_Test_ISR for both Port1 and port 2 ISR vectors (although I don't think this is necessary due to the GPIO_registerInterrupt calls. I feel like I must be missing something obvious.
Thanks in advance for the help