EmbeddedRelated.com
Forums

Data Transfer through UART of MSP430FE427

Started by seshuram_vadapalli September 14, 2007
I need to send some data from MSP430FE427 to hyperterminal through
UART.I used the P2.4 as TXD.

The output is always

________^^^^^^^^^}}}}}}}uuuuuu}__________ggggggggvvvvvv
Why I am not getting the given Input as ouptput?

Pl Help me.

regards,
Seshuramv

/********************
main.c
***************************/
main()
{
InitUART(57600);

TX_Mode = tx_cal;

SendString("AAAAAAAAA");
SendString("CCCCCCCCC");
SendString("DDDDDDDD");
SendString("EEEEEEEE");
SendString("AAAAAAAA");
SendString("11111111");
SendString("00000000");

}
/***********************************************************

************************************************************/
void InitUART(unsigned long baud)
{
//UART
// Configure USART in UART mode, 8-bit, 1-stop, no parity.
// Hold logic in reset state while configuring other registers

UCTL0 = (0*PENA) // 7 Parity Enable 0=Disabled
|(0*PEV) // 6 Parity Select 0= Odd
|(0*SPB) // 5 Stop Bit Select 0= 1 Stop bit
|(1*CHAR) // 4 Character Length 1= 8-bit data
|(0*LISTEN) // 3 Loopback control 0= Loopback disabled
|(0*SYNC) // 2 Synchronous Mode 0= UART mode
|(0*MM) // 1 Multiprocessor Mode 0= Idle-line
multiproc control
|(1*SWRST); // 0 Software Reset initially-1 1= Logic
Held in Reset State ...
// while configuring other registers

switch(baud)
{
case 9600:
UTCTL0 = SSEL0; // UCLK = ACLK
UBR00 = 0x03; // 32k/9600
UBR10 = 0x00; //
UMCTL0 = 0x4a; //
break;

case 19200:
UTCTL0 = SSEL1; // UCLK = SMCLK
UBR00 = 0xDA; // 4MHz/19200
UBR10 = 0x00; //
UMCTL0 = 0x55; //
break;
case 57600:
UTCTL0 = SSEL1; // UCLK = SMCLK
UBR00 = 0x48; // UBR00 = 0x48; // 4Mhz/57600
UBR10 = 0x00; //
UMCTL0 = 0x7B; //
break;
case 115200:
UTCTL0 = SSEL1; // UCLK = SMCLK
UBR00 = 0x24; // 4Mhz/115.2k
UBR10 = 0x00; //
UMCTL0 = 0x29; //
break;
case 230400:
UTCTL0 = SSEL1; // UCLK = SMCLK
UBR00=0x12;
UBR10=0x00;
UMCTL0=0x84; /* uart0 4194304Hz 230456bps */
break;

default:
break;
}

U0ME |= UTXE0+URXE0 ; // Enabled USART0 TXD/RXD

P2SEL |= (BIT4 + BIT5); // P2.4,5 = USART0 TXD/RXD
P2DIR |= BIT4; // P2.4 output direction

U0IFG &= UTXIFG0;
// U0IFG &= ~URXIFG0; // Clear USART0 RX interrupt
flag

UCTL0 &= ~(SWRST); //8-bit character - clr SWRST bit

U0IE |= URXIE0+UTXIE0; // Enable USART0 RX + TX
interrupt
// U0IE |= URXIE0; // Enable USART0 RX
interrupt
}

void SendString(const char* ARRAY)
{
int i=0;

while (ARRAY[i]) // transmit " String" via RS232
{
// SendChar(0x11);
SendChar(ARRAY[i]);
i++;
}
}

void SendChar(char ch)
{
while ((U0IFG&UTXIFG0)==0); // wait till TX buf empty
TXBUF0=ch; // transmit ch
}

Beginning Microcontrollers with the MSP430

Hello Seshuram,

Your snippet is incomplete. I can't see where you are initializing the
clock. Probably the baud rate is messed up.

Regards,
Yuliyan

