📄 main__.c
字号:
#include "MEGA16.h"
#include "INIT.h"
#include "DISPLAY.h"
#include "KEY.h"
uint time_sec_add=0;
//******************************中断函数************************************
//定时器1中断函数
interrupt [TIM1_OVF] void timer1_capt_isr(void)//1mS
{
TCNT1H = 0xE3; //reload counter high value
TCNT1L = 0x34; //reload counter low value
flash_add+=1;
if(flash_add>=1000)
flash_add=0;
if(b_time)
time_sec_add+=1;
if(time_sec_add>=1000) //1秒
{ b_sec=~b_sec;
sec+=1;
time_sec_add=0;
}
if(sec>=60) //1分
{
min+=1;
sec=0;
}
if(min>=60) //1小时
{
hour+=1;
min=0;
}
if(hour>99)
{
hour=99;
}
if((hour>=sethour)&&(min>=setmin))
{
b_time=0;
b_sec=1;
LED=0xef;
}
}
//******************************主函数************************************
void main(void)
{
init_devices();
sethour= eeprom_shu[0];
setmin= eeprom_shu[1];
hour= eeprom_shu[2];
min= eeprom_shu[3];
sec= eeprom_shu[4];
LED= eeprom_shu[5];
b_time= eeprom_shu[6];
while (1)
{
#asm("wdr")
if(!(PINC & (1<<PC6)))
{
show();
key();
}
else
{
PORTA=0X00;
eeprom_shu[0]=sethour;
eeprom_shu[1]=setmin;
eeprom_shu[2]=hour;
eeprom_shu[3]=min;
eeprom_shu[4]=sec;
eeprom_shu[5]=LED;
eeprom_shu[6]=b_time;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -