source: Deliverables/D4.1/GCC/SerialWrite.c @ 557

Last change on this file since 557 was 186, checked in by mulligan, 9 years ago

Added C code to write to SBUF SFR for Roberto.

File size: 490 bytes
Line 
1#include "mcs51reg.h"
2
3int main()
4{
5  SCON = SCON | 0x40;  // Change serial port mode to mode 1
6  TMOD = TMOD | 0x20;  // Configure timer 1 to mode 2 (8 bit autoreload)
7  TH1  = 0xFD;         // Baud rate to 19,200 with ~11mhz clock
8  PCON = PCON | 0x80;  // PCON.7 set to double baud rate (needed?)
9  TI   = 0x00;         // Clear the transmission bit
10  SBUF = 5;            // Write 5 to the serial buffer
11  while(!TI) { }       // Wait until the data has been transmitted
12  return 5;
13}
14
Note: See TracBrowser for help on using the repository browser.