main.c
#include <stc15f2k60s2.h>
#include <juzhen.h>
extern unsigned char display[];
extern unsigned char key;
void Timer0Init();
void main()
{
Timer1Init();EA=1;ET1=1;
Timer0Init();EA=1;ET0=1;
P2=0XA0;P0=0X00;P2=0X1f;
while(1)
{
anjian();
// xianshi();
}
}
void Timer0Init(void) //2毫秒@11.0592MHz
{
AUXR |= 0x80; //定时器时钟1T模式
TMOD &= 0xF0; //设置定时器模式
TL0 = 0x9A; //设置定时初值
TH0 = 0xA9; //设置定时初值
TF0 = 0; //清除TF0标志
TR0 = 1; //定时器0开始计时
}
void shuma() interrupt 1
{
unsigned char i;
P2=0XE0;
P0=0XFF;
P2=0X1f;
P2=0XC0;
P0=1<<i;
P2=0X1f;
P2=0XE0;
P0=display[i];
P2=0X1f;
i++;
if(i>=8)i=0;
}
juzhen.c
#include <stc15f2k60s2.h>
#include <juzhen.h>
unsigned char display[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
unsigned char smg[]={<