#include
unsigned char n=0;
void port_init(void) //Port initialization function
{
DDRB = 0xFF; //Port B is defined as output
}
void timer1_init(void) //Timer 1 initialization: 0.5 second timing, prescaler 256
{
TCCR1B = 0x00; //stop
TCNT1H = 0xF8; //setup
TCNT1L = 0x5F;
TCCR1A = 0x00;
TCCR1B = 0x04; //start Timer
}
void main(void)
{
port_init(); //initialize output port
CLI(); //disable all interrupts
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x05; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialised
timer1_init(); //Timer 1 initialization
while(1) //loop
{
;
}
}
#pragma interrupt_handler timer1_ovf_isr:9
void timer1_ovf_isr(void) //定时中断入口
{
TCNT1H = 0xF8; //reload counter high value
TCNT1L = 0x5F; //reload counter low value
if(n>=1)
{
n=0;
PORTB=55;
}
else
{
PORTB=0xAA;
n=n+1;
}
}
Previous article:How to drive LCD1602 to display and move left and right
Next article:IIC's PCF8563 practical clock program (iccavr)
Recommended ReadingLatest update time:2024-11-16 21:00
- Popular Resources
- Popular amplifiers
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
- 54V, 1.5kW Power Stage Reference Design for Three-Phase BLDC Drives
- 2G communication project - power consumption test comparison and analysis of IoT small size modules M26 and M6315 - waiting for suggestions online!
- [MM32 eMiniBoard Review] +A/D Data Acquisition
- (Reward: 5000 RMB) ADS1220 cannot collect data
- [National Technology low power series N32L43x review] Low power consumption test.
- Review summary: Apply for the phyBOARD-i.MX 8M Plus development board worth 1,000 yuan for free
- Where can I download national standards for free?
- DIY a powerful HomeAssistant smart home system using the ESP32-S3 development board
- [RVB2601 Creative Application Development] + Unpacking and installing the development environment
- EEWORLD University ---- Intelligent Control