当前位置:网站首页>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 .
边栏推荐
- qt quick项目offscreen模式下崩溃的问题处理
- 中国1,4-环己烷二甲醇(CHDM)行业调研与投资决策报告(2022版)
- Learn the principle of database kernel from Oracle log parsing
- 在IPv6中 链路本地地址的优势
- Barcodex (ActiveX print control) v5.3.0.80 free version
- [MySQL] online DDL details
- 12、 Start process
- Aardio - 不声明直接传float数值的方法
- Unity3D学习笔记6——GPU实例化(1)
- Classic sql50 questions
猜你喜欢
[sciter]: encapsulate the notification bar component based on sciter
网络基础入门理解
Data processing skills (7): MATLAB reads the data in the text file TXT with mixed digital strings
Aardio - 封装库时批量处理属性与回调函数的方法
Spatial domain and frequency domain image compression of images
Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing
Powerful domestic API management tool
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
A Mexican airliner bound for the United States was struck by lightning after taking off and then returned safely
Attack and defense world ditf Misc
随机推荐
i. Mx6ull build boa server details and some of the problems encountered
C # realizes crystal report binding data and printing 4-bar code
Aardio - 不声明直接传float数值的方法
volatile关键字
中国固态氧化物燃料电池技术进展与发展前景报告(2022版)
自制J-Flash烧录工具——Qt调用jlinkARM.dll方式
Oracle-控制文件及日志文件的管理
Unity3D学习笔记6——GPU实例化(1)
2022-07-05 stonedb的子查询处理解析耗时分析
CCNA-思科网络 EIGRP协议
网络基础入门理解
case 关键字后面的值有什么要求吗?
第3章:类的加载过程(类的生命周期)详解
Management background --4, delete classification
Assembly and interface technology experiment 5-8259 interrupt experiment
变量与“零值”的比较
墨西哥一架飞往美国的客机起飞后遭雷击 随后安全返航
十二、启动流程
ZABBIX proxy server and ZABBIX SNMP monitoring
Solve project cross domain problems