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

📄 sio.lst

📁 家电考试系统下位机程序
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V6.23a  SIO                                                                   05/11/2007 22:24:42 PAGE 1   


C51 COMPILER V6.23a, COMPILATION OF MODULE SIO
OBJECT MODULE PLACED IN SIO.OBJ
COMPILER INVOKED BY: C:\Keil623\C51\BIN\C51.EXE SIO.C OPTIMIZE(11,SPEED) REGFILE(.\intsio2.ORC) BROWSE DEFINE(XTAL=11059
                    -200) OBJECTADVANCED DEBUG CODE SYMBOLS PREPRINT

stmt level    source

   1          
   2          #include <reg52.h>
   3          #include <string.h>
   4          #include "sio.h"
   5          
   6          /*------------------------------------------------------------------------------
   7          Notes:
   8          
   9          The length of the receive and transmit buffers must be a power of 2.
  10          
  11          Each buffer has a next_in and a next_out index.
  12          
  13          If next_in = next_out, the buffer is empty.
  14          
  15          (next_in - next_out) % buffer_size = the number of characters in the buffer.
  16          ------------------------------------------------------------------------------*/
  17          #define TBUF_SIZE   2           /*** Must be one of these powers of 2 (2,4,8,16,32,64,128) ***/
  18          #define RBUF_SIZE   8           /*** Must be one of these powers of 2 (2,4,8,16,32,64,128) ***/
  19          
  20          #define TBUF_SPACE  idata       /*** Memory space where the transmit buffer resides ***/
  21          #define RBUF_SPACE  idata       /*** Memory space where the receive buffer resides ***/
  22          
  23          #define CTRL_SPACE  data        /*** Memory space for the buffer indexes ***/
  24           /* #define XTAL 12000000L  */
  25            #define XTAL 11059200L
*** WARNING C317 IN LINE 25 OF SIO.C: redefinition of macro 'XTAL'
  26          /*------------------------------------------------------------------------------
  27          ------------------------------------------------------------------------------*/
  28          #if TBUF_SIZE < 2
              #error TBUF_SIZE is too small.  It must be larger than 1.
              #elif TBUF_SIZE > 128
              #error TBUF_SIZE is too large.  It must be smaller than 129.
              #elif ((TBUF_SIZE & (TBUF_SIZE-1)) != 0)
              #error TBUF_SIZE must be a power of 2.
              #endif
  35          
  36          #if RBUF_SIZE < 2
              #error RBUF_SIZE is too small.  It must be larger than 1.
              #elif RBUF_SIZE > 128
              #error RBUF_SIZE is too large.  It must be smaller than 129.
              #elif ((RBUF_SIZE & (RBUF_SIZE-1)) != 0)
              #error RBUF_SIZE must be a power of 2.
              #endif
  43          
  44          /*------------------------------------------------------------------------------
  45          ------------------------------------------------------------------------------*/
  46          sbit P34     = 0xB4;
  47          static TBUF_SPACE unsigned char tbuf [TBUF_SIZE];
  48          static RBUF_SPACE unsigned char rbuf [RBUF_SIZE];
  49          
  50          static CTRL_SPACE unsigned char t_in = 0;
  51          static CTRL_SPACE unsigned char t_out = 0;
  52          
  53          static CTRL_SPACE unsigned char r_in = 0;
C51 COMPILER V6.23a  SIO                                                                   05/11/2007 22:24:42 PAGE 2   

  54          static CTRL_SPACE unsigned char r_out = 0;
  55          
  56          static bit ti_restart = 0;  /* NZ if TI=1 is required */
  57          
  58           extern void update_LCD( unsigned char ASC_II );
  59          
  60          /*------------------------------------------------------------------------------
  61          ------------------------------------------------------------------------------*/
  62          static void com_isr (void) interrupt 4
  63          {   unsigned char temp  ;
  64   1      /*------------------------------------------------
  65   1      Received data interrupt.
  66   1      ------------------------------------------------*/
  67   1      if (RI != 0)
  68   1        {
  69   2        RI = 0;
  70   2        if( P34 == 0 ) {    //P34 == 0,主机呼叫
  71   3        if (((r_in - r_out) & ~(RBUF_SIZE-1)) == 0)
  72   3          {
  73   4          rbuf [r_in & (RBUF_SIZE-1)] = SBUF;
  74   4          r_in++;
  75   4          }
  76   3          }// if( P34 )
  77   2        }
  78   1      P34 = 1;
  79   1      /*------------------------------------------------
  80   1      Transmitted data interrupt.
  81   1      ------------------------------------------------*/
  82   1      if (TI != 0)
  83   1        {
  84   2        TI = 0;
  85   2      
  86   2        if (t_in != t_out)
  87   2          {
  88   3          SBUF = tbuf [t_out & (TBUF_SIZE-1)];
  89   3          t_out++;
  90   3          ti_restart = 0;
  91   3          }
  92   2        else
  93   2          {
  94   3          ti_restart = 1;
  95   3          }
  96   2        }
  97   1      
  98   1      }
