Xbee and MSP430 Interface

All things pertaining to wireless and RF links

Moderator: phalanx

Xbee and MSP430 Interface

Postby sdelica » Sat Dec 11, 2010 7:04 pm

Hello there,

I am trying to interface Xbee DOUT (AP = 2) with MSP430F2272 RX. I use some of the example code from TI which is to use the USCI_A0_RX interrupt. I have these settings:

WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

And the ISR is set up as such:
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
apiframe[j++] = UCA0RXBUF;
if ((j == 0 && UCA0RXBUF == 0x7E) || j > 0) {
data[j++] = apiframe[j++];
if (j == 11){
dh = apiframe[j];
}
if (j == 12) {
dl = apiframe[j];
}
if (j > sizeof apiframe - 1) {
j = 0;
}
}
}

The API frame is 14 bytes long (hex): 7E 00 0A 83 00 01 24 00 01 20 00 02 5D D7

However, when I use CCS to debug and view UCA0RXBUF I get nothing remotely close to the API Frame. I am trying to parse the packet and get data dh and dl (some processing and math will be done in a function to output to LCD). In debug dh should be 02 and dl = 5D (byte 11 and 12 of frame).

I also tried doing some simple code to make sure interrupt was firing. The API frame was 7E 00 0A 83 00 01 2F 00 01 00 10 00 10 2B. I had a Endpoint Xbee sample D04 which I set to Digital High and the Coordinator would output the RXed frame onto DOUT which is connected to MSP430 RX. When I use CCS to debug I get apiframe[] = {00, 00, 36, 00, 00, 36, ...}. Whether I have the Coordinator setup to AP = 1 or 2, I get the same which is not right. I also tried polling the register (with the interrupt disables) in the main(), and I get the same for apiframe[].

Please your help is truly appreciated. My graduation depends on this :/
sdelica
 
Posts: 3
Joined: Sat Dec 11, 2010 6:32 pm

Re: Xbee and MSP430 Interface

Postby waltr » Sun Dec 12, 2010 10:00 am

I've never used the MSP430F2272 but have many other processors and XBee.

Have you gotten the serial on the two pieces working to a PC COM port? If not then wire a RS232 translator IC (MAX232 or equivelent) so that the XBee can be connected to the PC. This way you can use HyperTerm or X-CTU to read the XBee Frames.
Exactly which XBee modules and firmware version do you have? The Firmware version will determine which XBee document to use.

Conversely, do the same with the MSP430F2272 and send XBee formatted frames to test the setup and code.
waltr
 
Posts: 2651
Joined: Tue Sep 08, 2009 12:07 pm
Location: Philadelphia, USA

Re: Xbee and MSP430 Interface

Postby sdelica » Sun Dec 12, 2010 10:40 am

Thank you for your suggestion. I got a response from the TI E2E forum and it was some code issues I had to fix. Minor but major in respect to the "damage" it was causing. I had to set up the ISR like so. Thanx for your help!

#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{

apiframe[j] = UCA0RXBUF;
if ((j == 0 && apiframe[j] == 0x7E) || j > 0) {
data[j] = apiframe[j];
}
if (j == 11) {
dh = data[j];
}
if (j == 12) {
dl = data[j];
dataReady = 1;
}
if (j > sizeof apiframe - 1) {
j = 0;
}
j++;
}
sdelica
 
Posts: 3
Joined: Sat Dec 11, 2010 6:32 pm


Return to Wireless/RF

Who is online

Users browsing this forum: No registered users and 2 guests