Return to Snippet

Revision: 22239
at January 6, 2010 16:54 by jimfred


Initial Code
void TestSerial(void)  
{ 
  // for UART1, use TI_1, RI_1 and SBUF1.
  // for UART0, use TI,   RI   and SBUF.

  char c = 'A';

  TI_1 = 1;
  while (1) // forever. 
  {
    if (RI_1) // if a char is ready...
    {
      c = SBUF1; // Read a char.
      RI_1 = 0;  // Indicate that we've read the char.
    }
    while (!TI_1) {;} // wait for TX to be ready.
    TI_1 = 0;  
    SBUF1 = c; // Send a char
  }
}

Initial URL


Initial Description
From Keil C51 examples, TEST.C:  ISD51 Demo for TI MSC 1210.
Polled (non-interrupt) mode.

Work-around for dropped-characters related to stop-bit problem: Clear SCON1.5 (or SM2_1).

Initial Title
Keil C51 character echo test for UART1

Initial Tags
c

Initial Language
C