Dear member !
The first thing which is very obvious, is ur initialization of the
UART. If you read the chapter 12 of the MSP430x1xx user's guide, u
may know more. The UART initialization sequence should be:
1) Initialize the UART by setting the different parameters in its
control registers WITHOUT RESETTING THE SWRST bit
2) Enable any interrupts.
3) RESET THE SWRST bit
Resetting the UART should be the final step.
Try this, and if u still could not succeed , we can tell u more.
------- cheers-------
Khubaib
--- In msp430@msp4..., "dimitrisgavrilis"
<dimitrisgavrilis@y...> wrote:
> Hello,
> I am using mspgcc with msp430f149 microcontroller.
> I ma currently trying to send/receive data from the msp430's
> uart. Although the transmit part is functioning normally,
> when i try to send data from the msp430 to the pc, most of the
> data are lost and those that are not, are not right (seems like
> a baud rate problem).
>
> The initialization and receive routines are:
>
> void USART0_Init()
> {
> UCTL0 = SWRST; // reset the USART
>
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> UCTL0 = CHAR; // 8-bit character
> UTCTL0 = SSEL0; // UCLK = ACLK
>
> // --- 2400 baud rate settings ---
> UBR00 = 0x0D; // 32k/2400 - 13.65
> UBR10 = 0x00; //
> UMCTL0 = 0x6B; // modulation
> // --- 9600 baud rate settings ---
> //UBR00 = 0x03; // 32k/2400 - 13.65
> //UBR10 = 0x00; //
> //UMCTL0 = 0x29; // modulation
>
> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
> IE1 |= URXIE0; // Enable USART0 RX
interrupt
> P3SEL |= 0x30; // P3.4,5
= USART0 TXD/RXD
> P3DIR |= 0x10; // P3.4 output direction
> eint(); // Enable interrupts
> }
>
>
> // -- from mspgcc examples --
> int usart0Getch(void)
> {
> uint8_t ch;
>
> if (usart0_rx_insert_idx == usart0_rx_extract_idx) // check if
> character is available
> return -1;
>
> ch = usart0_rx_buffer[usart0_rx_extract_idx++]; // get character,
> bump pointer
> usart0_rx_extract_idx %= USART0_RX_BUFFER_SIZE; // limit the
pointer
> return ch;
> }
>
>
>
> // ISR for incoming data on usart0 - from mspgcc examples -
> interrupt (UART0RX_VECTOR) usart0RcvIsr(void)
> {
> uint16_t temp;
> volatile uint8_t dummy;
>
> // check status register for receive errors
> if (URCTL0 & RXERR)
> {
> // clear error flags by forcing a dummy read
> dummy = RXBUF0;
> return;
> }
>
> temp = (usart0_rx_insert_idx + 1) % USART0_RX_BUFFER_SIZE;
> usart0_rx_buffer[usart0_rx_insert_idx] = RXBUF0; // read the
> character
>
> if (temp != usart0_rx_extract_idx)
> usart0_rx_insert_idx = temp;
> P1OUT=~P1OUT;
> }
Hello,
I am using mspgcc with msp430f149 microcontroller.
I ma currently trying to send/receive data from the msp430's
uart. Although the transmit part is functioning normally,
when i try to send data from the msp430 to the pc, most of the
data are lost and those that are not, are not right (seems like
a baud rate problem).
The initialization and receive routines are:
void USART0_Init()
{
UCTL0 = SWRST; // reset the USART
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
UCTL0 = CHAR; // 8-bit character
UTCTL0 = SSEL0; // UCLK = ACLK
// --- 2400 baud rate settings ---
UBR00 = 0x0D; // 32k/2400 - 13.65
UBR10 = 0x00; //
UMCTL0 = 0x6B; // modulation
// --- 9600 baud rate settings ---
//UBR00 = 0x03; // 32k/2400 - 13.65
//UBR10 = 0x00; //
//UMCTL0 = 0x29; // modulation
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
IE1 |= URXIE0; // Enable USART0 RX interrupt
P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD
P3DIR |= 0x10; // P3.4 output direction
eint(); // Enable interrupts
}
// -- from mspgcc examples --
int usart0Getch(void)
{
uint8_t ch;
if (usart0_rx_insert_idx == usart0_rx_extract_idx) // check if
character is available
return -1;
ch = usart0_rx_buffer[usart0_rx_extract_idx++]; // get character,
bump pointer
usart0_rx_extract_idx %= USART0_RX_BUFFER_SIZE; // limit the pointer
return ch;
}
// ISR for incoming data on usart0 - from mspgcc examples -
interrupt (UART0RX_VECTOR) usart0RcvIsr(void)
{
uint16_t temp;
volatile uint8_t dummy;
// check status register for receive errors
if (URCTL0 & RXERR)
{
// clear error flags by forcing a dummy read
dummy = RXBUF0;
return;
}
temp = (usart0_rx_insert_idx + 1) % USART0_RX_BUFFER_SIZE;
usart0_rx_buffer[usart0_rx_insert_idx] = RXBUF0; // read the
character
if (temp != usart0_rx_extract_idx)
usart0_rx_insert_idx = temp;
P1OUT=~P1OUT;
}