About the problem of STM32 serial port idle interrupt IDEL

Publisher:亚瑟摩根Latest update time:2018-10-06 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. The idle interrupt is triggered when a byte of high level (idle) appears after receiving data. It does not mean that the idle interrupt will continue. To be precise, it should be a byte after the rising edge (stop bit). If it is always at a low level, the idle interrupt will not be triggered (it will trigger a break interrupt).


2. There are three situations to be prepared for the second point. In the datasheet,
"When an idle frame is detected, the processing steps are the same as receiving a normal data frame, but if the IDLEIE bit is set, an interrupt will be generated."
"The idle symbol is regarded as a complete data frame consisting entirely of '1', followed by the number of '1' bits of the start bit of the next frame of data, including the number of stop bits." The picture of the idle symbol is followed by this low level.
Some people understand that only when the start bit of the next data is received will the interrupt be triggered. This understanding is wrong. It should be triggered when there is an idle frame after the data.


3. The way to clear interrupts feels strange. The function USART_ClearITPendingBit( USART1, USART_IT_IDLE ) cannot clear interrupts. I use the 3.5 library. Looking at the function description, there is no IDLE in the @param parameter. In the @note below, it says:
"PE(Parity error),FE(Framing error),NE(Noise error),ORE(OverRun error) and IDLE(Idle line detected) pending bits are cleared by software sequence: a read operation to USART_SR register (USART_GetITStatus()) followed by a read operation to USART_DR register (USART_ReceiveData())."
I clear the IDLE interrupt through the statement "USART1->DR;".

Nowadays, many data processing methods require variable-length data, but the RXNE interrupt of the microcontroller serial port can only receive one byte of data at a time. There is no buffer and it is impossible to receive multiple data in one frame. Now two methods of using the serial port IDLE interrupt to receive a frame of data are provided. The methods are as follows:

Method 1: Implementation idea: Use the serial port 1 of STM32F103, configure it to the idle interrupt IDLE mode and enable DMA reception, and set the receiving buffer and initialize DMA at the same time. After the initialization is completed, when the external sends data to the microcontroller, assuming that the length of this frame of data is 200 bytes, then when the microcontroller receives a byte, the serial port interrupt will not be generated, but DMA will silently move the data to the specified buffer in the background. The serial port will only generate an interrupt after the entire frame of data is sent. At this time, the DMA_GetCurrDataCounter() function can be used to calculate the length of the data received this time, so as to process the data.

Application objects: Suitable for various serial port related communication protocols, such as MODBUS, PPI; also suitable for GPS data reception and analysis, serial port WIFI data reception, etc., which are all good application objects.

Method 2: Implementation idea: Directly use the RXNE and IDLE interrupts of stm32 to receive indefinite byte data. 


Keywords:STM32 Reference address:About the problem of STM32 serial port idle interrupt IDEL

Previous article:STM32 internal RAM online debugging configuration method and detailed description
Next article:STM32 Learning IIC

Recommended ReadingLatest update time:2024-11-16 16:22

【stm32f407】stm32 serial port experiment
1. Serial port theory As an important external interface of MCU, the serial port is also an important debugging method for software development. Its importance is self-evident. Now almost all MCUs have serial ports, and STM32 is no exception. STM32F407VGT6 embeds four universal synchronous/asynchronous receivers (
[Microcontroller]
【stm32f407】stm32 serial port experiment
STM32 Basic Design (3) --- Interrupt Serial Port Communication
This article introduces how to use the STM32 serial port USART1 through interruption. First, to summarize the full text, the design steps are mainly as follows: 1. Initialize GPIO 2. Initialize USART1 3. Initialize NVIC (Nested Vectored Interrupt Controller) 4. Write interrupt service function 5. Write the
[Microcontroller]
Detailed explanation of STM32 interrupt priority
1. STM32 interrupt priority attributes   STM32 has two priority attributes, namely preemptive priority and responsive priority. Among them, responsive priority is also called secondary priority.   An interrupt with a high preemptive priority can be responded to during the interrupt processing with a low preempt
[Microcontroller]
Summary of STM32 library function programming ideas and comparison with register programming
1. Summary of STM32 library function programming ideas 1. Development process based on STM32 library function Before carrying out specific project development, do a good job of project creation, which usually includes the following steps: (1) Create folders and subfolders for new project (such as user, output, l
[Microcontroller]
Summary of STM32 library function programming ideas and comparison with register programming
STM32 timer generates PWM with different frequencies
 It is very convenient for STM32 to generate PWM. You just need to simply set the timer and it will be generated immediately! (1) Enable the timer clock: RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); (2) Define the corresponding GPIO:  /* PA2,3,4,5,6 output- Key_Up,Key_Down,Key_Left,Key_Right,Key_Ctrl */
[Microcontroller]
STM32 self-study notes - multiplexing and remapping
Port multiplexing What is port multiplexing:  STM32 has many built-in peripherals, and the external pins of these peripherals are multiplexed with GPIO. In other words, if a GPIO can be multiplexed as a function pin of a built-in peripheral, then when this GPIO is used as a built-in peripheral, it is called multiplexi
[Microcontroller]
8 modes in stm32GPIO
1. Push-pull output: can output high and low levels and connect digital devices; push-pull structure generally means that two transistors are controlled by two complementary signals, and one transistor is always turned on while the other is turned off. The high and low levels are determined by the power supply of the I
[Microcontroller]
Learn STM32 (2) - IO-AFIO (multiplexing function IO and debugging configuration)
I'm learning STM32 recently. In an article about serial communication on BZ, there is a piece of code: RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO,ENABLE); I wrote it with reference to the development guide. I never understood the meaning of GPIOD or "RCC_APB2Periph_AFIO". After searching onli
[Microcontroller]
Learn STM32 (2) - IO-AFIO (multiplexing function IO and debugging configuration)
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号