/ Published in: C
                    
                                        
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).
                Polled (non-interrupt) mode.
Work-around for dropped-characters related to stop-bit problem: Clear SCON1.5 (or SM2_1).
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
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
}
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                