problem in receiveing bytes from uart - Zigbee MC1321X

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problem in receiveing bytes from uart - Zigbee MC1321X

1,520 Views
bitasobhani
Contributor III

Hi all
I am working on Zigbee Mc1321x.
I write a string of 2 bytes on uart at eah timer interval (for example every 1 seconds).
How can I receive both the two bytes at zigbee node? I wrote this code:

uint8_t       UartByte[2];
static void UartRxCallBack
  (
  void
  )
{
  UartX_GetByteFromRxBuffer(&UartByte[0]);
  UartX_GetByteFromRxBuffer(&UartByte[1]);
 
  SendToNode(gZbAddrMode16Bit_c, CoordinatorNwkAddr, gApsTxOptionNone_c, UartByte);
   
}
 
But It seems that the too bytes are not received at once. They are received byte by byte. So UartByte[0] takes the second byte value and UartByte[1] never takes anything (always 0x00).
What should I do? Can anbody give me the right code?
PLEASE REPLY.........:smileysad:

 

Added p/n to subject.






Message Edited by NLFSJ on 2008-09-03 10:57 PM
Labels (1)
0 Kudos
Reply
1 Reply

582 Views
jag
Contributor IV
Hi,

your problem is that you think that UartRxCallBack() is run when the uart has received all data.
But the callback is run as soon as some data (even only 1 byte) is received.
I suppose that the callback is run twice (first time after the first byte, second time after the second byte).

If the callback is run, and only 1 byte is in the buffer I think that the first getbyte() get the true data, but the second get nothing (buffer empty).
So the second time the callback is called (when the second byte arrived) the data in UartByte[0] is overwritten with the second byte you sent.

All this is IMHO, I never used zigbee, so I'm not sure about the behaviour of this processor, but usually the behaviour of uart is something like this.

Bye Jack
0 Kudos
Reply