STM8->EXTI

Publisher:芳华逝水Latest update time:2019-01-26 Source: eefocusKeywords:STM8  EXTI Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Interrupts, especially external interrupts, are an important means for MCU to implement complex functions.




Interrupt sources and vectors:


    All I/O pins have external interrupt capability, and each port has an independent interrupt vector and independent flag.


    Interrupts of various functional peripherals


    Up to 32 interrupt vectors (entry addresses are fixed by hardware), up to 40 external interrupt sources (4 levels of programmable software nesting priority), 11 of which are assigned as external interrupts.



Priority and response logic:


    Reset has the highest priority and all interrupts are disabled during reset.



There can be several interrupts queued for processing at the same time:


1. The interrupt with the highest software priority is responded to; (the software priority of each interrupt is configured through ITC->SPRx registers I1 and I0)


2. If several queued interrupts have the same software priority, the interrupt with the highest hardware priority is responded to first. //The hardware priority of the interrupt is unique and mutually exclusive


    Hardware interrupt priority low->high: MAIN, IT4, IT3, IT2, IT1, IT0, TRAP and RESET. Interrupt masking can be achieved through bits I1 and I0 of the CC register and ITC->SPRx to set the software priority. PD7 is the highest priority hardware interrupt source TLI entry.




Management of interruptions


1. All priorities in concurrent interrupt management mode are level 3, except for responding to RESET, TRAP, and TLI interrupts, which cannot be interrupted;


2. The nested interrupt management mode allows interrupts to be responded to in the interrupt program; this mode becomes effective immediately once the priority of an interrupt is lower than level 3;


Use the interrupt controller ITC to manage each interrupt:


    Non-maskable events: RESET, TRAP; non-maskable highest priority hardware interrupt TLI


    Non-maskable interrupts: RESET, TLI and TRAP have the highest software priority to handle, regardless of the status of I1 and I0 of the CC register.


    The TRAP instruction is prohibited in the TLI interrupt service subroutine. The TLI interrupt can interrupt (except TRAP and RESET) level 3 software interrupts. The software interrupt TRAP cannot cause the processor to exit from the Halt mode.






Configuration and use of simple interrupts (taking STM8L151 as an example):


    GPIO_Init(KEY_PORT, KEY_Pin, GPIO_Mode_In_FL_IT);


    EXTI_DeInit(); 


    EXTI_SetPinSensitivity(EXTI_Pin_4,EXTI_Trigger_Falling);


If you use registers to configure interrupts:


Register EXTI->CR1 function definition



Register EXTI->CR2 function definition



Enable interrupt


    {asm("rim"); }== {enableInterrupts();}


The definition of interrupt in the stm8l15x.h file is as follows:


 #define enableInterrupts() __enable_interrupt() /* enable interrupts */

 #define disableInterrupts() __disable_interrupt() /* disable interrupts */

 #define rim() __enable_interrupt() /* enable interrupts */

 #define sim() __disable_interrupt() /* disable interrupts */




Detailed 32 interrupt vector definitions:


#define FLASH_EOP_vector 0x03

#define FLASH_WR_PG_DIS_vector 0x03

#define DMA1_CH0_HT_vector 0x04

#define DMA1_CH0_TC_vector 0x04

#define DMA1_CH1_HT_vector 0x04

#define DMA1_CH1_TC_vector 0x04

#define DMA1_CH2_HT_vector 0x05

#define DMA1_CH2_TC_vector 0x05

#define DMA1_CH3_HT_vector 0x05

#define DMA1_CH3_TC_vector 0x05

#define RTC_ALARM_vector 0x06

#define RTC_WAKEUP_vector 0x06

#define EXTIE_vector 0x07

#define EXTIF_vector 0x07

#define EXTIPVD_vector 0x07

#define EXTIB_vector 0x08

#define EXTID_vector 0x09

#define EXTI0_vector 0x0A

#define EXTI1_vector 0x0B

#define EXTI2_vector 0x0C

#define EXTI3_vector 0x0D

#define EXTI4_vector 0x0E

#define EXTI5_vector 0x0F

#define EXTI6_vector 0x10

#define EXTI7_vector 0x11

#define CLK_CSS_vector 0x13

#define CLK_SWITCH_vector 0x13

#define TIM1_BIF_vector 0x13

#define COMP_EF1_vector 0x14

#define COMP_EF2_vector 0x14

#define TIM2_OVR_UIF_vector 0x15

#define TIM2_CAPCOM_BIF_vector 0x16

#define TIM2_CAPCOM_CC1IF_vector 0x16

#define TIM2_CAPCOM_CC2IF_vector 0x16

#define TIM2_CAPCOM_TIF_vector 0x16

#define TIM3_OVR_UIF_vector 0x17

#define TIM3_CAPCOM_BIF_vector 0x18

#define TIM3_CAPCOM_CC1IF_vector 0x18

#define TIM3_CAPCOM_CC2IF_vector 0x18

