#include"SH88F4051.h"
extern void UARTinit();
void Sendbyte();
void delay1ms(void) //Îó²î 0us
{
unsigned char a,b,c;
for(c=100;c>0;c--)
for(b=142;b>0;b--)
for(a=2;a>0;a--);
}
unsigned char TX[]={0x00,0x01,0x02,0x03};
unsigned char LED;
void main()
{
UARTinit();
P4_2=1;
delay1ms();
while(1)
{
Sendbyte();
P1=LED;
P4_2=0;
delay1ms();
}
}
void Sendbyte()
{
unsigned char i,c;
for(i=0;i<4;i++)
{
c=TX[i];
SBUF=c;
while(!TI);
TI=0;
delay1ms();
}
}
void Portint() interrupt 4
{
if(RI)
{
RI=0;
LED=SBUF;
}
}
|