打印
[STM8]

STM8中UART2使用发送中断的疑问

[复制链接]
3748|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wk871123|  楼主 | 2011-2-28 12:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 wk871123 于 2011-2-28 13:47 编辑

我在STM8中UART2使用发送中断的时候,当使能TIEN或TCIEN后,再打开全局中断,我也清了TC和TXE位,程序运行,总是不停进发送中断服务程序,望大家提提建议。
沙发
Eddie_xiao| | 2011-3-23 18:08 | 只看该作者
注意看文档, TEX, TC的清楚条件
TXE: Transmit Data Register Empty.
This bit is set by hardware when the content of the TDR register has been
transferred into the shift register. An interrupt is generated if the TIEN bit =1 in the
USART_CR2 register. It is cleared by a write to the USART_DR register.
0: Data is not transferred to the shift register
1: Data is transferred to the shift register
TC: Transmission Complete.
This bit is set by hardware when transmission of a frame containing Data is
complete. An interrupt is generated if TCIEN=1 in the USART_CR2 register. It is
cleared by a software sequence (a read to the USART_SR register followed by a
write to the USART_DR register).
0: Transmission is not complete
1: Transmission is complete

如果使用TXE的话,数据全部发送完了,最好把TEN能关掉。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3

主题

5

帖子

0

粉丝