当前位置:网站首页>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 .
边栏推荐
- Barcodex (ActiveX print control) v5.3.0.80 free version
- A Mexican airliner bound for the United States was struck by lightning after taking off and then returned safely
- Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing
- 在IPv6中 链路本地地址的优势
- [MySQL] online DDL details
- C#實現水晶報錶綁定數據並實現打印4-條形碼
- Management background --1 Create classification
- What are the interface tests? What are the general test points?
- Should novice programmers memorize code?
- 2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
猜你喜欢

Attack and defense world ditf Misc

数据处理技巧(7):MATLAB 读取数字字符串混杂的文本文件txt中的数据

Daily question 1: force deduction: 225: realize stack with queue

小常识:保险中的“保全”是什么?

Powerful domestic API management tool

Build op-tee development environment based on qemuv8

Memorabilia of domestic database in June 2022 - ink Sky Wheel

Chapter 4: talk about class loader again

C#实现水晶报表绑定数据并实现打印4-条形码

2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
随机推荐
将MySQL的表数据纯净方式导出
return 关键字
LeetCode 练习——剑指 Offer 26. 树的子结构
Aardio - 不声明直接传float数值的方法
Four data streams of grpc
微信红包封面小程序源码-后台独立版-带测评积分功能源码
lora同步字设置
LeetCode刷题(十一)——顺序刷题51至55
ZABBIX proxy server and ZABBIX SNMP monitoring
zabbix 代理服务器 与 zabbix-snmp 监控
Powerful domestic API management tool
雅思口语的具体步骤和时间安排是什么样的?
What are the interface tests? What are the general test points?
小常识:保险中的“保全”是什么?
Search element topic (DFS)
Classic sql50 questions
网络基础入门理解
Notes de développement du matériel (10): flux de base du développement du matériel, fabrication d'un module USB à RS232 (9): création de la Bibliothèque d'emballage ch340g / max232 SOP - 16 et Associa
How does the uni admin basic framework close the creation of super administrator entries?
Should novice programmers memorize code?