//program to transmit a sing le character.
#include<reg51.h>
void init_uart(void);
void uart_tr(char);
char uart_rx(void);
void init_uart()
{
SCON=0x50;//standard
uart mode
TMOD=0x20;//timer1
mode2
TH1=253;//set the
baud rate 9600
TR1=1;
}
void uart_tr(char c)
{
SBUF=c;
while(TI==0);
TI=0;
}
char uart_rx()
{
while(!RI);
RI=0;
return SBUF;
}
void main()
{
init_uart();
uart_tr('A');
while(1);
}
No comments:
Post a Comment