⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.lst

📁 Cygnal C8051F020 Dual UART Example
💻 LST
字号:
C51 COMPILER V7.06   MAIN                                                                  06/02/2003 14:21:06 PAGE 1   


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

stmt level    source

   1          /*-----------------------------------------------------------------------------
   2          -----------------------------------------------------------------------------*/
   3          #include <C8051F020.H>
   4          #include <stdio.h>                /* prototype declarations for I/O functions */
   5          
   6          
   7          bit sio_port = 1;   /* SIO port to use (0 = SIO0) */
   8          
   9          /*-----------------------------------------------------------------------------
  10          The following putchar function replaces the one in the library.
  11          -----------------------------------------------------------------------------*/
  12          char putchar (char c)
  13          {
  14   1      if (sio_port == 0)
  15   1        {
  16   2        while (!TI0);
  17   2        TI0 = 0;
  18   2        SBUF0 = c;
  19   2        }
  20   1      else
  21   1        {
  22   2        while (!(SCON1 & (1 << 1)));  /* While TI1 = 0 */
  23   2        SCON1 &= ~(1 << 1);           /* TI1 = 0 */
  24   2        SBUF1 = c;
  25   2        }
  26   1      
  27   1      return (c);
  28   1      }
  29          
  30          /*-----------------------------------------------------------------------------
  31          The following _getkey function replaces the one in the library.
  32          -----------------------------------------------------------------------------*/
  33          char _getkey (void)
  34          {
  35   1      char c;
  36   1      
  37   1      if (sio_port == 0)
  38   1        {
  39   2        while (!RI0);
  40   2        c = SBUF0;
  41   2        RI0 = 0;
  42   2        }
  43   1      else
  44   1        {
  45   2        while (!(SCON1 & (1 << 0)));  /* While RI1 = 0 */
  46   2        c = SBUF1;
  47   2        SCON1 &= ~(1 << 0);           /* RI1 = 0 */
  48   2        }
  49   1      
  50   1      return (c);
  51   1      }
  52          
  53          /*-----------------------------------------------------------------------------
  54          The main C function.
  55          -----------------------------------------------------------------------------*/
C51 COMPILER V7.06   MAIN                                                                  06/02/2003 14:21:06 PAGE 2   

  56          void main (void) {
  57   1      
  58   1      /*------------------------------------------------
  59   1      NOTE:  You must properly configure the crossbar
  60   1      for your application.
  61   1      ------------------------------------------------*/
  62   1      
  63   1      /*------------------------------------------------
  64   1      Disable the watchdog timer.  This should probably
  65   1      be done in the STARTUP code.
  66   1      ------------------------------------------------*/
  67   1      WDTCN = 0xDE;
  68   1      WDTCN = 0xAD;
  69   1      
  70   1      /*------------------------------------------------
  71   1      Setup the serial port 0 for 1200 baud at 2MHz
  72   1      using timer 2.
  73   1      
  74   1      See http://www.keil.com/c51/baudrate.asp for
  75   1      baudrate calculations and reload values.
  76   1      ------------------------------------------------*/
  77   1          SCON0  = 0x50;              /* SCON:  Mode 1, 8-bit UART, enable rcvr */
  78   1          T2CON  = 0x30;              /* T2CON: Use T2 for Baud Rate on SIO 0 */
  79   1      
  80   1          RCAP2L = 0xCC;              /* RCAP2: Reload value for 1200 baud */
  81   1          TL2    = 0xCC;
  82   1          RCAP2H = 0xFF;
  83   1          TH2    = 0xFF;
  84   1      
  85   1          TR2   = 1;                  /* TR2: T2 Run */
  86   1          TI0   = 1;                  /* TI0: Set TI0 to send first char of SIO 0 */
  87   1      
  88   1      /*------------------------------------------------
  89   1      Setup the serial port 1 for 2400 baud at 2MHz
  90   1      using timer 4.
  91   1      
  92   1      See http://www.keil.com/c51/baudrate.asp for
  93   1      baudrate calculations and reload values.
  94   1      ------------------------------------------------*/
  95   1          SCON1  = 0x50;              /* SCON1: Mode 1, 8-bit UART, enable rcvr */
  96   1          T4CON  = 0x30;              /* T4CON: Use T4 for Baud Rate on SIO 1 */
  97   1      
  98   1          RCAP4L = 0xE6;              /* RCAP4: Reload value for 2400 baud */
  99   1          TL4    = 0xE6;
 100   1          RCAP4H = 0xFF;
 101   1          TH4    = 0xFF;
 102   1      
 103   1          T4CON |= 1 << 2;            /* TR4: T4 Run */
 104   1          SCON1 |= 1 << 1;            /* TI1: Set TI1 to send first char of SIO 1 */
 105   1      
 106   1      /*------------------------------------------------
 107   1      ------------------------------------------------*/
 108   1        while (1) {
 109   2          char c;
 110   2      
 111   2          sio_port = !sio_port;       /* switch ports */
 112   2          printf ("Press a key: ");
 113   2          c = _getkey ();
 114   2          printf ("\r\nYou pressed %c\r\n", c);
 115   2        }
 116   1      }
 117          
C51 COMPILER V7.06   MAIN                                                                  06/02/2003 14:21:06 PAGE 3   



MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    128    ----
   CONSTANT SIZE    =     33    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       1
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -