#include REG52.h
char found1=0;
char found2=0;
char countABC=0;
char countXYZ=0;
void searchABCXYZ () interrupt 4
{
if (RI==1)
{
if (SBUF=='A')
{
found1=1;
}
else if ((SBUF=='B')&& (found1==1))
{
found1=2;
}
else if ((SBUF=='C')&& (found1==2))
{
countABC++;
found1=0;
}
else
found1=0;
P0=countABC;
if (SBUF=='X')
{
found2=1;
}
else if ((SBUF=='Y')&&(found2==1))
{
found2=2;
}
else if ((SBUF=='Z')&&(found2==2))
{
countXYZ++;
found2=0;
}
else
found2=0;
P1=countXYZ;
RI=0;
}
}
void main ()
{
P0=0x00;
P1=0x00;
TMOD=TMOD&0x0F;
TMOD=TMOD|0x20;
SCON=0x50;
TH1=0xFD;
TL1=0xFD;
EA=1;
ES=1;
TR1=1;
while (1)
PCON=PCON|0x01;
}
Comments
Post a Comment
Thanks for the comment