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.
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
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [TI High Precision Laboratory] In the course, when calculating the offset voltage error, is it not necessary to calculate the offset voltage error of the second-stage op amp?
- Does anyone know: Can one ZLL remote control control 3 ZLL lights at the same time?
- Does anyone have the Chinese version of the RL78F12 chip datasheet?
- Optimizing EMC and Efficiency in High Power DC/DC Converters Part 1
- Common Problems in RF Circuit Design
- Telink Microelectronics Matter Development Guide (I): The Past and Present of Matter
- Example of chip drain damage
- F280049C CAN_ex3 Issue
- [Factory Visit Live Replay] Arrived at the destination - TE Qingdao Factory
- Useful tutorial | How to quickly splice PCB data at unconventional angles?