📄 main.c
字号:
/***************************************************************
ML610Q431 sample C source file
CODE/DATA MODEL : SMALL/NEAR
ROMWINDOW : 0-0DFFFh
Version : V1.0
File name : main.c
Author : MF.Chen
Copyright (C) 2008/11/20 Globaltec Co.,Ltd.
***************************************************************/
/**********************************************************************************
User Includes
***********************************************************************************/
#include "m610411.h"
#include "common.h"
#include "lcd.h"
void sfr_init(void);
void clock_check(void);
void common_clrWDT( void );
/***********************************************************************************/
/* MAIN LOOP */
/***********************************************************************************/
void main(void)
{
__DI(); /* Interrupt Disable */
sfr_init() ; /* Initialize SFR */
lcd_init(); /* Initialize A&B */
__EI(); /* Interrupt Enable */
while (1) // Loop
{
clock_check(); //
common_clrWDT(); //clear watchdog
}
}
/**************************************************************************
program initialize
***************************************************************************/
void sfr_init(void)
{
/*=== I/O port init. ===*/
/*----P2-------*/
P2CON0=0xff; //output mode select
P2CON1=0xff; //CMOS output mode
/***********按键**************/
//*
P0CON0=0x03;
P0CON1=0x00; //pull up input mode
//*/
/*=== Select start/stop mode. ===*/
E2H=1; //enable T2Hz interrupt
cont_1second=0;
cont_1min=58;
cont_1hour=22;
}
/*****************************************************************************
Clear Watchdog Timer
******************************************************************************/
void common_clrWDT( void )
{
if ( WDP == 1 )
{
WDTCON = (unsigned char)0xA5u; /* WDP : 1 -> 0 */
}
WDTCON = (unsigned char)0x5A; /* WDP : 0 -> 1 */
WDTCON = (unsigned char)0xA5; /* WDP : 1 -> 0 */
}
/*****************************************************************************
Clock check
******************************************************************************/
void clock_check(void)
{
if (f_1s==1)
{
f_1s=0;
key_scan();
if(cont_1second<59)
{
cont_1second++; //秒计时
}
else if(cont_1min<59)
{
cont_1second=0;
cont_1min++; //分计时
}
else if(cont_1hour<23)
{
cont_1second=0;
cont_1min=0;
cont_1hour++;
}
else
{
cont_1hour=0;
cont_1min =0;
cont_1second=0;
}
disp_data_sec=cont_1second;
disp_data_min=cont_1min;
disp_data_hour= cont_1hour;
lcd_display(); //call lcd display
}
}
void key_scan(viod)
{
if(key0==0) //while(key0);
if(cont_1hour<24) cont_1hour++;
else cont_1hour=0;
else if(key1==0)
cont_1min++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -