#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; }
NE555频率检测
猜你喜欢
转载自blog.csdn.net/qq_39815222/article/details/80341750
今日推荐
周排行