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.

Regarding UART0 Communication in MSP430 F1611 of TelosB mote

Other Parts Discussed in Thread: MSP430F1611

Hi,

I am using TelosB wireless node for my project is in 6LoWPAN network(similar to ZigBee). TelosB node is having MSP430F1611 MCU. I am using contiki operating system for coding (http://www.contiki-os.org).I want to program simple TX and RX using UART0 which is loop back using interrupt(i.e. when i send a character from Tx buffer it has to be received by Rx buffer using hardware interrupt when interrupt is enabled). But it is not happening accordingly.

The following is the code snippet


#include<msp430.h>

#include<stdio.h>

#include "contiki.h"

#include "isr_compat.h"

 void uart0_init()
{
        P3SEL |= 0x30;
        P3DIR &= ~0x20;                      
        P3DIR |= 0x10;                       
        P3OUT |= 0x10;                       
        ME1 |= URXE0 + UTXE0;
        U0CTL |=CHAR;
        U0TCTL |= SSEL0;
        U0RCTL=0;
        U0BR0=0x03;
        U0BR1=0x00;
        U0MCTL=0x4a;
        U0CTL &= ~SWRST;
       IE1 |=URXIE0 +UTXIE0;
        _BIS_SR(GIE);
}


ISR(UART0RX,uart0_rx_
interrupt)

{
        unsigned char c;


        if(!(IFG1 & URXIFG0))
        {
           U0CTL &= ~URXSE;
           U0CTL |= URXSE;
                rx_in_progress = 1;
                leds_toggle(LEDS_BLUE);
                printf("%c\n",RXBUF0);
        }

        else{
                        rx_in_progress = 0;

                                if(URCTL0 & RXERR )
                                        {

                                                leds_on(LEDS_GREEN);
                                        c=RXBUF0;
                                        }
                                                else{

                                                leds_on(LEDS_GREEN);
                                                        c=RXBUF0;
                                                      }
                                        IFG1 &=~URXIFG0;
        }

}


void uart0_send_data()
{
               while(!(IFG1 & UTXIFG0));
               TXBUF0 = 0x41;
               while(!(IFG1 & UTXIFG0));
               TXBUF0 = 0x42;
 
}


PROCESS(uart_check,"uart-
communication");
AUTOSTART_PROCESSES(&uart_check);

PROCESS_THREAD(uart_check,ev,data)
{
PROCESS_BEGIN();
uart0_init();
uart0_send_data();
PROCESS_END();
}

Without using jumper for tx and rx pin(i.e without any physical interrupt )  UART0 program is entering into ISR  of UART0 receive.why it is happening like that?If at all it is entering in ISR, only once ISR is executing that to it is storing some garbage in rx buffer rather than tx buffer value and after exiting from ISR, waiting for tx buffer to set in uart0_send_data for 2nd byte transmission.Why it is happening like ?can anybody help?
Is there anything wrong/missing in the UART code ?
              
                      OR

Is there any other way to write the same code ?Please suggest me.
Regards,
Sai Krishna

**Attention** This is a public forum