Receiving data in FIFO mode

Source: Internet
Author: User

Old Rules: When the serial port receives data from the PC (100 bytes, once every ms), it will occasionally lose some data. A test record is as follows:

For the first time, the total amount of data sent is more than 0.6 million bytes, and 27 are lost. For the second time, the total amount of data sent is more than 0.8 million bytes (based on the previous sending) 40 million data records are lost for the third time. The total data volume is more than 1.9 million bytes (based on the previous sending). If more than 37 data records are lost, it indicates that the lost data is random, because if I clear the environment (such as power failure and restart) and the sending conditions on the PC side remain unchanged, the data loss is not the record shown above. For analysis, the so-called data loss is nothing more than that when the FIFO overflow software is too late to read or the readable zone size of the software buffer is 0. However, from the above situation, it should not be the reason for the latter. Because, if it is the latter, when the PC sending conditions remain unchanged and the Development Board environment is cleared again, data loss should be the same. Solution 1 can be modified based on the following solutions: If the PC (sender) has automatic traffic control, then, the CE end should also turn on the automatic throttling-set it through the rumcon register in the serial drive; if the PC end does not, the CE end should also turn off the automatic throttling solution 2: raise the priority of the receiving thread, including application and driver solution 3: Set the receiving interrupt mode of the serial controller and the trigger level value of the FIFO. There are two interruption modes. The pulse mode means that when the data volume in the FIFO reaches the required trigger level, there will be an interruption, which will only be generated at that moment, if the CPU is still processing the last interrupt and the interrupted mask is dropped, the interrupt will be lost, and the data in the FIFO will always increase to overflow; level Mode means that as long as the data in the FIFO reaches the required level, there will be interruptions, including when there are more than the required level, as long as the data in the FIFO is processed after the previous interruption is completed before the overflow, the FIFO will not overflow and the data will not be lost.

This article is from the "bluefish" blog, please be sure to keep this source http://bluefish.blog.51cto.com/214870/65389

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.