seshuram_vadapalli wrote:
> I need to send some data from MSP430FE427 to hyperterminal through
> UART.I used the P2.4 as TXD.
>
> The output is always
>
> ________^^^^^^^^^}}}}}}}uuuuuu}__________ggggggggvvvvvv
> Why I am not getting the given Input as ouptput?
>
> Pl Help me.
>
> regards,
> Seshuramv
>
> /********************
> main.c
> ***************************/
> main()
> {
> InitUART(57600);
>
> TX_Mode = tx_cal;
>
> SendString("AAAAAAAAA");
> SendString("CCCCCCCCC");
> SendString("DDDDDDDD");
> SendString("EEEEEEEE");
> SendString("AAAAAAAA");
> SendString("11111111");
> SendString("00000000");
>
> }
> /***********************************************************
>
> ************************************************************/
> void InitUART(unsigned long baud)
> {
> //UART
> // Configure USART in UART mode, 8-bit, 1-stop, no parity.
> // Hold logic in reset state while configuring other registers
>
> UCTL0 = (0*PENA) // 7 Parity Enable 0=Disabled
> |(0*PEV) // 6 Parity Select 0= Odd
> |(0*SPB) // 5 Stop Bit Select 0= 1 Stop bit
> |(1*CHAR) // 4 Character Length 1= 8-bit data
> |(0*LISTEN) // 3 Loopback control 0= Loopback disabled
> |(0*SYNC) // 2 Synchronous Mode 0= UART mode
> |(0*MM) // 1 Multiprocessor Mode 0= Idle-line
> multiproc control
> |(1*SWRST); // 0 Software Reset initially-1 1= Logic
> Held in Reset State ...
> // while configuring other registers
>
> switch(baud)
> {
> case 9600:
> UTCTL0 = SSEL0; // UCLK = ACLK
> UBR00 = 0x03; // 32k/9600
> UBR10 = 0x00; //
> UMCTL0 = 0x4a; //
> break;
>
> case 19200:
> UTCTL0 = SSEL1; // UCLK = SMCLK
> UBR00 = 0xDA; // 4MHz/19200
> UBR10 = 0x00; //
> UMCTL0 = 0x55; //
> break;
> case 57600:
> UTCTL0 = SSEL1; // UCLK = SMCLK
> UBR00 = 0x48; // UBR00 = 0x48; // 4Mhz/57600
> UBR10 = 0x00; //
> UMCTL0 = 0x7B; //
> break;
> case 115200:
> UTCTL0 = SSEL1; // UCLK = SMCLK
> UBR00 = 0x24; // 4Mhz/115.2k
> UBR10 = 0x00; //
> UMCTL0 = 0x29; //
> break;
> case 230400:
> UTCTL0 = SSEL1; // UCLK = SMCLK
> UBR00=0x12;
> UBR10=0x00;
> UMCTL0=0x84; /* uart0 4194304Hz 230456bps */
> break;
>
> default:
> break;
> }
>
> U0ME |= UTXE0+URXE0 ; // Enabled USART0 TXD/RXD
>
> P2SEL |= (BIT4 + BIT5); // P2.4,5 = USART0 TXD/RXD
> P2DIR |= BIT4; // P2.4 output direction
>
> U0IFG &= UTXIFG0;
> // U0IFG &= ~URXIFG0; // Clear USART0 RX interrupt
> flag
>
> UCTL0 &= ~(SWRST); //8-bit character - clr SWRST bit
>
> U0IE |= URXIE0+UTXIE0; // Enable USART0 RX + TX
> interrupt
> // U0IE |= URXIE0; // Enable USART0 RX
> interrupt
> }
>
> void SendString(const char* ARRAY)
> {
> int i=0;
>
> while (ARRAY[i]) // transmit " String" via RS232
> {
> // SendChar(0x11);
> SendChar(ARRAY[i]);
> i++;
> }
> }
>
> void SendChar(char ch)
> {
> while ((U0IFG&UTXIFG0)==0); // wait till TX buf empty
> TXBUF0=ch; // transmit ch
> }
>