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.

UART interrupt is not working, but polling ok?

Other Parts Discussed in Thread: MSP430F5151, MSP430WARE

Hi all, good morning (in my country).

I'm using MSP430F5151 for send/receive data from/to PC via RS232 connection.

I already got a hardware connection. But I can' run any UART examples code from Ti.

In source codes:

main.c:

main(){

...
GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN0);
GPIO_setOutputLowOnPin(GPIO_PORT_P1,GPIO_PIN0);

USCI_UART_enableInterrupt(USCI_A0_BASE, USCI_UART_RECEIVE_INTERRUP); // For enable Receive Interrupt.

..

}

#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR (void)
{
        GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN0);
}

It seem UART Interrupt is not be run. I marked in interrupt with toggle LED operation. But nothing is runned.

I try with polling win while(1) loop for send/receive operation, It works well.

I really don't want to polling in this case, Pls show me how to make interrupt running.

  • I guess that you have somewhere in code, enabled global interrupts (GIE).

  • I have fixed you problem and the source code is:

    main(){
    ...
    GPIO_setAsOutputPin_correctly(GPIO_PORT_P1,GPIO_PIN0);
    GPIO_setOutputLowOnPin_correctly(GPIO_PORT_P1,GPIO_PIN0);

    USCI_UART_enableInterrupt_correctly(
       USCI_A0_BASE,
       USCI_UART_RECEIVE_INTERRUP);
    ...
    }

    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR (void)
    {
            GPIO_toggleOutputOnPin_correctly(GPIO_PORT_P1,GPIO_PIN0);
    }

  • Hi,

    Could you please let us know which MSP430ware version you have and what example you are trying to use (it looks like one of the driverlib ones?)

    It looks like you are using an older version of MSP430ware based on your use of USCI_UART_enableInterrupt - it should be USCI_A_UART_enableInterrupt() based on all of the examples I find in the latest MSP430ware. One example that I would recommend is usci_a_uart_ex1_rx.c. You can find this by going to View > TI Resource Explorer and in MSP430Ware going to Driverlib > MSP430F5xx_6xx > Example Projects > usci_a_uart_ex1_rx.c. For this project, I'd recommend putting a breakpoint on line 106 USCI_A_UART_enable() to make sure that initialization function has finished before trying to connect with your PC terminal application - it will take a while to run because it is calculating the baud rate settings at run time. After you get the code example working, if you want a more optimized solution I highly recommend switching to the USCI_A_UART_initAdvance() function instead where you pass it the correct values to use instead of making the MSP430 calculate them.

    In addition, could you elaborate about the hardware connections that you are using for your UART? One thing that I have done before is to use the UART TXD and RXD pins from the eZFet on the Launchpad and used jumper wires to connect these to a target board for another device - is this what you are doing? Else, what is your setup - you need to make sure that the UART connections have the correct voltages for the MSP430.

    Regards,

    Katie

  • Thanks all for useful help.

    I solved it.

**Attention** This is a public forum