当前位置:网站首页>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 .
边栏推荐
- labelimg的安装与使用
- Daily question 1: force deduction: 225: realize stack with queue
- 【sdx62】WCN685X将bdwlan.bin和bdwlan.txt相互转化操作方法
- [linear algebra] determinant of order 1.3 n
- CCNA Cisco network EIGRP protocol
- 第3章:类的加载过程(类的生命周期)详解
- How does the uni admin basic framework close the creation of super administrator entries?
- Unity3D学习笔记6——GPU实例化(1)
- (十八)LCD1602实验
- BarcodeX(ActiveX打印控件) v5.3.0.80 免费版使用
猜你喜欢
Common sense: what is "preservation" in insurance?
GPS from getting started to giving up (12), Doppler constant speed
第3章:类的加载过程(类的生命周期)详解
Aardio - 利用customPlus库+plus构造一个多按钮组件
PVL EDI project case
Management background --5, sub classification
Management background --2 Classification list
自制J-Flash烧录工具——Qt调用jlinkARM.dll方式
Learn the principle of database kernel from Oracle log parsing
That's why you can't understand recursion
随机推荐
2021 geometry deep learning master Michael Bronstein long article analysis
Research and investment strategy report of China's VOCs catalyst industry (2022 Edition)
Management background --3, modify classification
Mysql database basic operations DML
Aardio - 封装库时批量处理属性与回调函数的方法
Barcodex (ActiveX print control) v5.3.0.80 free version
go多样化定时任务通用实现与封装
Unity3d minigame unity webgl transform plug-in converts wechat games to use dlopen, you need to use embedded 's problem
Insert sort and Hill sort
const关键字
Unity3d Learning Notes 6 - GPU instantiation (1)
GPS from getting started to giving up (XI), differential GPS
中国固态氧化物燃料电池技术进展与发展前景报告(2022版)
解决项目跨域问题
Report on technological progress and development prospects of solid oxide fuel cells in China (2022 Edition)
0 basic learning C language - interrupt
Solve project cross domain problems
2500个常用中文字符 + 130常用中英文字符
图像的spatial domain 和 frequency domain 图像压缩
Applet system update prompt, and force the applet to restart and use the new version