To make an IO port as an interrupt source for an external interrupt, three settings must be made. First, the direction of the IO port must be set to input; second, the trigger mode of the external interrupt must be selected, that is, whether it is a rising edge trigger or a falling edge trigger; third, the interrupt of the IO port must be enabled.
For example, if we want to set P1.0 as an external interrupt source, we can set it like this:
P1DIR&= ~BIT0; //Direction is set as input
P1IES |= BIT0; //trigger mode setting
P1IE |= BIT0; // Enable interrupt
In the trigger mode setting, 0 is rising edge trigger and 1 is falling edge trigger. After the setting is completed, you can use the external interrupt triggered by the falling edge or rising edge of the P1.0 port.
It should be noted that if interrupts are used in a design program, the general interrupt must be enabled before using the interrupt. The statement to enable the general interrupt in the IARfor430 environment is: _EINT(); Just like if we want to turn on the three lights A, B, and C, we need to turn on the main power switch in addition to turning on the switches of the three lights A, B, and C, otherwise the lights will not light up. The corresponding statement to turn off the general interrupt is: _DINT();
Previous article:Msp430 MCU clock module
Next article:Design based on stepper motor driver MC33991
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Recently I made a [51 MCU building block graphical Chinese programming software/C language code generator/circuit simulation]
- Regarding the use of serial ports for ESP32 MicroPython - Thanks!
- Qorvo Design Tools - The Go-to Resource for RF Projects
- FPGA Learning
- Causes of circuit failure
- The RT-Thread MicroPython development environment version 1.0.0 has been officially released. Let me share it with you.
- "Recommend Chinese chips" + domestic chips
- 【NXP Rapid IoT Review】 NO3. Receiving data from the cloud
- Littelfuse Efficient, Reliable, Accurate Power Control and Circuit Protection Solutions
- What issues need to be considered when using MCU development boards as industrial application boards