?? mcpcs.c
字號:
#include <reg51.h>
#define uchar unsigned char
uchar sn=10;
uchar idata nowrate[2]={0x00,0x00};
uchar idata *pp;
bit pf=1;
void contrl(direct,mode)
bit direct;
uchar mode;
{ uchar i;
uchar idata *cmode;
uchar idata rise[20];
uchar idata fall[20];
uchar idata plus[7]={0x01,0x03,0x02,0x06,0x04,0x05,0x00};
uchar idata minu[7]={0x05,0x04,0x06,0x02,0x03,0x01,0x00};
if(direct) cmode=plus;
else cmode=minu;
switch(mode)
{ case 1:pp=rise;break;
case 2:pp=nowrate;break;
case 3:pp=fall;break;
default:pp=nowrate;break;
}
do{
P1=cmode[i];
if(cmode[++i]==0x00) i=0;
while(pf);
pf=1;
if((mode==1)||(mode==3)) pp+=2;
} while(sn--);
}
void intt0(void) interrupt 1
{
TL0=*pp;nowrate[0]=TL0;
TH0=*(pp+1);nowrate[1]=TH0;
pf=0;
}
void main(void)
{
TMOD=0x01;
TH0=0x00;
TL0=0x00;
TR0=1;
ET0=1;
EA=1;
contrl(1,1);
sn=10;
contrl(1,2);
sn=10;
contrl(1,3);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -