Current location - Quotes Website - Collection of slogans - 5 1 The serial port of the single-chip computer receives the string continuously, and the interrupt takes up CPU time until the string is received.
5 1 The serial port of the single-chip computer receives the string continuously, and the interrupt takes up CPU time until the string is received.
The statement of 1 floor is obviously wrong. When the serial port receives a character (8 bits), RI will be automatically set to 1, at which time the CPU will switch from the main program for serial interrupt. Ordinary single serial port 5 1 microcontroller is generally an interrupt 4 subroutine, which will automatically return to the main program to continue execution after the end. Therefore, RI should be cleared from the end of the interrupt 4 subroutine.

The general processing method in the main program of interrupt 4 is to transfer the data in the receiving register SBUF to the predefined buffer. Note that the cache needs to be shifted when accepting strings. The routine is as follows:

Invalid serial interrupt () interrupt 4

{

Uchar temperature;

rec _ data[i++]= SBUF; // rec_data is a predefined receiving buffer, which can be continuously received until you need serial data.

RI = 0; //The reception interrupt signal is cleared, indicating that reception will continue.

}