[mw_shl_code=c,true] [/mw_shl_code]
[mw_shl_code=c,true]void UART4_IRQHandler(void)[/mw_shl_code]
[mw_shl_code=c,true]{
[/mw_shl_code]
[mw_shl_code=c,true] if(USART_GetITStatus(UART4, USART_IT_RXNE) != RESET)
{
USART_ClearITPendingBit(UART4, USART_IT_RXNE);
Receive[bufferRx]=USART_ReceiveData(UART4); //缓存COM4中断接收的数据
bufferRx++;
bufferRx &=0xFF;
[/mw_shl_code]
[mw_shl_code=c,true]
[/mw_shl_code]
[mw_shl_code=c,true] if( Receive[bufferRx-1]==0x52) //头
bufferTx=bufferRx-1;
if((Receive[bufferTx]==0x52)&&(Receive[bufferRx-1]==0x59))
{
bufferLen=bufferRx-1-bufferTx;
bufferSta=1;
}
if(USART_GetFlagStatus(UART4, USART_FLAG_ORE) == SET) //溢出
{
USART_ClearFlag(UART4, USART_FLAG_ORE); //读SR
USART_ReceiveData(UART4);
}
if(bufferSta)
{
for(tx4=0;tx4<=bufferLen;tx4++,bufferTx++)
USART_SendData(UART5,Receive[bufferTx]);
bufferTx=0;
bufferRx=0;
bufferSta=0;
break;
} [/mw_shl_code]
[mw_shl_code=c,true] }
}
[/mw_shl_code]
这段代码是网上的中断数据收发的例程,我可以进行数据比对,就是打印不出数据。如果我在开头那里加一句
USART_SendData(UART5,USART_ReceiveData(UART4));
这样只是打印字符,我需要判断数组里面的数据。 我如何获取数组里面的数据呢? 这个例子我觉得没有问题。。。 |