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/MSP430F67641A: UART interrupt is not triggering

Part Number: MSP430F67641A


Tool/software: TI C/C++ Compiler

Dear sir,

i am using MCLK_DEF 16

UCA2CTLW0 |= UCSWRST;                   // **Put state machine in reset**
    UCA2CTLW0 |= UCSSEL_2;                  // CLK = ACLK
    #if MCLK_DEF == 12
    UCA2BRW_L = 0x1E;                       //
    UCA2BRW_H = 0x05;                       //
    UCA2MCTLW = 0x5D00;                     // 
    #endif
    
   #if MCLK_DEF == 16
    UCA2BRW_L = 0xD3;                       // 
    UCA2BRW_H = 0x06;                       //
    UCA2MCTLW = 0x0500;                     // 
   #endif
    UCA2CTLW0 &= ~UCSWRST;                  // **Initialize USCI state machine**
    UCA2IE |= UCRXIE; 

  P2SEL|= BIT2 + BIT3; 



#pragma vector=USCI_A2_VECTOR
__interrupt void USCI_A2_ISR(void)
{

}

my issue is my uart interrupt is not triggering  i have selected this pins as pheripheral  P2SEL|= BIT2 + BIT3; 

my uart configuration is above ...

suggest me the answer as soon as possible because i m running out of time on this project ..

  • Hello Satish,

    In the future, please post your code using the Syntax Highlighter icon below. Without it, the code is hard to read and there's probably a lower chance that our community members will look through it and provide recommendations. I went ahead and fixed your initial post above.

    Regarding your question, I don't see where you enable global interrupts. Also, it looks like you're using ACLK, but I don't see any XT1 setup code. So, there could be an oscillator fault flag that doesn't get cleared.

    satish sharma13 said:
    my issue is my uart interrupt is not triggering  i have selected this pins as pheripheral  P2SEL|= BIT2 + BIT3; 

    Where does the code halt? Are your UART connections correct? Initialize your pins before configuring the UART module.

    satish sharma13 said:
    suggest me the answer as soon as possible because i m running out of time on this project ..

    I would highly recommend using one of our code examples as a reference. If it works, add your changes piece-by-piece until something doesn't work. Then, figure out why that change causes the issue. Preferably, you won't have any issues if all the changes are correct.

    msp430f67641A_uscia0_uart_03.c

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2013, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430F67641A Demo - USCI_A0, Ultra-Low Power UART 9600 Echo ISR, 32kHz ACLK
    //
    //   Description: Echo a received character, RX ISR used. Normal mode is LPM3,
    //   USCI_A0 RX interrupt triggers TX Echo.
    //   ACLK = 32768Hz crystal, MCLK = SMCLK = DCO ~1.045MHz
    //   Baud rate divider with 32768Hz XTAL @9600 = 32768Hz/9600 = 3.41
    //   See User Guide for baud rate divider table
    //
    //
    //               MSP430F67641A
    //             -----------------
    //        /|\ |              XIN|-
    //         |  |                 | 32kHz
    //         ---|RST          XOUT|-
    //            |                 |
    //            |     P1.3/UCA0TXD|------------>
    //            |                 | 9600 - 8N1
    //            |     P1.2/UCA0RXD|<------------
    //
    //  E. Chen
    //  Texas Instruments Inc.
    //  January 2015
    //  Built with CCS Version: 5.5.0 and IAR Embedded Workbench Version: 5.52
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop WDT
    
        // Setup P1.2 UCA0RXD, P1.3 UCA0TXD
        P1SEL |= BIT2 | BIT3;                   // Set P1.2, P1.3 to non-IO
        P1DIR |= BIT2 | BIT3;                   // Enable UCA0RXD, UCA0TXD
    
        // Setup LFXT1
        UCSCTL6 &= ~(XT1OFF);                   // XT1 On
        UCSCTL6 |= XCAP_3;                      // Internal load cap
        // Loop until XT1 fault flag is cleared
        do
        {
            UCSCTL7 &= ~(XT2OFFG | XT1LFOFFG | DCOFFG);
            // Clear XT2,XT1,DCO fault flags
            SFRIFG1 &= ~OFIFG;                  // Clear fault flags
        } while (SFRIFG1 & OFIFG);              // Test oscillator fault flag
    
        // Setup eUSCI_A0
        UCA0CTLW0 |= UCSWRST;                   // **Put state machine in reset**
        UCA0CTLW0 |= UCSSEL_1;                  // CLK = ACLK
        UCA0BRW_L = 0x03;                       // 32kHz/9600=3.41 (see User's Guide)
        UCA0BRW_H = 0x00;                       //
        UCA0MCTLW = 0x5300;                     // Modulation UCBRSx=0x53, UCBRFx=0
        UCA0CTLW0 &= ~UCSWRST;                  // **Initialize USCI state machine**
        UCA0IE |= UCRXIE;                       // Enable USCI_A0 RX interrupt
    
        __bis_SR_register(LPM3_bits | GIE);     // Enter LPM3, interrupts enabled
        __no_operation();                       // For debugger
    }
    
    // USCI_A0 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
        switch (__even_in_range(UCA0IV, 4))
        {
            case USCI_NONE: break;              // No interrupt
            case USCI_UART_UCRXIFG:             // RXIFG
                while (!(UCA0IFG & UCTXIFG)) ;  // USCI_A0 TX buffer ready?
                UCA0TXBUF = UCA0RXBUF;          // TX -> RXed character
                break;
            case USCI_UART_UCTXIFG: break;      // TXIFG
            case USCI_UART_UCSTTIFG: break;     // TTIFG
            case USCI_UART_UCTXCPTIFG: break;   // TXCPTIFG
            default: break;
        }
    }

    Regards,

    James

  • dear sir,

    i am using uca2rxd module for reception of data ...which is pin number p2.2..

    and i give some voltage which is 3.2v through a register to this pin it is going to zero means voltage accross this is zero..

  • satish sharma13 said:
    i am using uca2rxd module for reception of data ...which is pin number p2.2..

    Sure, so just change the code in the code example above to use P2.2.

    satish sharma13 said:
    and i give some voltage which is 3.2v through a register to this pin it is going to zero means voltage accross this is zero..

    I'm sorry but this doesn't make any sense. Are you trying to manually trigger something using a rising/falling edge? I think it would be easier to test a UART code example with a USB-to-serial adapter connected to the UART pins instead.

    Regards,

    James

**Attention** This is a public forum