STM32- external interrupt EXTI

Brief introduction

External Interrupt / Event Controller (EXTI) management controller 23 interrupt / event line. Each interrupt / event corresponds to a line edge detector, detecting the rising edge detection can be realized and the falling edge of the input signal. EXTI can be implemented individually configured for each interrupt / event line can be configured to interrupt or event, as well as triggering properties of the event alone.

Functional Block Diagram

We can see a lot of play on the signal line and a slash mark "23" character, this representation inside the controller similar to the signal line has 23, which EXTI a total of 23 interrupt / event line in Figure 17-1 consistent. So long as we understand one principle, and that principle 22 other lines will know.

5d305d1ee535277097

First, we look at Figure 17-1 red dotted line indicates the flow circuit. It is an interrupt generated line signal ultimately flows into the NVIC controller.

Line number 1 is input, the controller 23 the EXTI interrupt / event input lines, these lines may be input by a register set to any GPIO, provides also some peripheral events.

No. 2 is a edge detection circuit, it triggers the rising edge of select register (EXTI_RTSR) and a falling edge trigger selection register (EXTI_FTSR) arranged to control the position corresponding to the trigger signal. Edge detection circuit as the input signal input line, if there is an edge transition is detected on the valid signal output circuit 3 to the No. 1, otherwise the output signal of 0 is invalid. While the two registers can EXTI_FTSR EXTI_RTSR and what kinds of controllers Jump detection level may be only rising edge triggered, only the rising and falling or falling edge trigger triggers.

3 is a circuit number or actual gate circuit which inputs a number from the second circuit, a further input from the software interrupt event register (EXTI_SWIER). EXTI_SWIER allow we can start interrupt / event program control line, which is useful in some places. We know that there is a door or action "to 1, so that just a two input valid signal can be output 1 1 to No. 4 and No. 6 circuit.

4 is a circuit numbered AND circuit, an input number which third circuit, a further input from the interrupt mask register (EXTI_IMR). An AND gate circuit requires inputs are 1, only output 1, caused if EXTI_IMR set to 0, then regardless of the output signal number 3 circuit is 1 or 0, the signal eventually number 4 circuit outputs are 0; if EXTI_IMR set 1, No. 4 final signal circuit outputs an output signal only determined by the number of circuit 3, and we achieved a simple control EXTI_IMR whether an interrupt object. 4 are numbered circuit output signal is stored into the pending register (EXTI_PR) inside, if the number is determined as an output circuit 4 will be a position corresponding to the EXTI_PR.

No. 5 is the output EXTI_PR register contents into the NVIC, in order to achieve control system interrupt events.

Next we look at the green dotted lines indicate the flow circuit. It is a generating line of the event, the final output signal is a pulse. Generating event is in line after number 3 circuit interrupt line is different, before the circuit are shared.

No. 6 is an AND gate circuit, an input number which third circuit, a further input from the event mask register (EXTI_EMR). If EXTI_EMR set to 0, then regardless of the output signal number 3 circuit is 1 or 0, the final number 6 circuit output signals are 0; if EXTI_EMR is set to 1, the signal 6 circuit outputs the final number only by the number 3 circuit the output signal of the decision, so we can easily control whether a EXTI_EMR to achieve the purpose of the event.

No. 7 is a pulse generator circuit, as its input, i.e., the output of circuit number 6 is a 1 pulse will produce a valid signal; if the input signal is not a valid output pulse.

No. 8 is a pulse signal, to produce the final product is the line event, the pulse signal may be used for other peripheral circuit, such as the TIM timer, an analog to digital converter ADC and the like.

The purpose is to generate an interrupt line input signal input to NVIC, further runs interrupt service function, realize the function, this is the software level. Generating event transmission line object is a pulse signal to other peripherals used, and a level signal transmission circuit, a hardware level.

In addition, EXTI APB2 is on the bus, when the program need to be aware of this.

Line interrupt event

EXTI 23 interrupt / event lines, each GPIO can be configured as an input line, taking EXTI0 to EXTI15, there is another seven peripherals for specific events, see Table 17-1.

Seven specific peripheral interrupt / event triggered by the peripheral line, the specific use of reference "STM32F4xx Chinese Reference Manual" for specific instructions on peripherals.

5d305d6b6c56763248

EXTI0 to EXTI15 for GPIO, provides programmed control of one arbitrary as GPIO input source of EXTI. As apparent from Table 17-1, EXTI0 configuration register EXTI0 1 (SYSCFG_EXTICR1) [3: 0] bits can be interrupted by an external SYSCFG configured to select PA0, PB0, PC0, PD0, PE0, PF0, PG0, PH0 or PI0, see FIG. 17-2. Other EXTI line (EXTI interrupt / event line) using the configuration are similar.

5d305d77755d682336

Detailed structure initialization EXTI

Standard library functions for each peripheral initialization has established a structure, such as EXTI_InitTypeDef, structure members used to set the operating parameters of peripherals by peripheral initialization configuration functions, such as EXTI_Init () call, which will set the parameters provided the corresponding peripheral registers configure peripheral purpose working environment.

Initialize structure and initialization library function is used in conjunction with standard library essence, understand the significance of each member of the initialization structure basically you can use it freely of the peripherals. Initialize structure is defined in stm32f4xx_exti.h file, initializing the library function is defined in stm32f4xx_exti.c file programming we can use in conjunction with comments within two files.

Listing 17-1 EXTI initialization structure

typedef struct {
    uint32_t EXTI_Line; // 中断/事件线
    EXTIMode_TypeDef EXTI_Mode; // EXTI 模式
    EXTITrigger_TypeDef EXTI_Trigger; // 触发事件
    FunctionalState EXTI_LineCmd; // EXTI 控制
} EXTI_InitTypeDef;
  1. EXTI_Line: EXTI interrupt / event line selection, optional EXTI0 to EXTI22, refer to Table 17-1 choice.

  2. EXTI_Mode: EXTI mode is selected, optionally generate an interrupt (EXTI_Mode_Interrupt) or generate an event (EXTI_Mode_Event).

  3. EXTI_Trigger: EXTI edge trigger event, optional rising edge triggered (EXTI_Trigger_Rising), falling edge trigger (EXTI_Trigger_Falling), or both rising and falling edge trigger (EXTI_Trigger_Rising_Falling).

  4. EXTI_LineCmd: EXTI control line is enabled, optionally EXTI enable line (the ENABLE) or disabling (DISABLE).

Guess you like

Origin www.cnblogs.com/luoxiao23/p/11209630.html