Question
STM32F4 UART IRQ issue
Posted on January 22, 2015 at 10:07
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; } }
