#include "STC15F2K60S2.h"
#include "SMG.h" //见我之前的博客
void timer0_init();
void Timer1Init();
void all_init();
unsigned int count1s;
unsigned char temp,flag1s;
unsigned int frequency;
void main()
{
EA=1;
ET1=1;
ET0=1;
timer0_init();
Timer1Init();
all_init();
while(1)
{
if(flag1s)
{
flag1s=0;
frequency=frequency+(TH0*256)+TL0;
SMGBit[7]=frequency%10;
SMGBit[6]=frequency/10%10;
SMGBit[5]=frequency/100%10;
SMGBit[4]=frequency/1000%10;
SMGBit[3]=frequency/10000;
SMGBit[2]=10;
frequency=0;
TH0=0;TL0=0;
}
SMGBit[1]=temp;
SMGBit[0]=10;
}
}
void timer0_config() interrupt 1
{
frequency=frequency+65536; //如果溢出
}
void timer1_config() interrupt 3
{
SMG_display();
if(++count1s==500)
{
count1s=0;
flag1s=1;
temp++;
if(temp==10)
temp=0;
}
}
void timer0_init()
{
TL0=0X00;
TH0=0X00;
TR0=1;
}
void Timer1Init(void) //2毫秒@11.0592MHz
{
AUXR |= 0x40; //定时器时钟1T模式
TMOD = 0x05; //设置定时器模式
TL1 = 0x9A; //设置定时初值
TH1 = 0xA9; //设置定时初值
TF1 = 0; //清除TF1标志
TR1 = 1; //定时器1开始计时
}
void all_init()
{
P2=0xe0;P0=0XFF;
P2=0XA0;P0=0X00;
P2=0X80;P0=0XFF;
P2=0XC0;P0=0XFF;
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/82552.html