This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART驱动接收数据中存在的问题



在官方提供的UART驱动中,pend模式且使用信号量超时时,UART的逻辑会出现问题。

代码 UART_v1.c中的uart_read2_v1();

pend信号量因为超时而进行任务调度后,到关闭接收中断的过程中,如果刚好来了接收中断,那么在接收中断中会post一次信号量。

此时,任务是因为超时继续运行下去的,而不是因为post的操作。所以信号量可用

那么,下次接收数据时,pend发现信号量可用,然后继续运行了,但是实际中此时数据接收并没有完成

下次接收数据时,会发现串口被占用