Function description/*All timing 1S*/
#define F_CPU 16000000UL
#include "DS12864.h"
#include #include volatile unsigned int count0=0,flag0=0; volatile unsigned int count1=0,flag1=0; volatile unsigned int count2=0,flag2=0; volatile unsigned int count3=0,flag3=0; /********************************************************************** Subordinate module: timer test module Function Name: Timer0_Init() Function: Initialization Entry parameters: None Return parameter: None *******************************************************************/ void Timer0_Init() { TCNT0 = 0x06; TCCR0 = 0x03; //64 division TIMSK |= (1< } /********************************************************************** Subordinate module: timer test module Function Name: Timer1_Init() Function: Initialization Entry parameters: None Return parameter: None *******************************************************************/ void Timer1_Init() { TCNT1H = 0x3C; TCNT1L = 0xB0; TCCR1A = 0x00; TCCR1B = 0x03; //64 division TIMSK |= (1< } /********************************************************************** Subordinate module: timer test module Function Name: Timer2_Init() Function: Initialization Entry parameters: None Return parameter: None *******************************************************************/ void Timer2_Init() { TCNT2 = 0x06; TCCR2 = 0x03; //64 division TIMSK |= (1< } /********************************************************************** Subordinate module: timer test module Function name: Timer3_Init() Function: Initialization Entry parameters: None Return parameter: None *******************************************************************/ void Timer3_Init() { TCNT3H = 0x3C; TCNT3L = 0xB0; TCCR3A = 0x00; TCCR3B = 0x03; //64 division ETIMSK |= (1< } /****************************Test function***************************/ int main(void) { DDRD = 0xF0; DDRE = 0xF0; LCD12864_Init(); SREG &=~(1<<7); Timer0_Init(); Timer1_Init(); Timer2_Init(); Timer3_Init(); SREG |= (1<<7); LCD12864_Dis_Str(0,0,"Timer 0:"); LCD12864_Dis_Str(0,1,"Timer 1:"); LCD12864_Dis_Str(0,2,"Timer 2:"); LCD12864_Dis_Str(0,3,"Timer 3:"); while(1) { //TODO:: Please write your application code if(count0>1999){ count0=0; flag0=(flag0+1)%10; LCD12864_Dis_Ctr(5,0,flag0+0x30); } if(count1>4) { count1=0; flag1=(flag1+1)%10; LCD12864_Dis_Ctr(5,1,flag1+0x30); } if(count2>999) { count2=0; flag2=(flag2+1)%10; LCD12864_Dis_Ctr(5,2,flag2+0x30); } if(count3>4) { count3=0; flag3=(flag3+1)%10; LCD12864_Dis_Ctr(5,3,flag3+0x30); } } } /********************************************************************** Subordinate module: timer test module Function name: SIGNAL(TIMER0_OVF_vect) Function: Timer 0 interrupt function Entry parameters: None Return parameter: None *******************************************************************/ SIGNAL(TIMER0_OVF_vect) { TCNT0 = 0x06; count0++; } /********************************************************************** Subordinate module: timer test module Function name: SIGNAL(TIMER1_OVF_vect) Function: Timer 1 interrupt function Entry parameters: None Return parameter: None *******************************************************************/ SIGNAL (TIMER1_OVF_vect) { TCNT1H = 0x3C; TCNT1L = 0xB0; count1++; } /********************************************************************** Subordinate module: timer test module Function name: SIGNAL(TIMER2_OVF_vect) Function: Timer 2 interrupt function Entry parameters: None Return parameter: None *******************************************************************/ SIGNAL (TIMER2_OVF_vect) { count2++; } /********************************************************************** Subordinate module: timer test module Function name: SIGNAL(TIMER3_OVF_vect) Function: Timer 3 interrupt function Entry parameters: None Return parameter: None *******************************************************************/ SIGNAL (TIMER3_OVF_vect) { TCNT3H = 0x3C; TCNT3L = 0xB0; count3++; }
Previous article:ATmega128 time1 overflow interrupt. The usage of timer 1 in this mode is the same as that of 51
Next article:USART test---ATMEGA128
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
- TI E2E Chinese Community celebrates its 8th anniversary, with 8 technical collections for you who love technology!
- Several issues with the tps65130 chip
- Share the November 2018 STMicroelectronics-Shunde Motor Control Roadshow Conference Brochure
- My Journey of MCU Development (V)
- Why should we apply synchronous rectification technology?
- LTC3613DC/DC has a strange phenomenon, I hope the experts can answer it
- Understand the performance test of 18650 lithium battery - cycle test
- Sinlinx A64 Linux writes LED driver through device tree (with reference code, not tested)
- EEWORLD University Hall--Analysis of rules and techniques for high-speed PCB design
- LMV321 power supply range problem