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.

msp430f2618 UART with USCI_A1 module



#include  "msp430x26x.h"

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If calibration constants erased
// do not load, trap CPU!!
}
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
UCA1CTL1|= UCSWRST; // **Initialize USCI state machine**
UCA1CTL0 &= ~UCSYNC; //UART mode selected

P3SEL = 0xC0; // P3.6,7 = USCI_A1 TXD/RXD
UCA1CTL1 |= UCSSEL_2; // CLK = SMCLK
UCA1BR0 = 0x6D; // 9600 (see User's Guide)
UCA1BR1 = 0x00; //
UCA1MCTL = 0x04; // Modulation UCBRSx = 3
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UC1IE |= UCA1RXIE; // Enable USCI_A1 RX interrupt

__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}

// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB1RX_VECTOR
__interrupt void USCI1RX_ISR(void)
{
while (!(UC1IFG&UCA1TXIFG)); // USCI_A1 TX buffer ready?
UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
}


the code is written for USCI UART A1 module that receives and loops back the received data.it is configured on 9600 baudrate
the problem is that the UART is not receiving any byte of data passed using hyperterminal and hence not no interrupt is raised.
USCI_A0  module is working but when configured for USCI_A1 it is not working. 
Please tell me why?

  • Hello Ganesh,

    did you configure the Digital I/O Pins correctly? I do not think they are configured to use peripheral modules by default.

    Also the direction has to be set (input/output) for proper function, as setting PxSELx = 1 does not automatically set the pin direction.

    Regards Marco

  • How did you connect the MSP to the PC?

    PC COM port (and most USB->serial converters) uses RS232 signals (inverted symmetric signals) and MSP uses TTL signals (0/3.3V non-inverted)..

    Also MSPs RX and PCs TxD need to be connected, not RX and RxD.

  • It doesn't work because you configured the pin setting "P3SEL" which is for A0, you have to configure for P5SEL to use the UCA1 instead.

    /jakob

  • Jakob Uhlin1 said:
    It doesn't work because you configured the pin setting "P3SEL" which is for A0,

    While P3.0..5 are for USCIA/B0, P3.6/P3.7 are indeed for USCIA1 RX/TX, so the port setup is correct. P5.0..3 are for USCIB1 and for USCIA1 clock and STE in SPI mode.

    The baudrat esetting is wrong. The used 0x6d is for 1048567Hz. Since the caliration cosntants for 1.0MHz are used, teh baudrate divider should be 0x64, modulation is UCBRS=1 -> UCA1MCTL = 2;

    However, the baudrate error of ~5% shouldn't be large enough to totally block data reception.
    Out of curiosity: does something happen when you set UCRXEIE bit in UCA1CTL1?

**Attention** This is a public forum