Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 239515

Forum Post: MSP430FG4619 Puzzling UART problem

$
0
0

Good Evening,

I am having a puzzling problem with the UART on the MSP430FG4619, with an MSP430xG461xIPZ100 development board. I am trying to communicate between two Xbee 802.15.4 modules using the MSP430FG4619. These modules are configured correctly to transmit data between them and their operation has been verified with an oscilloscope.  They are configured for 9600 baud, no parity, single start and stop bits. I am using the X-CTU software provided by the Xbee distributors (digi.com) to configure and test the Xbee communication.

I wrote a program in Code Composer (v 5.5.0) to have the MSP430 send a UART byte using USART1 (pins 62 and 63) to the Xbee module and recieve the byte via the console window on the X-CTU software. Each Byte I transmitted was displayed correctly in the console window. I sent easlily recognized scope patterns 0F and 55 and also verified its operation with a scope.

However, when I tried the process in reverse, I ran into difficulty. I wrote a program to echo received data on the  MCU back to the X-CTU console window when it was received from the X-CTU software. Basically, X-CTU would send a byte, the MCU would receive it, and transmit it back to the X-CTU console window. The echo worked, but the data transmitted back was not the same as received. Also, each time I sent a byte a different byte was returned. Sometimes, the echo was correct, but most of the time it was not. I think it is a problem with my Recieve UART interrupt, or it could be baud rate, but that was verified using a scope. Here is my code.

//This program tests the UART connection with an echo from X-CTU software to the MCU

#include <msp430.h>

void UART2_Initialization(void);

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT

_enable_interrupt();

UART2_Initialization(); // Initialize USART

     while (1)
    {

     x++;  //continuously increments an integer while waiting for UART data

     }

}

#pragma vector=USART1TX_VECTOR
__interrupt void USART1_tx (void)
{
while(!TXEPT); //wait for Transmit Buf to empty
IFG2 &= 0xDF; //Clear Transmit flag in USART1
}

#pragma vector=USART1RX_VECTOR
__interrupt void USART1_rx (void)
{
TXBUF1 = RXBUF1;   //echo back received byte
}

//Initialization Function

void UART2_Initialization(void)
{
P4SEL |= 0x03; // P4.1,0 = USART1 TXD/RXD
ME2 |= 0x30; // Enable USART1 TXD/RXD
U1CTL = 0x10; // 8-bit character
U1TCTL = 0x20 ; // UCLK = SMCLK
U1BR0 = 0x41; // set baud rate
U1BR1 = 0x00; //
U1MCTL = 0x03; // Modulation
U1CTL &= ~SWRST; // Initialize USART state machine
IE2 |= 0x30; // Enable USART1 TX and RX interrupt
IFG2 &= 0xCF; //clear USART1 Interrupt Flags
}

Here is a transcription of my console window showing, transmitted byte followed by echoed byte, delimited by semi-colons

55 FD   ;    55 B7   ;  55 FF    ;    55 C4    ;    55 55   (correct!) ;     55 A9    ;

0F 0F (correct!)   ;   0F 0F  (correct);    0F 8F;    0F FF   ; 0F 1F ; 0F 87;

Any help would be appreciated. Sincerely, Mr. Palmer


Viewing all articles
Browse latest Browse all 239515

Latest Images

Trending Articles



Latest Images