//数码管数据p0口,数码管控制p2口
#include
#include
#include
#include
#include
#define code progmem
#define uchar unsigned char
#define uint unsigned int
code const ucharled_7[16] = {0x28, 0x7e, 0xa2, 0x62, 0x74, 0x61, 0x21, 0x7a, 0x20, 0x60,0xff};//common of +
code const uchar position[8] = {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar time[4]; //时间计数
volatile uchar disp_buff[8]; //显示缓冲区
volatile uchar time_count = 0;
volatile uchar point_on = 0;
volatile uchar posit = 0;
volatile uchar time_10ms_ok = 0;
void time_to_dispbuff(void);
void time1_init(void);
void time0_init(void);
void display(void);
int main(void)
{
porta = 0xff;
ddra = 0xff;
portc = 0xff;
ddrc = 0xff;
time[0] = 00;//1/10sec
time[1] = 30;//sec
time[2] = 59;//minute
time[3] = 23;//hour
time_to_dispbuff();
time1_init();
sei();
while(1)
{
if(time_10ms_ok)
{
time_10ms_ok = 0;
if(++time[0]》=100)
{
time[0] = 0;
point_on = ~point_on;
if(++time[1]》=60)
{
time[1] = 0;
if(++time[2]》=60)
{
time[2] = 0;
if(++time[3]》=24)
{
time[3] = 0;
}
}
}
}
time_to_dispbuff();
}
}
}
void time0_init(void)
{
tccr0 = 0x05;
tcnt0 = 0xea;
tifr |= 0x02;
timsk |= 0x02;
}
void time1_init(void)
{
tccr1a = 0x00;
tccr1b = 0x01;
tcnt1 = 0xa99a;
//tcnt1h = 0xa9;
//tcnt1l = 0x9a;
tifr |= 0x80;
timsk |= 0x80;
}
signal(sig_overflow1)
{
tcnt1 = 0xa99a;
display();
if(++time_count 》=5)
{
time_10ms_ok = 1;
time_count = 0;
}
}
void display(void)
{
portc = 0xff;
porta = pgm_read_byte(&led_7[disp_buff[posit]]);
if(point_on && ((posit==2)||(posit==4)||(posit==6)))porta &= 0x7f;
portc = pgm_read_byte(&position[posit]);
if(++posit》=8)posit = 0;
}
void time_to_dispbuff(void)
{
uchar i,j=0;
for(i=0;i《=3;i++)
{
disp_buff[j++] = time[i]%10;
disp_buff[j++] = time[i]/10;
经编机PLC如何实现数据采集到云平台进行监控
极致的口腔护理体验,XNUO心诺X628冲牙器帮你做到!
存储设备品牌排行榜
红米note4x最新消息:红米note4x高配版,再次升级,颜值实力都有啦!
Jet8让社交媒体互动转化盈利机制成为可能
AVR单片机对数码管数据P0口与P2口的控制设计
燧原科技“系统+软件”一体化方案帮助客户实现人工智能快速落地
5G技术对远程医疗有着重大影响力
人民日报:万物皆可“元宇宙”
聚辰股份:拥有A1、A2、A3 等级的全系列汽车级 EEPROM 产品
物联网边缘的智能视频分析
纳米图形衬底对AlGaN基深紫外LED中光子输运的影响
智能合约为什么要是用工厂模式
YXC扬兴科技丨压控晶振选型指南
不同网段的PLC怎么与MES系统通信实现跨网段访问
2020年数据泄露成本报告出炉,总成本平均为386万美元
DriveMaster对几款NVMe SSD进行功耗测试
庆科信息“万物有声”智能语音解决方案发布会即将开启
每个新手程序员应该知道的事情
【解决方案】安科瑞电气火灾监控系统在工厂的应用