当前位置:网站首页>Gd32f4xx serial port receive interrupt and idle interrupt configuration
Gd32f4xx serial port receive interrupt and idle interrupt configuration
2022-07-06 22:26:00 【fangye945a】
Recently debugging GD32F4xx, Want to use the idle interrupt of serial port , Discovery and STM32 Some differences . Make a record here , Memo , Prevent repeated stepping on the pit .
Serial port enable interrupt related code :
nvic_irq_enable(USART0_IRQn,0,1);
usart_interrupt_enable(USART0, USART_INT_RBNE); /* Can make USART0 Read area non empty interrupt */
usart_interrupt_enable(USART0, USART_INT_IDLE); /* Can make USART0 Idle interrupt */
Serial interrupt processing function :
void USART0_IRQHandler(void)
{
if ((RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)) &&
(RESET != usart_flag_get(USART0, USART_FLAG_RBNE))) {
unsigned char value = usart_data_receive(USART0);
RingBufWrite(g_debugRingBuf, value); // Write the received data to ringbuf in
usart_interrupt_flag_clear(USART0, USART_INT_FLAG_RBNE); // Clear the interrupt flag
}
else if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)) {
usart_interrupt_flag_clear(USART0, USART_INT_FLAG_IDLE);
usart_data_receive(USART0); /* Clear the receive completion flag bit */
(void)LOS_EventWrite(&g_shellInputEvent, 0x1); // Event notification reception completed
}
}
Special attention is paid to : And STM32F4 The difference is , After entering idle interrupt , Need to call usart_data_receive function , Used to clear the receive completion flag bit , Otherwise, the idle interrupt will be triggered many times or not .
stay STM32f4xx in , Clear idle interrupt flag macro is defined as follows :
/** @brief Clears the UART IDLE pending flag. * @param __HANDLE__ specifies the UART Handle. * UART Handle selects the USARTx or UARTy peripheral * (USART,UART availability and x,y values depending on device). * @retval None */
#define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
/** @brief Clears the UART PE pending flag. * @param __HANDLE__ specifies the UART Handle. * UART Handle selects the USARTx or UARTy peripheral * (USART,UART availability and x,y values depending on device). * @retval None */
#define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) \ do{
\ __IO uint32_t tmpreg = 0x00U; \ tmpreg = (__HANDLE__)->Instance->SR; \ tmpreg = (__HANDLE__)->Instance->DR; \ UNUSED(tmpreg); \ } while(0U)
You can see that there are read operation pairs DR Register to read , amount to GD32 Standard library usart_data_receive Function function .
边栏推荐
- How does the uni admin basic framework close the creation of super administrator entries?
- Unity3d Learning Notes 6 - GPU instantiation (1)
- SQL Server生成自增序号
- Spatial domain and frequency domain image compression of images
- Leetcode question brushing (XI) -- sequential questions brushing 51 to 55
- Attack and defense world ditf Misc
- Force deduction question 500, keyboard line, JS implementation
- Web APIs DOM 时间对象
- 二叉(搜索)树的最近公共祖先 ●●
- 雅思口语的具体步骤和时间安排是什么样的?
猜你喜欢
![[linear algebra] determinant of order 1.3 n](/img/6e/54f3a994fc4c2c10c1036bee6715e8.gif)
[linear algebra] determinant of order 1.3 n

LeetCode 练习——剑指 Offer 26. 树的子结构

Assembly and interface technology experiment 5-8259 interrupt experiment

Oracle-控制文件及日志文件的管理

ZABBIX proxy server and ZABBIX SNMP monitoring

【数字IC手撕代码】Verilog无毛刺时钟切换电路|题目|原理|设计|仿真

Aardio - 利用customPlus库+plus构造一个多按钮组件

Mysql database basic operations DML

Chapter 4: talk about class loader again

Should novice programmers memorize code?
随机推荐
2022年6月国产数据库大事记-墨天轮
Unity3d minigame unity webgl transform plug-in converts wechat games to use dlopen, you need to use embedded 's problem
2500个常用中文字符 + 130常用中英文字符
基于 QEMUv8 搭建 OP-TEE 开发环境
插入排序与希尔排序
How does the uni admin basic framework close the creation of super administrator entries?
C#实现水晶报表绑定数据并实现打印4-条形码
That's why you can't understand recursion
雅思口语的具体步骤和时间安排是什么样的?
case 关键字后面的值有什么要求吗?
网络基础入门理解
C # realizes crystal report binding data and printing 4-bar code
GPS from getting started to giving up (12), Doppler constant speed
NPDP认证|产品经理如何跨职能/跨团队沟通?
Crawler obtains real estate data
[linear algebra] determinant of order 1.3 n
Build op-tee development environment based on qemuv8
2022-07-05 使用tpcc对stonedb进行子查询测试
sizeof关键字
Management background --4, delete classification