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.

CCS/EVM430-F6736: UART problem

Part Number: EVM430-F6736

Tool/software: Code Composer Studio

Hi all,

I'm working with EVM430F6736 controller board. I want to communicate the data from this board to arduino due using UART. For transmitting the data from energy meter board to arduino due is working fine. In receiver side of energy meter board doesn't get the data from arduino due. I confirmed that arduino due send the data to energy meter board. 

Check the EUSCI_A0 serial port configuration,

port configuration : 1.2 UART rx0, 1.3 UART tx0

P1DIR = BIT3;

P1SEL = BIT2 | BIT3;

P1OUT = 0;

UART settings :

UCA0CTL1 = UCSWRST | UCSSEL_2;          // SMCLK : 24MHz clock frequency , baud rate : 9600

UCA0CTL0 = 0;                  // 8 bit data, no parity, 1 stop bit

Baud rate generation setting for baud rate : 9600, 24MHz clock

UCA0BRW = 0xA3D;

UCA0MCTLW = 0x5500;

UCA0CTLW1 =0x0003;  /*receiver Glitch Suppression(time 70 to 200ns)*/

 UCA0TXBUF = 0;

 UCA0CTL1 &= ~UCSWRST;

 UCA0IE |= UCRXIE;

 

 

I have the problem in receiver interrupt. I am not getting any receiver interrupt response.

My questions

1] Whether my UART initialization is right for receiving Interrupt?.

2] Is it their any problem because of having receiver glitch suppression time(70 to 200 ns)?, I try to change the glitch time as per datasheet but it is not changed, so how to change it?.

3] Whether my baudrate generation setting is correct or not for 9600,24MHZ clock?.

 

 

 

 

 

  • Hello,

    user5961265 said:
    1] Whether my UART initialization is right for receiving Interrupt?.

    P1DIR = BIT3 should be P1DIR |= BIT2 | BIT3. I would encourage you to look at our code examples as a reference, such as 'MSP430F6734X_USCIA0_UART_03.c' shown below.

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, 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--*/
    //******************************************************************************
    //   MSP430F673x 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
    //
    //
    //                MSP430F673x
    //             -----------------
    //        /|\ |              XIN|-
    //         |  |                 | 32kHz
    //         ---|RST          XOUT|-
    //            |                 |
    //            |     P1.3/UCA0TXD|------------>
    //            |                 | 9600 - 8N1
    //            |     P1.2/UCA0RXD|<------------
    //
    //  M. Swanson
    //  Texas Instruments Inc.
    //  December 2011
    //  Built with CCS Version: 5.1.0 and IAR Embedded Workbench Version: 5.40.1
    //******************************************************************************
    #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;
        }
    }

    user5961265 said:
    2] Is it their any problem because of having receiver glitch suppression time(70 to 200 ns)?, I try to change the glitch time as per datasheet but it is not changed, so how to change it?.

    Doubtful at this point. It's more likely an incorrect port configuration or incorrect baud rate setting.

    user5961265 said:
    3] Whether my baudrate generation setting is correct or not for 9600,24MHZ clock?.

    If you know your clock is running at 24MHz and you want a baud rate of 9600, you can use the baud rate calculator and the user's guide to figure out the correct settings. Also, I'd recommend using a logic analyzer or oscilloscope to measure the baud rate. If you're communicating with the Arduino, then the baud rate should be right. Change the port configuration and see if that helps.

    Regards,

    James

**Attention** This is a public forum