2015-01-22 01:07 AM
Hi,
I am trying to receive RF packet using USART1 IRQ, using below code. But packets are missing in the receive end. My point here is sometimes i will receive packets and the received packet is completely valid, i mean all received bytes are perfect. But I am expecting interrupt IRQ to be called many times. but thats not happening here. Can any one please suggest me is my IRQ function is valid ?void USART 1 _IRQHandler(void) { char c; uint 8 _t rByte= 0 ,lsb= 0 ,msb= 0 ,rCnt= 0 ; c=USART_ReceiveData(USART 1 ); switch(rByte) { case 0: if(c==PACKET_DELIMETER) { received_String[rCnt++]=c; //first byte copied to array rByte= 1 ; } break; case 1: msb=c; //Second byte copied to array received_String[rCnt++]=msb; rByte= 2 ; break; case 2: lsb=c; // 3 rd byte copied to array received_String[rCnt++]=lsb; rByte= 3 ; break; case 3: if(c==ZB_API_RECEIVEPACKET) { received_String[rCnt]=c; for(rCnt= 4 ;rCnt<lsb+ 1 ;rCnt++) { received_String[rCnt]=c; // whole packet will be received at this point } rByte= 4 ; } break; case 4: if(received_String[ 15 ]==g_ch_indx && received_String[ 16 ]==g_frame_Id) { g_bOK= 1 ; g_nei_id = received_String[ 17 ]; } break; default : break; } }
2015-01-22 02:07 AM
Unreadable wall of code here, please try again with the code, and explanation of the problem.
2015-01-22 02:48 AM
2015-01-22 02:48 AM
You assume that the variables you use are static, i.e. don't change between successive invocations of the routine, but you don't declare them as such.
JW2015-01-22 05:26 PM
volatile char c; // tried by declaring c as volatile char and char
uint
8
_t lsb=
0
,msb=
0
;
static
uint
8
_t rByte=
0
,rCnt=
0
; //
static
variables