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.

MSP-EXP432P401R: Interrupts not detected on Port 2

Part Number: MSP-EXP432P401R


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

  • Here's a "is your computer plugged in?" kind of suggestion: Which side of JP9/JP11 did you connect your switches to? I'm pretty sure it should be the side nearest the MCU, but it's a quick test to just try both.

    [Edit: I finally found my Launchpad. You want the side closer to the MCU. When I do that your program interrupts as expected.]

  • Thanks for the thought.  I had tried on both sides with no luck.  On the side nearest the MCU, I can scope and see the line idle high and then be pulled down with the button press.

    It seems like hardware is suspect given that you were able to get the expected result with the above code, but I'm also able to repeat this issue on 2 copies of custom hardware.  Is there a compile option or something that I'm missing? 

    Thanks for the help

  • I didn't do anything special in the Project Settings. My test case was a jumper wire and a breakpoint in the ISR. My driverlib source is, uh, "unknown provenance", but probably < 2 years old.

    If you can see the transition at the pin, I would be following the chain up. Pausing the debugger:

    1) P2->IN and P2->IFG: Did the port see it?

    2) ISER[1].4 and ISPR[1].4 should be set (PORT2_IRQn=36=(32+4)): Did the NVIC see it?

    3) PRIMASK=0: Did the CPU see it?

    When you pause, make note of where it pauses. We expect it's at the while(1) but maybe it got lost somewhere.

    [Edit: Um, how about 2.5 years (MSPWare_3_30_01_00)? I just used driverlib_empty_project_with_source from SDK 3_20_00_06 and got the same result.]

  • It was old drivers!

    I performed the test you recommended with my original setup, and all the registers looked to be set appropriately, except I would just never see the interrupt flag get set.  

    I had been modifying a sample project using the CC256x MSP432 Bluetopia SDK, which turns out is using old drivers.  I updated to the latest v3_21_00_05 and now things are working as expected! 

    Thanks for all the help!

**Attention** This is a public forum