#define uint unsigned int
uint cnt=0; //count variable
uint on=0; //start/stop status variable
uchar start[16]=" start ";
uchar stop[16]=" stop ";
{
PORTA=0xff;
DDRA=0xff;
PORTB=0xff;
DDRB=0xff;
PORTD=0xff;
DDRD=0xff;
}
{
MCUCR=0x0a;
GICR=0xc0;
SREG=0x80;
}
void time0_init()
{
TCCR0=0x03;
TIMSK=0x01;
TCNT0=0x83;
}
{
displayonechar(10,0,(time/10)+48);
displayonechar(11,0,(time%10)+48);
}
{
port_init();
delay(15);
writecmd(0x38);
delay(5);
writecmd(0x38);
delay(5);
writecmd(0x38);
writecmd(0x80);
writecmd(0x01);
writecmd(0x06);
writecmd(0x0c);
delay(500);
//End of initialization
init();
time0_init();
while(1)
{
displaychar(0,0,str1);
showtime(sec); //Display time value (seconds) Repeatedly overwrite these 2 digits to achieve the display effect
delay(20);
}
}
#pragma vector = 0x24 //Timer 0 overflow (timing seconds)
__interrupt void time0()
{
TCNT0=0x83;
if(on==1) //Start flag
{
cnt++;
if(cnt==1000)
{
sec++;cnt=0;
}
if(sec>100)sec=0;
}
}
__interrupt void int0()
{
on=1;
writecmd(0x01); // Clear screen
displaychar(0,1,start); // Display start character
displaychar(0,0,str1); // Display original character
showtime(sec);
}
__interrupt void int1()
{
on=0;
writecmd(0x01); //Clear screen
displaychar(0,1,stop); //Display stop character
displaychar(0,0,str1); //Display original character
showtime(sec);
}
Previous article:The realization of automatic bell system for starting and ending classes based on AVR single chip microcomputer
Next article:AVR microcontroller PCF8591AD-DA experiment
- 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
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- 【GD32L233C-START Review】VII. TIMER
- TCP/IP Detailed Volume 1: Protocols (2nd Edition)
- Charging box modified LED light
- Write a Unico tool for STEVAL-MKI109V3
- Human body blowing sensor module
- Parking Robot Embedded Engineer Recruitment
- C++ Computer Vision OpenCV Official Introduction (2017 Edition)
- I built a chassis over the weekend.
- Can you help me design a washing machine controller? It's paid. If you want, please contact me, QQ: 993849120
- 1. GD32L233C-START (unboxing), turn on the lights as usual.