⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 这是52单片机串口调试程序
💻 C
字号:
#include <AT89X52.H>
#include "macro.h"
#include "common.h"
#include "28F040.h"
#include "HT1380.h"
#include "lcd.h"
#include "serial.h"
#include "key.h"
#include "idcard.h"
#include "menu.h"

void main(void)
{
	BYTE i;
	EA=0;
	PSW=0;
	P0=P1=P2=P3=0xFF;
	Ret_I();
	Ret_I();
	TMOD=0x11;									// T0=16bit  T1=8bit auto reload
	TCON=0x45;									// Timer1 start
	PCON=0x00;        						// SMOD=0
	SCON=0x50;									// UART_mode=1,REN=1
	T2MOD=0;
	T2CON=0x34;									// Set T2 to baud rate register
	AUX_OUT_OFF
	Serial_init();
	Protect_28F040();
	Unprotect_28F040();
	LCD_open();
	VOC_stop();
	BELL_OFF
	Calc_Total_User();
	Calc_Total_Record();
	Sys_Stat=SB;
	LCD_ShowStatus();
	IP=0x10;										// Set Serial to high level
	IE=0x98;										// Enable Serial and Timer1 interrupt
	while(1){
		if(b_Recv_done)
			Recv_Process();
		if(0==Timer_20ms){					// 20ms * 50 = 1s
			if(Timer_1s)
				Timer_1s--;
			Timer_20ms=50;
			if(Menu_stat==0){
				LCD_ShowRiqi();
				LCD_ShowTime();
				if(!b_LCD_line4){				// LCD line 4 control by Machine
					b_ShowNow=!b_ShowNow;
					if(b_ShowNow){
						b_ShowSomething=!b_ShowSomething;
						if(b_ShowSomething){
#ifdef	CHINESE
//							mystrcpy("  恒 创 科 技   ");
							mystrcpy("  金 典 科 技   ");
//							mystrcpy("  江苏海通通信  ");
#else
							mystrcpy("WeWin Technology");
#endif
							LCD_writeline(6);
						}else{
#ifdef	CHINESE
							mystrcpy(" 管 理 创 效 益 ");
#else
							mystrcpy("Time Attendance ");
#endif
							LCD_writeline(6);
						}
					}
				}
			}
		}
		if((0==Timer_20ms2)&&(b_20ms2==0)){
			b_20ms2=1;
			if(Total_Record<30000)
#ifdef	CHINESE
				mystrcpy("   请  刷  卡   ");
#else
				mystrcpy(" Check the Card ");
#endif
			else
#ifdef	CHINESE
				mystrcpy("  考勤记录将满  ");
#else
				mystrcpy("Too Much Records");
#endif
			LCD_writeline(4);
		}
		if(Pause_time==0){
			i=Check_Key_Card_valid(3);
			if(i==0xFF){						// ID_Card input
				for(i=0; i<7; i++){
					if(Last_Card_no[i]!=ID_Card_no[i]){
						i=100;
						break;
					}
				}
				if(i!=100){						// The same card
					if(Timer_1s){
						Timer_1s=4;
						continue;
					}
				}
				Card_Process();
			}else if(i!=0){					// Key_in
				Key_Process(i);
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -