超时中断
如果接收FIFO里的数据没有达到触发级而且至少存在一个字符,而且存在一定时间的话,就会触发超时中断
接收中断
当接收fifo中的深度大于设置的触发深度时发生的中断
发送中断
当发送fifo的深度小于设定的深度时触发的中断
超时中断和接受中断都用于接收数据,发送数据只有一个发送中断。
这三个中断就是最长用的了。除此之外,urat还有四个错误类型的中断:间隔中断、帧错误、溢出中断和奇偶错误。
四个线状态错误:
间隔中断
在发送数据时,如果RXD引脚保持低电平,将产生间隔中断。发生间隔中断后,接收模块停止数据接收。
Break Interrupt.
When the Un_RX pin is held low for one full character
transmission (start, data, parity, stop), a break interrupt
occurs. Once the break condition has been detected, the
receiver goes idle until the Un_RX pin goes high.
但RX引脚在一个字符的所有期间(开始、数字、校验和停止位)都为0时,将会引发间隔中断。一旦检测到间隔中断,
接收器将会进入空闲状态直到RX引脚恢复到高电平。
帧错误
Framing Error.
When the stop bit of a received character is a logic 0, a
framing error occurs. A framing error is associated with the character at the top of
the UARTn RBR FIFO.
Upon detection of a framing error, the receiver will attempt
to resynchronize to the data and assume that the bad stop
bit is actually an early start bit. However, it cannot be
assumed that the next received byte will be correct even if
there is no Framing Error.
当字符的停止位是零时,发生帧错误。帧错误和fifo顶端的数据关联。
一旦检测到帧错误,接收器就会尝试数据同步并假设错误的停止位其实已是个超前的开始位。
但是,即使没有帧错误发生也不能假设下一个字符是正确的。(yll:就是说前一个帧错误和下一个字符之间没有关系)
校验错误
Parity Error.
When the parity bit of a received character is in the wrong
state, a parity error occurs.
A parity error is associated with the character at the top of
the UARTn RBR FIFO.
当 接收到的字符的校验位是错误状态时,引发校验错误。
校验错误和fifo的顶部的字符相关。
溢出错误
Overrun Error.
This bit is set when the UARTn RSR has a new character
assembled and the UARTn RBR FIFO is full. In this case,
the UARTn RBR FIFO will not be overwritten and the
character in the UARTn RSR will be lost.
The overrun error condition is set as soon as it occurs.
当接收器的移位寄存器有新的字符装载进来而接收fifo已经满时发生溢出错误。
此时已有的字符不会被覆盖,新来的字符被丢弃。
溢出错误将会在发生后立即影响标志位。
break中断和溢出错误不会产生有效字符在fifo中。
另外补充一下CTS/RTS 引脚的用法:
RTS:fifo中的深度大于RTS触发深度时,RTS引脚输出低电平。让对方暂停发送。
CTS:当CTS引脚检测到低电平时,停止发送。
可见,将一对uart的这两个引脚交叉连接就可以相互控制对方的发送了。这两个引脚的功能属于流控的范畴。
感谢以下博客的作者:
http://blogold.chinaunix.net/u3/98807/showart_1969310.html
http://blog.csdn.net/liukun321/archive/2010/05/31/5636748.aspx