Was added to look at the serial loop of the transmit data queue

 

 First, why should use circular queue to send data? What is the problem in order to solve it!

 

 

 

This section says how to use interrupt transmission of data, but if you thought that this interruption has sent a bug, look at the following

 

 

 

 

He would have wanted to see did not reply

qwertyuioaqwertyuioa The reply is qqwertyuioa

 

Actually bug is obvious, since the transmission is no longer occupied by the main loop, so the next instruction will be sent immediately! Then put the first obliterated

 

 

The idea now is the need for a cache, I kept to the cache and write data, the serial port transmit interrupt constantly taken out from the cache, and then sent out!

Direct use of the circular queue is a good choice.

I sent the data written into the ring queue, and then open the serial port transmit interrupt

Serial port transmit interrupt which determines the number of data inside the circular queue is not greater than 0, if it is sent out to the student!

 

Second, define some variables

 

 

 

 

 

 

 

 

Third, then an array of variables to manage the queue to ring

 

 

Fourth, there is such a serial port transmit interrupt

 

Fifth, modify ring a function of the queue, the data is completely filled break open

 

 

Sixth, the test now

 

 

 

 

 

Now the data will not be lost!

 

Note: Even if the use of a circular queue in main loop which do not

 

 

 

 Circular queue buffer is limited! Well as long as the baud rate is set, an interrupt transmission time per bit of data is certain to send data will certainly need time!

Now is the direct cause of death,

 

 

In fact, the cause of the crash is due to the use of printf inside the circular queue,

 

 The printf not interrupt transmission, resulting in a conflict

 

 

Change it

 

 

 

 

Guess you like

Origin www.cnblogs.com/yangfengwu/p/11671297.html
Recommended