#include <atmel\at89x52.h>
#include <string.h>
#define comdir P3_2
#define wirespeaker P1_3
#define wiret0 T0
#define wiret1 T1
#define adr_delay1s 0x1086
#define adr_print10ms 0x1000
#define adr_print80ms 0x101A
#define adr_screen_black 0x10BA
#define adr_screen_clear 0x10CD
#define adr_key_search 0X10EB
#define adr_sound500hz 0x109E
#define max_timer 24*3
void (* pFunc)(void); //定义指向函数的指针
void (* Print80ms)(void);
int CodeChange(int i);
/*define a struct*/
struct time_str{
unsigned char hour;
unsigned char min;
unsigned char sec;
}today;
int depart=20;
int t0int_flag=0;
unsigned char data dispbuf[8] _at_ 0x30;
unsigned char code Sound_Date[max_timer]={
0x00 0 0 0 0 0 0 0 0 0 0 0
0x0b 0 0 0 0 0 0 0 0 0 0 0
0x0b 0 0 0 0 0 0 0 0 0 0 0
0x0b 0 0 0 0 0 0 0 0 0 0 0
0x0b 0 0 0 0 0 0 0 0 0 0 0
0x0b 0 0 0 0 0 0 0 0 0 0 0
};
/*TIMER0 INTERRUPT*/
void timer0(void) interrupt 1{
wiret1=!wiret1;
TH0=0X3C;
TL0=0XB0;
depart-=1;
if (depart%10==0){
t0int_flag=!t0int_flag;
}
if (depart==0){
depart=20;
today.sec+=1;
wiret0=!wiret0;
if (today.sec==60){
today.sec=0;
today.min+=1;
if(today.min==60){
today.min=0;
today.hour+=1;
if(today.hour==24){
today.hour=0;
}
}
}
}
}
/*SERIAL PORT INTERRUPT*/
void serial(void) interrupt 4{
}
main()
{
char *P;
int j=0;
int i=0;
int k=0;
P3_4=0; //T0=0
P3_4=1; //T0=1
P3_5=0; //T1=0
P3_5=1; //T1=1
pFunc=adr_screen_black; //screen black
(*pFunc)();
pFunc=adr_screen_clear; //clrar screen ram
(*pFunc)();
/*P=0X30;
(*P)=0X79;
P++;
(*P)=0X71;*/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//SP=0XD0;
TMOD=0X21;
//TH1=0XF3;
//TL1=0XF3;
//PCON=0;
//SCON=0X40;
//TR1=1;
ET1=0;
//REN=1;
TH0=0X3C; /* 50ms interrupt */
TL0=0XB0;
TR0=1;
ET0=1;
EA=1;
//TI=0;
//SBUF=0XAA; //MON51 占用串口
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pFunc=adr_sound500hz;
(*pFunc)(); /*发声音一秒*/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
today.hour=0;
today.
本文关键字:程序 综合-其它,单片机-工控设备 - 综合-其它
上一篇:X5045和51单片机接口