This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to sent Letter "A" from Microprossor to Hyperterminal

#include <REG51KJ.h>
#include <stdlib.h>



void serial_init()
{
        TMOD = 0x20;   //set timer 1 mode to 8-bit-auto-reload
        SCON = 0x50;   //enable reception , det serial port mode to 8-bit UART    REN ENABLE
        PCON |= 0x80;  //set mode 2       by seting SMOD
        TH1  = 0xF3;   //set baudrate to 9600 at 24 MHZ crystal
        TL1  = 0xF3;
        TR1  = 1;       //start Timer
}

void delay(unsigned int msec)//delay
{
        int i,j;
        for(i=0;i<msec;i++);
        for(j=0;j<1275;j++);
}

void serial_send(unsigned char dat)
{
        while(!TI);     //wait for data to be send completely
        TI = 0;         //clr Transmit interrupt flag
        SBUF = dat;     //move data to send in SBUF
}

/********************************************/

void main(void)
{
        serial_init() ;
        for(;;)
        {
                delay(10);
                serial_send('A');                  //send char 'A' through rs232 across
        }

}