#include <AT89X51.H>
#include <absacc.h>
#include <intrins.h>
#define uchar unsigned char
#define COM8155 XBYTE[0xfdf8] //8155命令口地址
#define PA8155 XBYTE[0xfdf9] //8155口A地址
#define PB8155 XBYTE[0xfdfa] //8155口B地址
sbit p10=P1^0;
sbit p11=P1^1;
sbit p12=P1^2;
sbit p13=P1^3;
sbit p14=P1^4;
sbit p15=P1^5;
sbit p16=P1^6;
sbit p17=P1^7;
sbit p20=P2^0;
sbit p21=P2^1;
sbit p22=P2^2;
bit me_flag=0;
bit de_flag=0;
bit urs_flag=0;
bit flag_8155=0;
unsigned int idata num=0;
unsigned int t=50000;
uchar ml,mh,hh,hl; //hh hl:mh ml
uchar code x[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //0,1,2,3,...,9
//--------------------------------------------------------------------------------------------
void TimeToScrn(uchar idata hhmm,uchar idata sel) //8155时间处理子函数
{
PA8155=sel;
PB8155=x[hhmm];
_nop_();_nop_();_nop_();
}
//--------------------------------------------------------------------------------------------
void Interrupt_0() interrupt 0 using 1 //外部中断0子函数--市电和发电机组同时有电
{
P1=(P1&0xe0)|0x1f; //切断所有可能输出
while(t--);t=50000; while(t--);t=50000; //延时200ms
//-------------------------------------------------------------------------------------------
while(p17==0)
{
P1=(P1|0x04)&0xe4; //接通市电, 停机组,直到机组停机成功
while(t--);t=50000; while(t--); t=50000; //延时200ms
}
TR0=0;
P1=(P1|0x07)&0xe7; //保持市电接通状态
me_flag=1;
de_flag=0;
//-------------------------------------------------------------------------------------------
p21=1; //8155停止工作
flag_8155=0;
P2=(P2&0x1
#include <absacc.h>
#include <intrins.h>
#define uchar unsigned char
#define COM8155 XBYTE[0xfdf8] //8155命令口地址
#define PA8155 XBYTE[0xfdf9] //8155口A地址
#define PB8155 XBYTE[0xfdfa] //8155口B地址
sbit p10=P1^0;
sbit p11=P1^1;
sbit p12=P1^2;
sbit p13=P1^3;
sbit p14=P1^4;
sbit p15=P1^5;
sbit p16=P1^6;
sbit p17=P1^7;
sbit p20=P2^0;
sbit p21=P2^1;
sbit p22=P2^2;
bit me_flag=0;
bit de_flag=0;
bit urs_flag=0;
bit flag_8155=0;
unsigned int idata num=0;
unsigned int t=50000;
uchar ml,mh,hh,hl; //hh hl:mh ml
uchar code x[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //0,1,2,3,...,9
//--------------------------------------------------------------------------------------------
void TimeToScrn(uchar idata hhmm,uchar idata sel) //8155时间处理子函数
{
PA8155=sel;
PB8155=x[hhmm];
_nop_();_nop_();_nop_();
}
//--------------------------------------------------------------------------------------------
void Interrupt_0() interrupt 0 using 1 //外部中断0子函数--市电和发电机组同时有电
{
P1=(P1&0xe0)|0x1f; //切断所有可能输出
while(t--);t=50000; while(t--);t=50000; //延时200ms
//-------------------------------------------------------------------------------------------
while(p17==0)
{
P1=(P1|0x04)&0xe4; //接通市电, 停机组,直到机组停机成功
while(t--);t=50000; while(t--); t=50000; //延时200ms
}
TR0=0;
P1=(P1|0x07)&0xe7; //保持市电接通状态
me_flag=1;
de_flag=0;
//-------------------------------------------------------------------------------------------
p21=1; //8155停止工作
flag_8155=0;
P2=(P2&0x1