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");
PROCESS_THREAD(uart_check,ev,data)
{
PROCESS_BEGIN();
uart0_init();
uart0_send_data();
PROCESS_END();
}
OR