home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 September / PCWK996.iso / demo / wgelectr / pk51demo / files.2 / EXAMPLES / HELLO / HELLO.C < prev    next >
C/C++ Source or Header  |  1995-09-26  |  2KB  |  36 lines

  1. /*------------------------------------------------------------------------------
  2. HELLO.C
  3.  
  4. Copyright 1995 KEIL Software, Inc.
  5. ------------------------------------------------------------------------------*/
  6.  
  7. #pragma DEBUG OBJECTEXTEND CODE   /* gma lines can contain state C51       */
  8.                                   /* command line directives                  */
  9.  
  10. #include <reg51.h>                /* special function register declarations   */
  11.                                   /*  the intended 8051 derivative         */
  12.  
  13. #include <stdio.h>                /* prototype declarations for I/O functions */
  14.  
  15.  
  16. /****************/
  17. /* main program */
  18. /****************/
  19. void main (void)  {               /* execution starts here after stack init   */
  20.  
  21. /* do not initilize the serial interface if you are running with Monitor-51   */
  22. #ifndef MON51  
  23.   SCON  = 0x50;                   /* SCON: mode 1, 8-bit UART, enable rcvr    */
  24.   TMOD |= 0x20;                   /* TMOD: timer 1, mode 2, 8-bit reload      */
  25.   TH1   = 0xf3;                   /* TH1:  reload value for 2400 baud         */
  26.   TR1   = 1;                      /* TR1:  timer 1 run                        */
  27.   TI    = 1;                      /* TI:   set TI to send first char of UART  */
  28. #endif
  29.  
  30.   printf ("Hello World\n");       /* the 'printf' function call               */
  31.  
  32.   while (1) {                     /* An embedded program does not stop and    */
  33.     ;  /* ... */                  /* never returns.  We've used an endless    */
  34.   }                               /* loop.  You may wish to put in your own   */
  35. }                                 /* code were we've printed the dots (...).  */
  36.