1. Initialization function
GPIO_Init(GPIOB, GPIO_Pin_3, GPIO_Mode_In_FL_IT);
EXTI_SetPinSensitivity(GPIO_Pin_3, EXTI_Trigger_Falling); //Error, will be explained below
2. Interrupt function
INTERRUPT_HANDLER(EXTI3_IRQHandler,11)
{
EXTI_ClearITPendingBit(EXTI_IT_Pin3);
//
}
3. Questions and explanations
I won't go into details about the specific use of the function, which can be found in the firmware library and manual. When testing, I found that when the signal input is a falling edge and remains at a low level, it will trigger repeatedly, which seems to be configured as a falling edge and low level trigger mode. I debugged for a long time but couldn't find the problem. Finally, I looked at the library function again and found the correct configuration is
EXTI_SetPinSensitivity(EXTI_Pin_3, EXTI_Trigger_Falling);
At first I also noticed that EXTI_Pin_3 should be used instead of GPIO_Pin_3, but based on my experience in programming AVR, I thought that these two macros were both defined as 3, and if they were not 3, they should be the same, so I didn't think much about it.
Open the corresponding header file and look at these two macro definitions
GPIO_Pin_0 = ((uint8_t)0x01), /*!< Pin 0 selected */
GPIO_Pin_1 = ((uint8_t)0x02), /*!< Pin 1 selected */
GPIO_Pin_2 = ((uint8_t)0x04), /*!< Pin 2 selected */
GPIO_Pin_3 = ((uint8_t)0x08), /*!< Pin 3 selected */
GPIO_Pin_4 = ((uint8_t)0x10), /*!< Pin 4 selected */
GPIO_Pin_5 = ((uint8_t)0x20), /*!< Pin 5 selected */
GPIO_Pin_6 = ((uint8_t)0x40), /*!< Pin 6 selected */
GPIO_Pin_7 = ((uint8_t)0x80), /*!< Pin 7 selected */
EXTI_Pin_0 = (uint8_t)0x00, /*!< GPIO Pin 0 */
EXTI_Pin_1 = (uint8_t)0x02, /*!< GPIO Pin 1 */
EXTI_Pin_2 = (uint8_t)0x04, /*!< GPIO Pin 2 */
EXTI_Pin_3 = (uint8_t)0x06, /*!< GPIO Pin 3 */
EXTI_Pin_4 = (uint8_t)0x10, /*!< GPIO Pin 4 */
EXTI_Pin_5 = (uint8_t)0x12, /*!< GPIO Pin 5 */
EXTI_Pin_6 = (uint8_t)0x14, /*!< GPIO Pin 6 */
EXTI_Pin_7 = (uint8_t)0x16 /*!< GPIO Pin 7 */
You can see that they are not the same.
Looking at the manual again, the interrupt is configured as falling edge and low level trigger mode by default.
summary:
Using library functions is certainly convenient and quick, but sometimes you can't be too quick on the slack. If you encounter a problem, you should carefully read the library functions and manuals.
Previous article:STM8L052R8 big and small end test
Next article:STM8 low power design
Recommended ReadingLatest update time:2024-11-16 13:00
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- 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
- Automotive electronics such as car chargers and wireless chargers
- 220V AC to 18V DC
- DSPF28335 Study Notes
- Anyone know what component this is?
- 【AT-START-F425 Review】-Recording the use of CAN communication
- HDI blind hole design, did you notice this detail?
- EEWORLD University Hall----Design of DC power supply system for battery testing equipment
- This is a brain teaser - hypotenuse, leg, chord, even Pythagorean theorem
- Should the PCB trace angle not be 90°? — PCB Layout Tips
- Problems with serial programming of STC89C51RC microcontroller