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

📄 main.lst

📁 ZLG500B读卡模块的程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
 144          
 145          /****************************************************************************
 146          *                                                                           *
 147          * Function:     serial_init                                                        *
 148          *                                                                           *
 149          * Input:        -                                                           *
 150          * Output:       -                                                           *
 151          *                                                                           *
 152          * Description:                                                              *
 153          *                                                                           *
 154          *                                                                           *
 155          ****************************************************************************/
 156          
 157          void    serial_init (void)
 158          {
 159   1              PCON = 0x80;                    // SMOD = 1;
 160   1              SCON = 0x50;                    // Mode 1, 8-bit UART, enable receiption
 161   1              TMOD&=0x0f;
 162   1              TMOD|=0x20;                     // Timer 1, mode 2, 8-bit auto reload,
 163   1              
 164   1              switch(baud_num)
 165   1              {       
 166   2                      case 0: TH1=BAUD_2400;  break;
 167   2                      case 1: TH1=BAUD_4800;  break;
 168   2                      case 2: TH1=BAUD_9600;  break;
 169   2                      case 3: TH1=BAUD_19200; break;
 170   2                      case 4: TH1=BAUD_28800; break;
 171   2                      case 5: TH1=BAUD_57600; break;
 172   2              }
 173   1              
 174   1              CON_485=0;
 175   1              ES = 1;
 176   1              ET1 = 0;
 177   1              TR1 = 1;
 178   1      }
 179          
C51 COMPILER V7.02b   MAIN                                                                 03/02/2006 18:25:03 PAGE 4   

 180          #pragma noaregs
 181          
 182          /****************************************************************************
 183          *                                                                           *
 184          * Function:     delay_50us                                                  *
 185          *                                                                           *
 186          * Input:        _50us                                                       *
 187          * Output:       -                                                           *
 188          *                                                                           *
 189          * Description:                                                              *
 190          *                                                                           *
 191          * Time delay with a resolution of 50 us.                                    *
 192          *                                                                           *
 193          ****************************************************************************/
 194          
 195          void    delay_50us (uchar _50us)
 196          {
 197   1      
 198   1        RCAP2LH = RCAP2_50us;
 199   1        T2LH    = RCAP2_50us;
 200   1        ET2 = 0;      // Disable timer2 interrupt
 201   1        T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
 202   1        
 203   1        while (_50us--)
 204   1        {
 205   2              while (!TF2);
 206   2              TF2 = FALSE;
 207   2        }
 208   1      
 209   1        TR2 = FALSE;
 210   1      
 211   1      }
 212          
 213          
 214          /****************************************************************************
 215          *                                                                           *
 216          * Function:     delay_1ms                                                   *
 217          *                                                                           *
 218          * Input:        _1ms                                                        *
 219          * Output:       -                                                           *
 220          *                                                                           *
 221          * Description:                                                              *
 222          *                                                                           *
 223          * Time delay with a resolution of 1 ms.                                     *
 224          *                                                                           *
 225          ****************************************************************************/
 226          
 227          void    delay_1ms (uint _1ms)
 228          {
 229   1      
 230   1        RCAP2LH = RCAP2_1ms;
 231   1        T2LH    = RCAP2_1ms;
 232   1        ET2 = 0;      // Disable timer2 interrupt
 233   1        T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
 234   1        
 235   1        while (_1ms--)
 236   1        {
 237   2              while (!TF2);
 238   2              TF2 = FALSE;
 239   2        }
 240   1        TR2 = FALSE;
 241   1      
C51 COMPILER V7.02b   MAIN                                                                 03/02/2006 18:25:03 PAGE 5   

 242   1      }
 243          
 244          
 245          /****************************************************************************
 246          *                                                                           *
 247          * Function:     delay_10ms                                                  *
 248          *                                                                           *
 249          * Input:        _10ms                                                       *
 250          * Output:       -                                                           *
 251          *                                                                           *
 252          * Description:                                                              *
 253          *                                                                           *
 254          * Time delay with a resolution of 10 ms.                                    *
 255          *                                                                           *
 256          ****************************************************************************/
 257          
 258          void    delay_10ms (uint _10ms)
 259          {
 260   1      
 261   1        RCAP2LH = RCAP2_10ms;
 262   1        T2LH    = RCAP2_10ms;
 263   1        ET2 = 0;      // Disable timer2 interrupt
 264   1        T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
 265   1        
 266   1        while (_10ms--)
 267   1        {
 268   2              while (!TF2);
 269   2              TF2 = FALSE;
 270   2        }
 271   1        TR2 = FALSE;
 272   1      
 273   1      }
 274          
 275          
 276          #pragma aregs
 277          
 278          
 279          
 280          /***************************************************************************/


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    799    ----
   CONSTANT SIZE    =     12    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      9      22
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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