anybody knows what is my Uart code problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

anybody knows what is my Uart code problem

1,592件の閲覧回数
bitasobhani
Contributor III
Hi all
I am working on zigbee 1321x.
I want to send two bytes at periodic time intervals from zigbee node to uart (for example every 1 seconds).
I used this code in the interval timer callback.

void TimerCallBack
  (
  tmrTimerID_t  timerId
  )
{
  uint8_t testByte[2]={0x12,0x34};
  (void) timerId;
 
  (void)UartX_Transmit(testByte , 2, NULL);
    
}

anybody knows what is the problem? The first byte is received correctly (0x01), but the second byte does not appear stable, it changes continuosly and some instances takes the correct value (0x34).

PLEASE REPLY..................



ラベル(1)
0 件の賞賛
返信
2 返答(返信)

735件の閲覧回数
bitasobhani
Contributor III
I solved my probem by declaring testByte as a global variable outside the timer callback function (instead of local variable).
It worked correctly:smileyhappy: But I didn't understand WHY?!!! Because it  was being used only in that function not any other one.
0 件の賞賛
返信

735件の閲覧回数
JimB
Contributor I

Hi - perhaps the transmit routine buffers the array parameters (and not the contents) for later (interrupt) transmission, thus the data is lost when the test function exits (releasing the stack frame).

Jim

0 件の賞賛
返信