*** WARNING C280 IN LINE 63 OF SIO.C: 'temp': unreferenced local variable
  99          
 100          /*------------------------------------------------------------------------------
 101          ------------------------------------------------------------------------------*/
 102          #pragma disable
 103          
 104          void com_initialize (void)
 105          {
 106   1      /*------------------------------------------------
 107   1      Setup TIMER1 to generate the proper baud rate.
 108   1      ------------------------------------------------*/
 109   1      //com_baudrate (1200);
 110   1      
 111   1      /*------------------------------------------------
 112   1      Clear com buffer indexes.
 113   1      ------------------------------------------------*/
 114   1      t_in = 0;
C51 COMPILER V6.23a  SIO                                                                   05/11/2007 22:24:42 PAGE 3   

 115   1      t_out = 0;
 116   1      
 117   1      r_in = 0;
 118   1      r_out = 0;
 119   1      
 120   1      /*------------------------------------------------
 121   1      Setup serial port registers.
 122   1      ------------------------------------------------*/
 123   1      SM0 = 0; SM1 = 1;   /* serial port MODE 1 */
 124   1      SM2 = 0;
 125   1      REN = 1;            /* enable serial receiver */
 126   1      
 127   1      RI = 0;             /* clear receiver interrupt */
 128   1      TI = 0;             /* clear transmit interrupt */
 129   1      ti_restart = 1;
 130   1      
 131   1      ES = 1;             /* enable serial interrupts */
 132   1      PS = 0;             /* set serial interrupts to low priority */
 133   1      }
 134          
 135          /*------------------------------------------------------------------------------
 136          ------------------------------------------------------------------------------*/
 137          #pragma disable
 138          
 139          void com_baudrate (
 140            unsigned baudrate)
 141          {
 142   1      /*------------------------------------------------
 143   1      Clear transmit interrupt and buffer.
 144   1      ------------------------------------------------*/
 145   1      TI = 0;             /* clear transmit interrupt */
 146   1      t_in = 0;           /* empty transmit buffer */
 147   1      t_out = 0;
 148   1      
 149   1      /*------------------------------------------------
 150   1      Set timer 1 up as a baud rate generator.
 151   1      ------------------------------------------------*/
 152   1      TR1 = 0;            /* stop timer 1 */
 153   1      ET1 = 0;            /* disable timer 1 interrupt */
 154   1      
 155   1      PCON |= 0x80;       /* 0x80=SMOD: set serial baudrate doubler */
 156   1      
 157   1      TMOD &= ~0xF0;      /* clear timer 1 mode bits */
 158   1      TMOD |= 0x20;       /* put timer 1 into MODE 2 */
 159   1      
 160   1      TH1 = (unsigned char) (256 - (XTAL / (16L * 12L * baudrate)));
 161   1      
 162   1      TR1 = 1;            /* start timer 1 */
 163   1      }
 164          
 165          /*------------------------------------------------------------------------------
 166          ------------------------------------------------------------------------------*/
 167          #pragma disable
 168          
 169          char com_putchar (
 170            unsigned char c)
 171          {
 172   1      /*------------------------------------------------
 173   1      If the buffer is full, return an error value.
 174   1      ------------------------------------------------*/
 175   1      if (com_tbuflen () >= TBUF_SIZE)
 176   1        return (-1);
C51 COMPILER V6.23a  SIO                                                                   05/11/2007 22:24:42 PAGE 4   

 177   1      
 178   1      /*------------------------------------------------
 179   1      Add the data to the transmit buffer.  If the
 180   1      transmit interrupt is disabled, then enable it.
 181   1      ------------------------------------------------*/
 182   1      tbuf [t_in & (TBUF_SIZE - 1)] = c;
 183   1      t_in++;
 184   1      
 185   1      if (ti_restart)
 186   1        {
 187   2        ti_restart = 0;
 188   2        TI = 1;               /* generate transmit interrupt */
 189   2        }
 190   1      
 191   1      return (0);
 192   1      }
 193          
 194          /*------------------------------------------------------------------------------
 195          ------------------------------------------------------------------------------*/
 196          #pragma disable
 197          
 198          int com_getchar (void)
 199          {
 200   1      if (com_rbuflen () == 0)
 201   1      

⌨️ 快捷键说明

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