EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

UART confusion on the FG4618

Started by Darren Logan March 7, 2008
Hi all,

I'm a little confused over the UART situation on an FG4618.

On pins 2.4 & 2.5, you have UCA0TXD and UCA0RXD respectively.

But, you also have the same UCA0TXD and UCA0RXD on pins 4.6 & 4.7!

Why are they labelled the same? :-/

I want to use the 2.4 and 2.5 in UART mode, and I "think" i've written the correct setup code (IAR below),
but the Rx interrupt isn't triggering. Can you see anything obvious please?

UCA0CTL0 = 0x00; /* 8-bit character, no parity, 1 stop bit */
UCA0CTL1 = UCSSEL1; /* use SMCLK (watch crystal driven on XT1) */
UCA0MCTL = 0x00; /* Modulation Control */
IE2 |= UCA0RXIE; /* Enable USART0 RX interrupt */

P2SEL |= 0x30; /* P2.4, 2.5 = USART0 TXD/RXD */
P2DIR |= 16;

ME2 = 0x30;

#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCIAB0RX_ISR(void)
{

/* i'm lonely :-( */

}

Thanks!

Vbr,
Darren

Beginning Microcontrollers with the MSP430

>>On pins 2.4 & 2.5, you have UCA0TXD and UCA0RXD respectively.
>>But, you also have the same UCA0TXD and UCA0RXD on pins 4.6 & 4.7!
>>Why are they labelled the same? :-/

The pins can be allocated to different functions. Specifically in this case,
you could use the Port 4 pins for general I/O, Universal Serial
Communication [includes a UART but also more than just that], and as a
segment driver for an LCD. Port 2 on the other hand can be a general I/O, an
interrupt pin or access to the same USC as on port 4. So in a nut shell, you
determine which port pins to use as the interface to the USC.

>>I want to use the 2.4 and 2.5 in UART mode, and I "think" i've written the
correct setup code (IAR below),
>>but the Rx interrupt isn't triggering. Can you see anything obvious
please?

It is what I don't see that is obvious. How do you have SMCLK configured? It
is based off of the DCO. The DCO is based off of the FLL using the Watch
crystal.

As an example, here is a PORTION of a clock init routine that establishes
the DCO at ~3.2MHz with SMCLK = DCO.

// MCLK = DCO, SMCLK = DCO, ACLK divider = 1

SCFI0 = 0x00; // Clear System Clock Frequency Integrator Register 0

// FLL+ loop divider = 1, DCO Range Control = 0

SCFI1 = 0x00; // Clear System Clock Frequency Integrator Register 1

SCFQCTL = 0x00; // Clear System Clock Control Register

SCFQCTL = 0x61; // Set Clock [98+1] * 32768 = 3,244,032 Hz

Now the other obvious omission; the Baud Rate. In the following routine, the
USC is set as a UART to communicate with the TUSB3410 at a baud rate of
460,800bps. It uses the DCO / SMCLK values above. Do not just assume your
modulation values will be zero. That is a function of the baud rate and
SMCLK clock frequency. As is always the case, the example provided is set to
work with specific values. Changing them to fit your criteria will require
some additional gray matter.

//--
----

void InitUART(void){

// Setup of UART 0 - TUSB3410 Interface Port 2 pins 4&5

UCA0CTL1 = UCSWRST; // To set hold the module in reset

UCA0CTL1 |= UCSSEL0 + UCSSEL1; // UCLK = SMCLK

UCA0BR0 = 0x07; // 3,244,032 MHz / 460,800 = ~7.04

UCA0BR1 = 0x00; // 3,244,032 MHz / 460,800 = ~7.04

UCA0MCTL = 0x00; // Second modulation stage values

UCA0CTL1 &= ~UCSWRST; // Release USCI from Reset

IE2 |= UCA0RXIE; // Enable USART0 RX interrupt

}

//--
----

This should get you going.

Thanks,

Jim

_____

From: m... [mailto:m...] On Behalf Of
Darren Logan
Sent: Friday, March 07, 2008 6:19 AM
To: m...
Subject: [msp430] UART confusion on the FG4618
Importance: High

Hi all,

I'm a little confused over the UART situation on an FG4618.

On pins 2.4 & 2.5, you have UCA0TXD and UCA0RXD respectively.

But, you also have the same UCA0TXD and UCA0RXD on pins 4.6 & 4.7!

Why are they labelled the same? :-/

I want to use the 2.4 and 2.5 in UART mode, and I "think" i've written the
correct setup code (IAR below),
but the Rx interrupt isn't triggering. Can you see anything obvious please?
UCA0CTL0 = 0x00; /* 8-bit character, no parity, 1 stop bit */
UCA0CTL1 = UCSSEL1; /* use SMCLK (watch crystal driven on XT1) */
UCA0MCTL = 0x00; /* Modulation Control */
IE2 |= UCA0RXIE; /* Enable USART0 RX interrupt */

P2SEL |= 0x30; /* P2.4, 2.5 = USART0 TXD/RXD */
P2DIR |= 16;

ME2 = 0x30;

#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCIAB0RX_ISR(void)
{

/* i'm lonely :-( */

}

Thanks!

Vbr,
Darren

The 2024 Embedded Online Conference