2952 views|10 replies

3184

Posts

0

Resources
The OP
 

An interview question [Copy link]

During the interview today, the interviewer asked me a question

A frame of data came in the serial port interrupt, but before it could be processed, another frame of data came.

What should I do?

I didn't know how to answer, so I just said something random.

Overwrite the previous frame, or save it to another variable, process the later one first, and then

Process the previous frame.

Could you please advise how to answer this? Thank you!

This post is from stm32/stm8

Latest reply

If this situation is sporadic, then caching is likely to solve the problem. If this situation is the norm, it means that your hardware system load has reached its limit and there is no room for improvement. You can consider using hardware that responds more quickly and runs faster. If even if you spend more money on a hardware system that cannot meet your data pressure, you can only coordinate with the business to reduce the data pressure. If none of the above works and the business pressure cannot be adjusted, consider adding another level of front-end data forwarding to distribute the pressure to two or more hardware systems.   Details Published on 2021-11-15 16:11
Personal signature为江山踏坏了乌骓马,为社稷拉断了宝雕弓。
 

1w

Posts

25

Resources
2
 

Different systems may have different processing methods. Some can discard old data, while others need to cache first and process the old data before processing the new data.

This post is from stm32/stm8
 
 

122

Posts

2

Resources
3
 

It mainly depends on the importance of the data. For unimportant data, it is usually directly overwritten. For important data, the receiving buffer is enlarged and all are stored. Process them in sequence.

This post is from stm32/stm8
 
 

3184

Posts

0

Resources
4
 

Thank you

This post is from stm32/stm8
 
Personal signature为江山踏坏了乌骓马,为社稷拉断了宝雕弓。
 
 

39

Posts

0

Resources
5
 

1. If the serial port has a register such as FIFO, it can store several frames of data, and if it is not full, the new frame of data will not be lost.
2. If the serial port does not have FIFO, the old frame will be overwritten by the new one if it cannot be processed in time. "The serial port interrupt has data that cannot be processed in time, and a new one comes" --- It means that other interrupts are running, and their interrupt priority is not lower than the serial port interrupt, and their running time exceeds the interval between the two frames before and after the serial port; there are two situations: one is that the serial port data loss is not important, and the other is that there is a problem with the interrupt design.

This post is from stm32/stm8
 
 
 

6773

Posts

2

Resources
6
 

There are many ways. To take the most extreme example, the data is very important and continuous and cannot be lost, and the hardware FIFO of the serial port is full.

Scenario 1: If the content of the previous frame is currently being processed, but the content of the next frame is more important, you can interrupt the processing of the current frame and save the scene. If the scene cannot be saved, save the original data of the previous frame and process the next frame first.

Scenario 2: If the data is continuous, the previous frame must be processed first, and the next frame will be stored in the self-defined cache.

Scenario 3: If an RTOS system is used, another task can be started to process the next frame of data, so that two frames of data can be processed simultaneously.

This post is from stm32/stm8

Comments

Very accurate analysis  Details Published on 2021-11-12 13:56
 
 
 

1412

Posts

3

Resources
7
 
There are many methods. Take the most extreme case. The data is very important and continuous and cannot be lost. The hardware FIFO of the serial port is also full. Scenario 1: If the content of the previous frame is currently being processed, but the content of the next frame is more important, you can interrupt the processing of the current frame and save the scene. If the scene cannot be saved, save the original data of the previous frame and process the next frame first. Scenario 2: If the data is continuous, you must process the previous frame first, and the next frame will be stored in the cache you define. Scenario 3: If an RTOS system is used, you can start another task to process the data of the next frame, and the two frames of data can be processed at the same time.

Very accurate analysis

This post is from stm32/stm8
 
 
 

3184

Posts

0

Resources
8
 

They are all experts.

This post is from stm32/stm8
 
Personal signature为江山踏坏了乌骓马,为社稷拉断了宝雕弓。
 
 

2870

Posts

4

Resources
9
 

There is another solution to handle extreme situations: the data is very important, the data is continuous, the buffer is full, and it cannot be processed temporarily. Usually, a frame structure can be added, and a data receiving response can be designed. At this time, a request can be issued to the sender to suspend sending. What if there is no response? The sender can be asked to send more than twice. The data from the two times is received together.

This post is from stm32/stm8
 
 
 

7452

Posts

2

Resources
10
 

If this situation is sporadic, then caching is likely to solve the problem.

If this situation is the norm, it means that your hardware system load has reached its limit and there is no room for improvement. You can consider using hardware that responds more quickly and runs faster.

If even if you spend more money on a hardware system that cannot meet your data pressure, you can only coordinate with the business to reduce the data pressure.

If none of the above works and the business pressure cannot be adjusted, consider adding another level of front-end data forwarding to distribute the pressure to two or more hardware systems.

This post is from stm32/stm8
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

3184

Posts

0

Resources
11
 

Thank you

This post is from stm32/stm8
 
Personal signature为江山踏坏了乌骓马,为社稷拉断了宝雕弓。
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>
Featured Posts
C51 programming of real-time clock chip DS1302

C51 programming of real-time clock chip DS1302 is divided into 8 parts

The significance of failure analysis

1. Failure analysis is to find out the cause of failure and take effective measures to prevent similar failure accidents ...

Power supply control principle of three-phase fuel pump used in Mercedes-Benz passenger cars

Masters, the gasoline pump used in Mercedes-Benz cars currently has three wires UVW coming out of the fuel pump computer ...

MSP430 MCU general I/O port settings sharing

In the first chapter, we will learn about I/O. I/O operation is the most basic, and these registers must be firmly maste ...

BMA400 triaxial accelerometer development

This post was last edited by Blkhumor on 2021-3-31 12:19 ****Main text**** # Introduction to BMA400 Bosch BMA400 tria ...

Domestic MCU replacement: a pitfall

  As a fan of Butterfly, I feel sorry for the shortage and price increase of STM32. But whether you are making product ...

[CB5654 Intelligent Voice Development Board Evaluation] Development Environment Construction

To evaluate and develop the development board, the construction of the development environment is indispensable. The CDK ...

MOS tube selection problem

I want to use a SOT23 MOS tube to drive a 24V/180MA solenoid valve. The maximum power dissipation here is 2.5W, but 24*0 ...

[Boliu BL606P audio and video development board] Smart speaker test

1af9ebbc234f3a6b60f0b3aeeb081b26 Preface In the previous article, we conducted a Bluetooth audio playback test, and in ...

Ultra-small package TI MSPM0 MCU can optimize design space and realize more possibilities. The live broadcast entrance is open!

Enter the live broadcast room 【Live broadcast time】 10:00-11:00 am, June 12 (today) Note: Registered users can log ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list