完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
STM8S105K6使用串口中断发送,如何清发送完成中断TXE?找了一个例程
INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20){ // 写操作自动清中断,因此可以不用显式清中断 UART2_ClearITPendingBit(UART2_IT_TXE); // 从写缓冲中写出1字节 UART2_SendData8(writ_buffer[writ_idx++]); // 全部写完、关写中断、置写完成标志(同步化处理) if( writ_idx == writ_len ) { UART2_ITConfig(UART2_IT_TXE, DISABLE); writ_ok = 1; } } ---------------------------------------------------------------------------------------------------------------------------------- 这个例程使用UART2_ClearITPendingBit(UART2_IT_TXE); 来清发送完成中断,会导致进入断言while(1)循环void assert_failed(u8* file, u32 line) 查看UART2_ClearITPendingBit函数说明,发现该函数不能请TXE和TC中断,给出的解决方案是UART2_SendData8() or UART2_SendData9(),写数据的方式。单带来的问题是,实际发送数据时,我的最后一个字节发送完了怎么办,没发清中断标志,又无数可发?? ---------------------------------------------------------------------------------------------------------------------------------- /** * @brief Clears the UART2 pending flags. * @param UART2_IT specifies the pending bit to clear * This parameter can be one of the following values: * - UART2_IT_LBDF: LIN Break detection interrupt * - UART2_IT_LHDF: LIN Header detection interrupt * - UART2_IT_RXNE: Receive Data register not empty interrupt. * @note * - PE (Parity error), FE (Framing error), NE (Noise error), * OR (OverRun error) and IDLE (Idle line detected) pending bits are * cleared by software sequence: a read operation to UART2_SR register * (UART2_GetITStatus()) followed by a read operation to UART2_DR register * (UART2_ReceiveData8() or UART2_ReceiveData9()). * * - RXNE pending bit can be also cleared by a read to the UART2_DR * register (UART2_ReceiveData8() or UART2_ReceiveData9()). * * - TC (Transmit complete) pending bit can be cleared by software * sequence: a read operation to UART2_SR register * (UART2_GetITStatus()) followed by a write operation to UART2_DR * register (UART2_SendData8()or UART2_SendData9()). * * - TXE pending bit is cleared only by a write to the UART2_DR register * (UART2_SendData8() or UART2_SendData9()). * @retval None */ void UART2_ClearITPendingBit(UART2_IT_TypeDef UART2_IT) |
|
相关推荐
1个回答
|
|
给一段stm32的发送中断程序,供参考:
if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET) { /* Write one byte to the transmit data register */ USART_SendData(USART1, usart_user_1.send_buff[TxCounter1++]); if(TxCounter1 == usart_user_1.send_num ) { /* Disable the USART2 Transmit interrupt */ USART_ITConfig(USART1, USART_IT_TXE, DISABLE); TxCounter1 = 0; } } |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1645 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1564 浏览 1 评论
992 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
691 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1610 浏览 2 评论
1871浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
656浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
526浏览 3评论
542浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
515浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 23:54 , Processed in 0.922027 second(s), Total 80, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号