Using embedded proggraming, Code Composer Studio 6.0.1,

Trying to configurate UART to communicate between MSP430F6736A and my PC. Using USB/RS485 converver(2 vire (A,B)).

For sending data using HERCULES(app for testing communication).

         #include <msp430.h> 
            #include <msp430f6736.h>
             * main.c

            int main(void) {

                WDTCTL = WDTPW | WDTHOLD;   // Stop watchdog timer

                P4DIR |= BIT6;
                        P4OUT &= ~BIT6;
                //UCSCTL0 |= DCO_0 | MOD_0;
                //UCSCTL1 |= DCORSEL_0;

                // Config pinov  P2.2 a P2.3 na ich funkciu(Rx a Tx)
                P2SEL |= BIT2 + BIT3; // RX and TX pins

                // config comm
                UCA1CTLW0 |= UCSWRST; // reset UCA1 for config
                UCA1CTLW0 |= UCSSEL_1 ; //  ACLK as source clock
                UCA1MCTLW |= UCBRS0;

                // Baudrate from datasheet
                UCA1BR0 = 1;    // 1200 Baud
                UCA1BR1 = 11;   // 1200 Baud

                UCA1CTLW0 &= ~UCSWRST; // UCA1 back from  reset

                // interrupts enabled for RT and TX
                UCA1IE |= UCTXIE | UCTXIE;

                __bis_SR_register(GIE); // global interupt enabled


#pragma vector=USCI_A1_VECTOR
__interrupt void    Recieve_ISR(void)
    while  (!UCA1IFG)    //  USCI_A0 TX  buffer  ready?
    P4DIR |= BIT6;
    P4OUT &= ~BIT6;
    UCA1RXBUF  =  UCA1TXBUF;    //  TX  -&amp;gt;   RXed    character

All I want is when I send data(for eample number 5) from HERCULES(config same: 1200 baud, no parity, 1 stop bit) I want to receive them and turn LED on. But it doesn´t work.

Somewhere in this code is something missing or something bad written. , . I got big head from datasheets so can anyone help me?

  • \$\begingroup\$ UCA1IV does not contain interrupt flags. \$\endgroup\$
    – CL.
    Apr 8, 2016 at 11:05
  • \$\begingroup\$ deleted it and still not working \$\endgroup\$
    – user5939530
    Apr 8, 2016 at 11:26
  • \$\begingroup\$ No! You must use the register that does contain the interrupt flags. \$\endgroup\$
    – CL.
    Apr 8, 2016 at 11:29
  • \$\begingroup\$ in datasheet there is no other register for interrupt flags just UCA1IFG \$\endgroup\$
    – user5939530
    Apr 8, 2016 at 11:59

1 Answer 1


The entire interrupt handler function is wrong.

    while  (!(UCA1IFG & UCA1IV));    //  UCA1 TX  buffer  ready?

UCA1IV is a vector register, not an interrupt flag. To wait for the TX buffer being ready, you must check for the UCTXIFG bit being set.


This line happens to be correct.


Accessing registers has side effects. Reading UCA1TXBUF might actually work, but reading UCA0RXBUF removes the next byte from the buffer, if it exists.

And this comparison does not make sense; you echoed the received byte in the previous line, so this condition, if it worked, would always be true.

        P4DIR |= BIT6;

You do not need to reinitialize this bit.

        P4OUT &= ~BIT6; // turn on LED

This does not change the state of the LED, because the bit has the same value you initialized it with.

The interrupt function should look somewhat like this:

    while (!(UCA1IFG & UCTXIFG));    // UCA1 TX buffer ready?
    P4OUT ^= BIT6; // toggle LED
  • \$\begingroup\$ I eddited code(look up), but still no working. May be problem with Baudrate. As source I choosed ACLK which is 32 768kHz. And i want to have 1200 Baud. Is my configuration good for this ? \$\endgroup\$
    – user5939530
    Apr 8, 2016 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.