#define FOSC 12000000L //系统时钟
#define Timer0_Interval_ms 5 //timer0模式1的计数溢出时间间隔,必须以毫秒为单位
//--定义使用的IO口--//
#define GPIO_DIG P0 //段选
#define GPIO_PLACE P1 //位选
unsigned char num[8]={0,0,0,0,0,0,0,0};
//--定义全局变量--//
unsigned char code DIG_PLACE[8] = {
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//位选控制查表的方法控制
unsigned char code DIG_CODE[17] = {
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
//0、1、2、3、4、5、6、7、8、9、A、b、C、d、E、F的显示码
unsigned char DisplayData[8];
long counter=87654321;
unsigned char second=0,minute=0,hour=21;
unsigned char counter_5ms=200;
bit IsTime2SentPC = 0;
bit busy;
enum {STOP,HOUR_TEN,HOUR_SINGLE,COLON_1,MINUTE_TEN,MINUTE_SINGLE,COLON_2,SECOND_TEN,SECOND_SINGLE,RUNNING};
//工作模式:停止计时,小时十位,小时个位,冒号1,分钟十位,分钟个位,冒号2,秒钟十位,秒钟个位,运行计时
unsigned char WorkMode = RUNNING; //开机状态是时钟运行计时
//用来存放要显示的8位数的值
sbit K_add = P3^2;
sbit K_dec = P3^3;
//sbit Number_ON=P3^7;
sbit dig_out = P2^7; //位扫描信号,对数码管扫描没用,用在示波器显示波形
sbit frame_out = P2^0; //帧扫描信号,对数码管扫描没用,用在示波器显示波形
bit counter_changed = 0; //按键后计数器值发生变化的标志,有变化才调用update_display_buffer() |