1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉
標(biāo)題:
0-999秒表程序
[打印本頁(yè)]
作者:
shi1918844682
時(shí)間:
2018-5-2 22:12
標(biāo)題:
0-999秒表程序
#include <STC12C5A60S2.H>
#define ENLED P11
#define Interrupt
unsigned char code LedChar[10] =
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char LedBuff[6] =
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
void T0init()
{
TMOD &= 0xF0;
TMOD |= 0x01;
TH0 = 0xF5;
TR0 = 1;
EA = 1;
ET0 = 1;
TF0 = 0;
}void LED_Scan(unsigned long sec)
{
static unsigned char i = 0;
unsigned char j = 6;
while(j)
{
LedBuff[j-1] = LedChar[sec%10];
sec /= 10;j--;
}
P2 = ~0x07;
P2 |= i%6;
P0 = LedBuff[(i++)%6];
}void main()
{
T0init();
ENLED = 0;
while(1)
{
#ifndef Interrupt
void TF0_Scan();
TF0_Scan();
#endif
}
}
#ifdef Interrupt
void interrupt_Scan() interrupt 1
{
static unsigned int cnt = 0;
static unsigned long sec = 0;
TF0 = 0;
TH0 = 0xF5;
TL0 = 0x95;
cnt++;
if(cnt >=999)
{
cnt = 0;
sec++;
if(sec >9)
{
P13=0;sec=0;
}
}
LED_Scan(sec);
}
#else void TF0_Scan()
{
static unsigned int cnt = 0;
static unsigned long sec = 0;
if(TF0 == 1)
{
TF0 = 0;
TH0 = 0xF5;
TL0 = 0x95;
cnt++;
if(cnt >= 999)
{
cnt = 0;
sec++;
if(sec > 9)
{
P13=0;
sec=0;
}
}
LED_Scan(sec);
}
}
#endif
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1