初级会员

- 积分
- 81
- 金钱
- 81
- 注册时间
- 2015-1-19
- 在线时间
- 0 小时
|
5金钱
串口和定时器同时运行,串口的接收数据会丢失一部分数据。我的定时器里面做的事情已经很少了,只是在里面定时发送消息。
串口一次性接收200多字节数据,中间丢了很多。如果我把定时器的发送消息的代码屏蔽,就不会有问题。
我觉得是不是定时器里面的执行的代码的时间,超过了串口接收中断接收一个字节的时间,导致了丢失数据呢。请大神帮忙解答
串口接受中断:
void BSP_IntHandlerUART5 (void)
{
unsigned char uart5_data = 0;
//OS_CPU_SR cpu_sr = 0;
OSIntEnter(); /* Tell uC/OS-II that we are starting an ISR */
if(USART_GetFlagStatus(UART5,USART_IT_RXNE)==SET)
{
uart5_data =(CPU_INT08U) USART_ReceiveData(UART5);
#ifdef BLE_ON
ble_irq_handler(uart5_data);//接收蓝牙数据并处理
#endif
USART_ClearITPendingBit(UART5, USART_IT_RXNE);
}
OSIntExit(); /* Tell uC/OS-II that we are leaving the ISR */
}
定时器3中断处理:
void BSP_IntHandlerTIM3 (void)
{
//OS_CPU_SR cpu_sr = 0;
OSIntEnter(); /* Tell uC/OS-II that we are starting an ISR */
if(TIM_GetITStatus(TIM3, TIM_IT_Update) == SET)
{
#ifdef LOCK_STATUS
send_msg_by_time3();//定时发送消息
#endif
TIM_ClearFlag(TIM3, TIM_FLAG_Update);
}
OSIntExit(); /* Tell uC/OS-II that we are leaving the ISR */
}
|
|