一般單片機發送中斷有兩種出發方式(STM8為例):
- Tansmit Data Register empty interrupt
- Transmission complete interrupt
而單片機的發送用到兩個寄存器:發送數據寄存器和移位器
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.(如果正在發生,數據會先存到發送數據寄存器,等發送完成在送到移位器)
When no transmission is taking place, a write instruction to the UART_DR register places
the data directly in the shift register.(如果沒有發數,數據會直接送到移位器)
發送空中斷和完成中斷的區別就很簡單了。
空中斷:是相對於發送數據寄存器來說的,只要他空了,就會發生中斷,而此時移位寄存器有可能還在工作
完成中斷:是相對於移位寄存器來說的,他完全發送完成了才會發生中斷。