新手上路
- 积分
- 43
- 金钱
- 43
- 注册时间
- 2019-11-4
- 在线时间
- 5 小时
|

楼主 |
发表于 2021-8-19 12:34:24
|
显示全部楼层
void USART2_IRQHandler(void)
{
if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET)//½óêÕμ½áËêy¾Y
{
RS232_buff[RS232_rec_counter] = USART2->DR;//
RS232_rec_counter ++;
/********òÔRS232_END_FLAG1oíRS232_END_FLAG2¶¨òåμÄ×Ö·û×÷Îaò»Ö¡êy¾YμĽáêø±êê¶************/
if(RS232_rec_counter >= 2) //Ö»óD½óêÕμ½2¸öêy¾YòÔéÏ2Å×öÅD¶Ï
{
if(RS232_buff[RS232_rec_counter - 2] == RS232_END_FLAG1 && RS232_buff[RS232_rec_counter - 1] == RS232_END_FLAG2) //Ö¡Æeê¼±êÖ¾
{
RS232_REC_Flag = 1;
}
}
if(RS232_rec_counter > RS232_REC_BUFF_SIZE)//3¬1y½óêÕ»o3åÇø′óD¡
{
RS232_rec_counter = 0;
}
}
if (USART_GetITStatus(USART2, USART_IT_TXE) != RESET)
{
USART_ClearITPendingBit(USART2, USART_IT_TXE); /* Clear the USART transmit interrupt */
}
}
在中断处理函数中增加了最后两行,复位一下发送中断,可以了 |
|