C51 COMPILER V7.05   URAT                                                                  07/26/2011 12:33:37 PAGE 1   


C51 COMPILER V7.05, COMPILATION OF MODULE URAT
OBJECT MODULE PLACED IN URAT.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE URAT.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          //-----------------------------------------------------------------------------------------------------//
   2          // PROJECT NAME    - UART
   3          // AUTHOR MAIL     - bhau2727@gmail.com
   4          // DATE OF ALTERED - 27/7/2011
   5          // HARDWARE        - PCF 8591 WITH P89V51RD2 BASED 
   6          // SOFTWARE        - INPUTS   HIGH LEVEL - 1 // LOW LEVEL - 0 //CONNECT PC TO MC AND OPEN HYPER TERMINAL,U
             - CAN RECIVE
   7          //                   HELLO WORLD! FROM MC
   8          //-----------------------------------------------------------------------------------------------------//
   9          
  10          //----------------------------------HEADER Declarations--------------------------------------//
  11          #include <reg51.h>
  12          #include <string.h>
  13          
  14          //----------------------------------lcd Declarations--------------------------------------//
  15          
  16          void initlcd(void);  //intiate lcd
  17          void cmd_lcd(unsigned char command);
  18          void data_lcd(unsigned char data2lcd);
  19          void lcd_shortdelay(void);
  20          void delay_ms(unsigned char milliseconds);
  21          void printlcd(unsigned char *message, unsigned char row, unsigned char col);
  22          #define LCD_PORT P1
  23          sbit enable=P3^4;
  24          sbit regsel=P3^5;
  25          
  26          //----------------------------------uart Declarations--------------------------------------//
  27          
  28          void inituart(void);
  29          void Tx_Data(unsigned char);
  30          void SCI_String_Tx(unsigned char *string);
  31          
  32          //----------------------------------main function--------------------------------------//
  33          
  34          void main(void)
  35          {
  36   1              initlcd();
  37   1              inituart();
  38   1              while(1)
  39   1              {
  40   2                      cmd_lcd(0x0C);
  41   2                      printlcd("SENDING DATA..",0,0);//print in frist line
  42   2                      delay_ms(1000);
  43   2                      SCI_String_Tx("HELLO WORLD!"); //send data to terminal
  44   2                      printlcd("HELLO WORLD!",1,0);  //print in second line
  45   2                      delay_ms(1000);
  46   2                      cmd_lcd(0x01);
  47   2                      delay_ms(10);
  48   2                      
  49   2              }
  50   1      }
  51          
  52          //----------------------------------uart functions--------------------------------------//
  53          
  54          void inituart()
C51 COMPILER V7.05   URAT                                                                  07/26/2011 12:33:37 PAGE 2   

  55          {
  56   1              TMOD=0X21;
  57   1              SCON=0X50;
  58   1              TH1=0XFD;
  59   1              TR1=1;
  60   1              
  61   1      }
  62          
  63          void Tx_Data(unsigned char v)
  64          {
  65   1               SBUF=v;
  66   1               while(TI==0);
  67   1               TI=0;
  68   1      }
  69          
  70          
  71          void SCI_String_Tx(unsigned char *string) 
  72          {
  73   1              while(*string)
  74   1              {
  75   2                      Tx_Data(*(string++));
  76   2              }
  77   1      }
  78          
  79          //----------------------------------lcd functions--------------------------------------//
  80          
  81          void initlcd()
  82          {
  83   1              enable=0;
  84   1              delay_ms(20);
  85   1              cmd_lcd(0x30);
  86   1              delay_ms(5);
  87   1              cmd_lcd(0x30);
  88   1              cmd_lcd(0x30);
  89   1              cmd_lcd(0x38);
  90   1              cmd_lcd(0x08);
  91   1      //      cmd_lcd(0x01);
  92   1              cmd_lcd(0x06);
  93   1              cmd_lcd(0x0e);
  94   1      }
  95          
  96          void cmd_lcd(unsigned char command)
  97          {
  98   1              LCD_PORT=command;
  99   1              regsel=0;
 100   1              enable=1;
 101   1              enable=0;
 102   1              lcd_shortdelay();
 103   1      }
 104          
 105          void data_lcd(unsigned char databyte)
 106          {       
 107   1              LCD_PORT=databyte;
 108   1              regsel=1;
 109   1              enable=1;
 110   1              enable=0;
 111   1              lcd_shortdelay();
 112   1      }
 113          
 114          void printlcd(unsigned char *message, unsigned char row, unsigned char col)
 115          {
 116   1              cmd_lcd(0x80 + (0x40*row) + col);
C51 COMPILER V7.05   URAT                                                                  07/26/2011 12:33:37 PAGE 3   

 117   1              
 118   1              for(; *message; message++)
 119   1                      data_lcd(*message);
 120   1              
 121   1      }
 122          
 123          void lcd_shortdelay(void)
 124          {
 125   1              unsigned char t=23;
 126   1              while(t--);
 127   1      }
 128                  
 129          void delay_ms(unsigned char ms)
 130          {
 131   1              unsigned char t1;
 132   1              unsigned int t2;
 133   1      
 134   1              for(t1=0; t1<ms; t1++){
 135   2                      for(t2=0; t2<711; t2++);
 136   2              }
 137   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    277    ----
   CONSTANT SIZE    =     28    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       8
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
