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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/22/03 20:46
Read: times


 
#53130 - RE: reading from serial port
Responding to: ???'s previous message
Hi,
I dont have much knolodge on C, but why dont you use an serial interrupt routine? I think some thing like this:

#include<AT89X55.h>

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;
IE = 0x90; /* Enable Serial Int */
}

/* Dont know how to declare a interrupt in C,
but this would be the serial ISR.
*/
void Serial_Int()
{
if(!RI) return;
RI = 0;
P0 = SBUF;
}

void main()
{
serial_init();
while(1) {};
}

Gabriel Ortiz Lour



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