Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/21/03 18:06
Read: times


 
#53042 - reading from serial port
I have been trying to read the serial port via SBUF register and dumping its value onto a I/O port. But have been unsuccessful.
I have been using the following test code..... please suggest any modifications if required.


#include<AT89X55.h>

char ch;
void serial_init()
{

SCON = 0x50; /* mode 1, 8-bit uart, enable receiver */

PCON|= 0x80; /* PCON^7 = SMOD doubles the baud rate i.e. k=2 */
TMOD = 0x20; /* timer 1, mode 2, 8-bit reload */
TH1 = 0xFD; /* reload value for 19200 baud */

TR1 = 1;

TI = 1;

}
char receive_byte()
{
RI = 0;
while (RI != 1) {;}

ch=SBUF;
RI = 0;
return ch;

}

void main()
{
serial_init();

P0=receive_byte();
}



List of 6 messages in thread
TopicAuthorDate
reading from serial port            01/01/70 00:00      
   RE: reading from serial port            01/01/70 00:00      
      RE: reading from serial port            01/01/70 00:00      
         RE: reading from serial port            01/01/70 00:00      
   RE: reading from serial port            01/01/70 00:00      
   RE: reading from serial port            01/01/70 00:00      

Back to Subject List