Principle of Microcomputer-07-Interrupt System

Interrupt the system

###definition

"Interrupt" means that the CPU temporarily stops the program being executed, and transfers to execute the service program requesting the internal and external events that the CPU serves. After the service program is executed, it returns to the suspended program to continue running.

The role of interruption

  • (1) Can improve the working efficiency of the
    CPU With the interrupt function, the CPU can start multiple peripherals to work at the same time through time-sharing operation, and can manage them uniformly. CPU can avoid unnecessary waiting and query by interrupting when exchanging information with peripherals, thus greatly improving its work efficiency
  • (2) It can improve the processing time of real-time data.
    In the real-time control system, the real-time parameters, over-limit data and fault information of the controlled system must be collected, analyzed, judged and processed by the computer in time in order to implement correct adjustment and control. With the interrupt function of the CPU, abnormal and faults of the system can be immediately notified to the CPU through the interrupt, so that it can quickly collect real-time data and fault information,
    and make emergency treatment for the system.

Interrupt source

1. External device interrupt sources
Computer peripherals such as printers and keyboards can be used as interrupt sources.

2. Control object interrupt source The
controlled object is often the main interrupt source of real-time control computer.

3. Fault interrupt source

4. Timer pulse interrupt source
The signal generated when the timer / counter overflows can cause the CPU to be interrupted, so that the CPU can perform timing or counting processing in order to achieve the purpose of time or counting control.

5. Source of interrupt caused by software

Interrupt classification

1. According to the position classification of the interruption
(1) External interrupt, or external hardware real-time interrupt, it is generated by a specific pin sent to the CPU from the outside.
(2) Internal interruption, or software instruction interruption, is an interruption provided to deal with some unexpected situations that occur during the running of the program or the convenience of debugging the program.

2. According to the way of accepting interrupts
(1) maskable interrupts
(2) non-maskable interrupts, as long as the interrupt source requests, the CPU must respond, mainly used for emergency treatment, such as power failure.

Interrupt process

Interrupt nesting

#### Interrupt response conditions

① In total broken allowed to open , IE register interrupt enable bit total EA (IE.7) is set, i.e. EA 1.
② The interrupt enable bit of this interrupt source is "1", that is, the interrupt is not masked.
③ The interrupt source issues an interrupt request, that is, the interrupt request flag corresponding to the interrupt source is "1".
④ No interrupt of the same level or higher is being serviced.
The first two conditions need to be set by programming in the program.

Exercise

3. What is an interrupt source? What are the interrupt sources for AT89S51? What are the characteristics of each?

**** Answer: **** The cause of the interruption is called the source of the interruption. The AT89S51 interrupt system has 5 interrupt request sources:

(1) External interrupt request 0, the interrupt request flag is IE0.

(2) External interrupt request 1, the interrupt request flag is IE1.

(3) Timer / counter T0 overflow interrupt request, the interrupt request flag is TF0.

(4) Timer / counter T1 overflow interrupt request, the interrupt request flag is TF1.

(5) Serial port interrupt request, the interrupt request flag is TI or RI.

Features: 2 external interrupt sources and 3 internal interrupt sources.

5. What are the six interrupt flag bit codes of AT89S51? Under what circumstances are they set and reset?

answer:

(1) The external interrupt 0 interrupt request flag is IE0.

(2) The external interrupt 1 interrupt request flag is IE1.

(3) The timer / counter T0 overflow interrupt request flag is TF0.

(4) The timer / counter T1 overflow interrupt request flag is TF1.

(5) The serial port transmission interrupt request flag is TI.

(6) The serial port receive interrupt request flag is RI.

Each flag bit is set due to a corresponding interrupt request, the first four flag bits are reset due to the corresponding interrupt request, and the last two flag bits are reset by software in the interrupt service routine.

image-20200327150432101

*answer:*

The procedure is:

Bit manipulation instructions:

SETB PX0

SETB PX1

SETB EA

SETB EX0

SETB  EX1

Use byte manipulation instructions:

MOV IE,#85H

MOV IP , # 05H

image-20200327150445519

10. Try to write img[External chain image transfer failed, the source site may have an anti-theft chain mechanism, it is recommended to save the image and upload it directly (img-ET8yqRD4-1586394702574) (file: /// C: \ Users \ JACKIN ~ 1 \ AppData \ Local \ Temp \ ksohtml17144 \ wps15.png)] is the interrupt initialization program for the falling edge trigger mode.

*answer:*

ORG 0000H

    AJMP MAIN 

ORG 0013H

    AJMP PINT1

    ORG 0100H 

MAIN:  SETB IT1

      SETB EX1 

SETB EA

  HERE: AJMP HERE

  PINT1: RETI 

END

17. After the AT89S51 microcontroller responds to the interrupt, it generates a hardware long call instruction LCALL. The process of executing the instruction includes: first pushing the content of (PC) onto the stack for breakpoint protection, and then sending the 16-bit address of the long call instruction (PC), Turn program execution to the interrupt address area in (program memory).

Published 225 original articles · Like 140 · Visit 250,000+

Guess you like

Origin blog.csdn.net/jankin6/article/details/105402806