?? main.c
字號:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "main_asm.h" /* interface to the assembly module */
void MCU_init(void); /* Device initialization function declaration */
#define uchar unsigned char
unsigned char P0,P2;
uchar const dis_7[12]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x40};//段碼
uchar const bit_8[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//位碼
uchar dis[8]={0x00,0x00,11,0x00,0x00,11,0x00,0x00};//顯示的初值
uchar timedata[3]={0x00,0x00,0x00};//時分秒的數據—
uchar ms50=0x00,con=0x00,con1=0x00,con2=0x00;//秒脈沖,時分秒電
void delayms(int t)
{
int i,j;
for(i=0;i<t;i++)
for(j=0;j<120;j++);
}
void scan(void)
{
uchar k;
dis[0]=(unsigned char )(timedata[0]%10);
dis[1]=(unsigned char )timedata[0]/10;
dis[3]=(unsigned char )(timedata[1]%10);
dis[4]=(unsigned char )timedata[1]/10;
dis[6]=(unsigned char )(timedata[2]%10);
dis[7]=(unsigned char )timedata[2]/10;
for (k=0;k<8;k++)
{
P0=dis_7[dis[k]];
P2=bit_8[k];
delayms(1);
P2=0xff;
}
}
void main(void) {
MCU_init(); /* call Device Initialization */
/* include your code here */
asm_main(); /* call the assembly function */
for(;;) {
__RESET_WATCHDOG();/* by default, COP is disabled with device init. When enabling, also reset the watchdog. */
scan();
} /* loop forever */
/* please make sure that you never leave main */
}
/*作 者: */
/* function: 顯示時分秒電子表 P0送段碼,P2送位碼 */
/*2007-2, */
/*****************************************/
//sbit key0=P1^0;//進入調開關
//sbit key1=P1^1;//加開關
//sbit key2=P1^2;//減開關
//延時子程序
//鍵掃子程序
/* keyscan()
{
EA=0;
if(key0==0)
{
delayms(10);
while(key0==0);
con++;TR0=0;ET0=0;
if(con>=3)
{
con=0;TR0=1;ET0=1;}
}
if(con!=0)
{
if(key1==0)
{
delayms(10);
while(key1==0);
timedata[con]++;
if(con==2)
con1=24;else con1=60;
if(timedata[con]>=con1)
{timedata[con]=0;}
}
}
if(con!=0)
{
if (key2==0)
{
delayms(10);
while(key2==0);
timedata[con]--;
if(con==2)
con2=23;//
else con2=59;
if(timedata[con]<=0)
{timedata[con]=con2;}
}
}
EA=1;
} */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -