|
吾爱游客
发表于 2014-11-22 23:26
申请ID:lichangle
个人邮箱:191738162@qq.com
供水系统 proteus c51仿真源码
#include<reg52.h>
#include<intrins.h>
//#include <absacc.h>
#define uchar unsigned char
#define uint unsigned int
sbit motor1=P2^0; //电机
sbit motor2=P2^1;
sbit motor3=P2^2;
sbit shwe1=P1^0; //水位
sbit shwe2=P1^1;
sbit shwe3=P1^2;
void initTimer(void);
void delayms(uint xms); //声明延时子程序
/************
主函数
************/
void main(void)
{
initTimer();
}
//timer init
void initTimer(void)
{
IT0=1; //INT0下降沿中断
EX0=1; //允许INT1中断
IT1=1; //INT1下降沿中断
EX1=1; //允许INT1中断
TMOD=0x11;
TH0=0xdc;
TL0=0x32;
TH1=0xdc;
TL1=0x32;
TR0=1;
ET0=1;
TR1=1;
ET1=1;
EA=1;
}
//timer0/counter0 interrupt
uint time1=0,time2=0,time3=0,time4=0;
void timer0(void) interrupt 1
{
TH0=0xdc;
TL0=0x32;
//add your code here.
time1++;
if (time1>100) //1秒
{
time2 ++;
time1 =0;
}
if (time2>60) //一分钟
{
time2 =0;
time3 ++;
}
if (time3>30) //30分钟
{
time3 =0;
}
}
//timer1/counter1 interrupt
void timer1(void) interrupt 3
{
TH1=0xdc;
TL1=0x32;
//add your code here.
}
//int0 interrupt
void int0(void) interrupt 0
{
//add your code here
}
//int1 interrupt
void int1(void) interrupt 2
{
//add your code here
}
void delayms(uint xms) //延时子程序
{ uint i, j;
for (i=xms; i>0; i--)
for (j-110; j>0; j--);
}
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|