Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the problems related to stm32 usart and their solutions

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

What are the stm32 usart-related problems and solutions? in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

If USART is sending data at this time, writing to the USART_DR register stores the data in the TDR register, and

The data is copied into the shift register at the end of the current transmission.

If the USART is not sending data and is idle at this time, the write operation to the USART_DR register directly sets the number

According to putting in the shift register, the data transfer begins and the TXE bit is set immediately. When a frame is sent (after the stop bit is sent)

The TC bit is set, and if the TCIE bit in the USART_CR1 register is set, an interrupt occurs.

First read the USART_SR register, and then write the USART_DR register, you can complete the zero of the TC bit.

Note: the TC bit can also be cleared by writing 0 to its software. This zero clearing method is recommended only in multi-buffer communication mode.

When a character is received

The z RXNE bit is set. It indicates that the contents of the shift register are transferred to RDR. In other words, the data has been received

And can be read (including associated error flags).

Z if the RXNEIE bit is set, an interrupt occurs.

Z if a frame error, noise or overflow error is detected during reception, the error flag will be set up

Z when communicating with multiple buffers, the RXNE is set after each byte is received, and the DMA reads the data register.

And zero.

Z in single buffer mode, the software reads the USART_DR register to clear the RXNE bit. The RXNE logo is also available.

To clear it by writing 0 to it. The RXNE bit must be cleared before the end of the next character reception to avoid overflow errors.

Note: the RE bit should not be reset when receiving data. If the RE bit is cleared on reception, the reception of the current byte is lost

Overflow error

If the RXNE has not been reset and another character is received, an overflow error occurs. Data only when RXNE bits are cleared

Zero can be transferred from the shift register to the RDR register. The RXNE tag is set after each byte is received. If

When the next data has been received or the previous DMA request has not been served, the RXNE flag is still set and an overflow error occurs.

When an overflow error occurs:

The z ORE bit is set.

Z RDR content will not be lost. You can still get the previous data by reading the USART_DR register.

Z the previous contents in the shift register will be overwritten. All subsequently received data will be lost.

Z if the RXNEIE bit is set or both the EIE and DMAR bits are set, an interrupt occurs.

Z sequentially performs read operations on USART_SR and USART_DR registers, and resets ORE bits

Note: when the ORE position bit, at least 1 data has been lost. There are two possibilities:

If RXNE=1, the last valid data is still on the receiving register RDR and can be read out.

If RXNE=0, this means that the last valid data has been read away, and RDR has nothing to read. When the last one had

This can happen when new (that is, lost) data is received while the effective data is read in RDR.

New data is received during the read sequence (between USART_SR register read access and USART_DR read access)

This can also happen.

The answers to the questions related to stm32 usart and the ideas to solve them are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report