Crystal: 7.3728 MHz
External interrupt 0, falling edge triggered.
About hardware: If you want to use external interrupts stably, it is best to pull up a resistor at the pin (usually 10K, of course, whether to pull up or pull down depends on your trigger conditions). If it is a button, you should add a capacitor (usually 104). This will have a better effect and effectively prevent jitter.
Code:
#include
#include
#include
void int0_init()
{
_CLI(); //disable all interrupts //Disable total interrupt
MCUCR = 0x02; //Falling edge triggers external interrupt 0
GICR = 0x40; //Enable external interrupt 0
GIFR_INTF0 = 1; //Clear external interrupt 0 flag
_SEI(); //re-enable interrupts //Open general interrupt
}
void main(void)
{
DDRB_Bit0 = 1; //define an LED
int0_init();
while(1);
}
#pragma vector = INT0_vect //External interrupt 0 entry address
__interrupt void ex_int0(void)
{
PORTB_Bit0 = ~PORTB_Bit0; //Each time an interrupt is entered, an LED will turn from bright to dark, and from dark to bright
}
Previous article:IAR For AVR -- LCD1602
Next article:IAR For AVR About the use of comp_a90.h header file
Recommended ReadingLatest update time:2024-11-16 15:26
- Popular Resources
- Popular amplifiers
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Metronom Real-Time Operating System RTOS for AVR microcontrollers
- IAR fully supports the new industrial-grade PX5 real-time operating system
- Learn C language for AVR microcontrollers easily (with video tutorial) (Yan Yu, Li Jia, Qin Wenhai)
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
- MM32F103 BUG reminder to avoid pitfalls
- Will MakeCode support Python?
- What are the specific differences between triodes and MOS tubes?
- How to set the GND pin of a separate component as a flower pad in PADS?
- EEWORLD University Hall----Keithley 4200A-SCS parameter analyzer accelerates semiconductor equipment, materials and process development
- EEWORLD University Hall ---- Advanced C Language Programming for Embedded Systems (Ling Ming, Southeast University)
- Two-phase brushless DC motor speed control system based on DSP and CPLD
- The main structure of the DM642 image processing program
- Multi-way switch, battery inspection instrument
- EEWORLD University ---- Wildfire FPGA Video Tutorial