anybody knows what is my Uart code problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

anybody knows what is my Uart code problem

1,600 次查看
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 回复数

743 次查看
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 项奖励
回复

743 次查看
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 项奖励
回复