Any of a number of bytes transmitted, received and sent back after the MCU plus serial number comprising a maximum of 255
Code
#include"reg51.h"
typedef unsigned int u16;
typedef unsigned char u8;
u16 a;
u16 i=0;
void usart_init()
{
SCON=0x50;
EA=1;
ES=1;
TMOD=0x20;
TH1=TL1=0XF4;
TR1=1;
}
void main()
{
usart_init();
while(1);
}
void usart() interrupt 4
{
RI=0;
a=SBUF;
if(i<256)
{
SBUF=i;
while(!TI);
TI=0;
i++;
if(i==255)i=0;
}
SBUF=a;
while(!TI);
TI=0;
}
Simulation Figure
Serial Assistant
Component Name
COMPIM
AT89C51(AT89C52)