There are two modes of STM8L interrupts, namely Pin mode and Port mode, which are the so-called line interrupts and port interrupts.
In short, line interrupt means that the interrupts of the same pin of all register groups use the same interrupt number, such as,
void KEY2Init()
{
PB_DDR_bit.DDR2 = 0; //GPB->PIN2 Set the input and output direction register of port PB->2 to input direction
PB_CR1_bit.C12 = 1; //GPB->PIN2 input with pull-up resistor
PB_CR2_bit.C22 = 1; //GPB->PIN2 enables external interrupt
// Use the second port as interrupt so select P2Is
EXTI_CR1_bit.P2IS = 2; //10 tx port bit2 external interrupt line 2 is a falling edge triggered interrupt
EXTI_CONF_bit.PBLIS = 0; //Set PB[3:0] as the lower 4 bits of the external general interrupt PB port
}
Port interrupt means that all the pins of the same or multiple register groups use the same interrupt number.
void KEY3Init()
{
PD_DDR_bit.DDR3 = 0; //GPD->PIN3 Set port PD->3 input direction
PD_CR1_bit.C13 = 1; //GPD->PIN3 input with pull-up resistor
PD_CR2_bit.C23 = 1; //GPD->PIN3 enables external interrupt
EXTI_CR3_bit.PDIS = 2; //PortD port external interrupt line 2 is a falling edge triggered interrupt
EXTI_CONF_bit.PDLIS = 1; //Set PD as external general interrupt
}
For example,
The interrupt of Pin1 of all Port A/B/C/D/E is EXTI1.
All pin interrupts of Port B and Port G are EXTIB/G
It can be understood that line interruption is specific to that pin, and port interruption is specific to that port.
A type of port can contain many pins.
When written in register mode, the two are very similar, with the following difference (please look carefully at the following two lines of code):
1. EXTI_CR1_bit.P2IS = 2; //10 tx port bit2 external interrupt line 2 is a falling edge triggered interrupt
2. EXTI_CR3_bit.PDIS = 2; //PortD port external interrupt line 2 is a falling edge triggered interrupt
Previous article:STM8S Self-study Notes-006 GPIO input: key input and key filtering
Next article:Build STM8S001 development environment
Recommended ReadingLatest update time:2024-11-15 21:09
- Popular Resources
- Popular amplifiers
- STM8 C language programming (1) - basic program and startup code analysis
- Description of the BLDC back-EMF sampling method based on the STM8 official library
- STM32 MCU project example: Smart watch design based on TouchGFX (8) Associating the underlying driver with the UI
- uCOS-III Kernel Implementation and Application Development Practical Guide - Based on STM32 (Wildfire)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- The story I have to tell about Yatli+!
- Misuse of "termination" will cause signal failure
- Raspberry Pi Pico is out~ I originally said that I would not review it before the New Year, but I am here to recommend this board to you~~
- PyBoard W5500 firmware compilation issue
- Discussion and help
- "Playing with the board" + lighting up the SPI touch screen of Xintao
- &FF0000 and &880000 are both red. What is the difference between these two reds?
- Internet radio design based on RSIC-V RVB2601 (3)
- LIS2MDL three-axis magnetometer package and code
- Live broadcast with prizes: Enter the TI robot production class, starting on Friday, reservations are in progress! (Share 100% to get gifts)