#define TIM3_CAPCOM_TIF_vector 0x18

#define TIM1_OVR_UIF_vector 0x19

#define TIM1_CAPCOM_CC1IF_vector 0x1A

#define TIM1_CAPCOM_CC2IF_vector 0x1A

#define TIM1_CAPCOM_CC3IF_vector 0x1A

#define TIM1_CAPCOM_CC4IF_vector 0x1A

#define TIM1_CAPCOM_COMIF_vector 0x1A

#define TIM1_CAPCOM_TIF_vector 0x1A

#define TIM4_TIF_vector 0x1B

#define TIM4_UIF_vector 0x1B

#define SPI_MODF_vector 0x1C

#define SPI_OVR_vector 0x1C

#define SPI_RXNE_vector 0x1C

#define SPI_TXE_vector 0x1C

#define SPI_WKUP_vector 0x1C

#define USART_T_TC_vector 0x1D

#define USART_T_TXE_vector 0x1D

#define USART_R_IDLE_vector 0x1E

#define USART_R_OR_vector 0x1E

#define USART_R_PE_vector 0x1E

#define USART_R_RXNE_vector 0x1E

#define I2C_ADD10_vector 0x1F

#define I2C_ADDR_vector 0x1F

#define I2C_AF_vector 0x1F

#define I2C_ARLO_vector 0x1F

#define I2C_BERR_vector 0x1F

#define I2C_BTF_vector 0x1F

#define I2C_OVR_vector 0x1F

#define I2C_RXNE_vector 0x1F

#define I2C_SB_vector 0x1F

#define I2C_STOPF_vector 0x1F

#define I2C_TXE_vector 0x1F

#define I2C_WUFH_vector 0x1F


Keywords:STM8  EXTI Reference address:STM8->EXTI

Previous article:STM8->GPIO
Next article:Use of STM8L15x series DAC

Recommended ReadingLatest update time:2024-11-23 15:20

STM32 external interrupt operation
The CM3 core supports 256 interrupts, including 16 core interrupts and 240 external interrupts, and has 256 levels of programmable interrupt settings. However, the STM32 does not use all of the CM3 core, but only uses part of it. The STM32 has 76 interrupts, including 16 core interrupts and 60 maskable interrupts, with
[Microcontroller]
How to set read protection and remove read protection using STVP programming program in STM8 series chips
First, open STVP, open the program to be burned (Open), if you want to read protect the chip, just set the protection option to ON. As shown in the figure below: Click Write All, and you will be prompted to set protection. Click "Yes" to write protection. After the above writing is completed, both reading and writin
[Microcontroller]
How to set read protection and remove read protection using STVP programming program in STM8 series chips
STM8 simulation debugging quick start
● Installation of ST Visual Develop   Go to the ST official website:  http://www.st.com/stonline/products/support/micro/files/sttoolset.exe  to download and install. ● Setting up ST Visual Develop software and creating and opening related debugging files   - using Cosmic C language, software simulation   If you want
[Microcontroller]
STM8 simulation debugging quick start
Benefits of STM8--Atomthreads real-time operating system
Atomthreads is an open source real-time operating system. It was designed for STM8s when it was first created, and the author is still updating it. I think the latest major modification is to add support for more MCUs. There is no change in the algorithm. So I took version 1.3, which is enough. I am using the smalle
[Microcontroller]
Benefits of STM8--Atomthreads real-time operating system
STM32 EXTI small experiment
stm32 does not use all 256 interrupts of Cortex-M3, only a part of it (16 cores + 68 external interrupts) Interrupt Line        Pin 0 of all GPIO ports corresponds to the EXTI0 interrupt line, and similarly PA1~PG1 correspond to the EXTI1 interrupt line. Interrupt service function        The interrupt service
[Microcontroller]
STM8 Windowed Watchdog (WWDG)
STM8 Window Watchdog Introduction The window watchdog is used to monitor software errors caused by external interference or unpredictable logic conditions. Such software errors usually cause the application program to run in an unexpected manner. Unless the program refreshes the down counter before the T6 bit of the d
[Microcontroller]
STM8 Windowed Watchdog (WWDG)
MCU external interrupt program (give P3.2 pin low level, LED will show the inverted state)
A very simple external interrupt program, I hope it will be helpful to those who are learning #include reg52.h sbit k3=P3^2; //define key K3 sbit led=P2^0; //define P20 port as LED void delay(unsigned int i) //delay function, when i=1, the delay is about 10us { while(i--); } void Int0Init()
[Microcontroller]
STM8 I2C slave mode
STM8 I2C slave mode In order to generate the correct timing, the input clock to the module must be set in the I2C_FREQR register. The frequency of the input clock must be at least: In standard mode: 1MHz Fast mode: 4MHz Once the start condition is detected, the address received on the SDA line is sent to the shift r
[Microcontroller]
STM8 I2C slave mode
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号