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.

Compiler/MSP430FR2676: MSP430FR2676 locking up on a switch input interrupt.

Part Number: MSP430FR2676


Tool/software: TI C/C++ Compiler

I have a MSP430FR2676 processor that I am using on a dev kit that is giving me some bizarre behavior.
I have a switch input set up to fire off an interrupt on a HIGH TO LOW transition. I have code that will check the status of the interrupt using the GPIO_getInterruptStatus() API to check it, and the GPIO_clearInterrupt() API call to clear it.
All of the above works just as I designed it, no problems.
I then introduced the UART into the project to print out simple debug serial messages (I connected a 3.3V to RS232 pod to the uart pins and connected the pod to tera-term to view the messages).
I use the UART_openPort() API to open the port, and UART_transmitBuffer() to print out the messages.
This also works as designed, no problems.
The problem occurs when I press a button to fire off the interrupt, the program locks up and jumps to the "isr_trap".

Through various edits, I removed every UART_transmitBuffer() except for one that occurs right before the main loop (so NO OTHER UART print statements are occurring throughout the program).
Even with only one of the UART_transmitBuffer() called at the beginning of the program, I still get the lockup.
Is there something I don't have configured correctly in this project?
Is this a known issue?
Any help is greatly appeciated!
Thanks in advance!!
  • Going to isr_trap means you got an interrupt which doesn't have an ISR. One way to do this is to make a typo in the vector= name; this will get a warning, but you might not notice.

    Can you post or attach your code?

  • Thanks for the Response!!

    When you mentioned: "One way to do this is to make a typo in the vector= name; this will get a warning, but you might not notice."
    Where exactly do I add that?

    Also, here is my code, if you see something that stands out (Or, if you need to see more code from a function), please let me know - Thanks!!!

    ===================
    Main.c:
    ===================

    void main(void)
    {
        /* Set the watchdog timer */
        WDTCTL = WDTPW | WDTHOLD;

        /* Initialize the MCU:
        BSP_configureMCU() sets up the device IO and clocking
        The global interrupt enable is set to allow peripherals
        to wake the MCU. */
        BSP_configureMCU();

        /* open the port for communication */
        UART_openPort(&UARTPort);

        /* Setup LED pins */
        GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN7);
        GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN6);
        GPIO_setAsOutputPin(GPIO_PORT_P5, GPIO_PIN7);

        /* LED initial settings */
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN7);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        GPIO_setOutputLowOnPin(GPIO_PORT_P5, GPIO_PIN7);

        /* Configure buttons */
        buttonConfigure();

        static uint32_t delayCounter = 0;
        static uint16_t loopCounter = 0;

        /* When this is in, CRASH!! */
        static uint8_t msg[] = {"Program Start"};
        UART_transmitBuffer(msg, sizeof(msg));

        /*  Main Loop */
        while(1)
        {
            /* Process the Buttons */
            buttonProcess();

            if (delayCounter++ > MAX_COUNTER)
            {
                delayCounter = 0;
                GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN6);

                loopCounter++;
            }
        }
    }


    ===================
    Button.c
    ===================

    void buttonConfigure( void )
    {
        GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P5, GPIO_PIN3);

        /* Set the edge */
        GPIO_selectInterruptEdge(GPIO_PORT_P5, GPIO_PIN3, GPIO_HIGH_TO_LOW_TRANSITION);

        /* Enable the interrupts for this port/pin */
        GPIO_enableInterrupt(GPIO_PORT_P5, GPIO_PIN3);

        /* Clear the interrupt */
        GPIO_clearInterrupt(GPIO_PORT_P5, GPIO_PIN3);
    }

    void buttonProcess( void )
    {
        /* Clear the bitmap */
        buttonInterruptStatusVal = 0x0000;

        buttonInterruptStatusVal = GPIO_getInterruptStatus(GPIO_PORT_P5, GPIO_PIN3);

        /* Check if a button was pressed */
        if (buttonInterruptStatusVal)
        {
            GPIO_clearInterrupt(GPIO_PORT_P5, GPIO_PIN3);

            /* Toggle LED */
            GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN7);
        }
    }


    ===================
    Structure for UART setup:
    ===================

    //Sets all the parameters for UART transmission
    const tUARTPort UARTPort =
    {
         //does not receive messages, so no callback needed
        .pbReceiveCallback = NULL,

        //does not receive messages, so no callback needed
        .pbErrorCallback = 0,

        //choose clock source
        .peripheralParameters.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,

        //clockPrescalar is UCBRx = int(N / 16), where N = clock_frequency / baud_rate
        // N = 2000000 / 115200 = 17.36111
        //int(N / 16) = int(17.36111 / 16) = int(1.0850694) = 1;
        .peripheralParameters.clockPrescalar = SMCLK_FREQ_MHZ * 1000000 / 115200 / 16,

        //controls UCBRF bits for oversampling mode
        //UCBRF = int(((N/16) - int(N/16)) * 16) = int(((17.36111/16) - int(17.36111/16)) * 16) = int(1.36111) = 1
        .peripheralParameters.firstModReg = 1,

        //consult table 22-4 in the user's guide to find the register value corresponding to UCBRF number
        //fraction portion of N = 0.36111
        //in the table, 0.36111 <---> 0x4A or 0x52
        .peripheralParameters.secondModReg = 0x4A,


        //controls parity bit - NOTE the eZ-FET does not support a parity bit
        .peripheralParameters.parity = EUSCI_A_UART_NO_PARITY,

        //least or most significant bit first
        .peripheralParameters.msborLsbFirst = EUSCI_A_UART_LSB_FIRST,

        //select either one or two stop bits
        .peripheralParameters.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT,

        //select whether to use multiprocessor/autobaud modes
        .peripheralParameters.uartMode = EUSCI_A_UART_MODE,

        //selects oversampling vs low-freq baud rate modes
        .peripheralParameters.overSampling = EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION

    };

  • To answer your question: You can define an ISR (Interrupt Service Routine) using "#pragma vector=<something>_VECTOR" and the __interrupt keyword.

    But I don't think you want to do that. This code (buttonProcess) is polling the interrupt flags (IFG). That's fine, but in that case you should Not enable those interrupts (IE). The IFG bits are set independent of their corresponding IE bits. (It is routine to see IFG bits set for events you don't care about.)

    Summary: Remove this line:

    >    GPIO_enableInterrupt(GPIO_PORT_P5, GPIO_PIN3);

  • Thanks for the response!

    I removed the GPIO_enableinterrupt line and everything is working much better.

    Thanks!!

**Attention** This is a public forum