anybody knows what is my Uart code problem

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

anybody knows what is my Uart code problem

1,587 Views
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..................



Labels (1)
0 Kudos
Reply
2 Replies

730 Views
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 Kudos
Reply

730 Views
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 Kudos
Reply