關(guān)于串口發(fā)送中斷的理解(轉(zhuǎn))
發(fā)布時間:2019-05-22
一般單片機發(fā)送中斷有兩種出發(fā)方式(STM8為例):
- Tansmit Data Register empty interrupt
- Transmission complete interrupt
而單片機的發(fā)送用到兩個寄存器:發(fā)送數(shù)據(jù)寄存器和移位器
When a transmission is taking place, a write instruction to the UART_DR register stores the
data in the TDR register. The data is copied in the shift register at the end of the current
transmission.(如果正在發(fā)生,數(shù)據(jù)會先存到發(fā)送數(shù)據(jù)寄存器,等發(fā)送完成在送到移位器)
When no transmission is taking place, a write instruction to the UART_DR register places
the data directly in the shift register.(如果沒有發(fā)數(shù),數(shù)據(jù)會直接送到移位器)
發(fā)送空中斷和完成中斷的區(qū)別就很簡單了。
空中斷:是相對于發(fā)送數(shù)據(jù)寄存器來說的,只要他空了,就會發(fā)生中斷,而此時移位寄存器有可能還在工作
完成中斷:是相對于移位寄存器來說的,他完全發(fā)送完成了才會發(fā)生中斷。