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

📄 main.lst

📁 学校水POS读卡程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
 859   4      
 860   4                      do
C51 COMPILER V6.23a  MAIN                                                                  09/14/2004 14:19:20 PAGE 15  

 861   4                      {
 862   5                        if (!RXD)
 863   5                        {
 864   6                              break;
 865   6                        }
 866   5                      } while (!TF0);
 867   4                }
 868   3              } while (!TF0);
 869   2      
 870   2              TR0 = FALSE;
 871   2              TF0 = FALSE;
 872   2      
 873   2              Capt = ((uint)Capt_H << 5) | ((uint)Capt_L & 0x001F);
 874   2      
 875   2              for (BaudRate = BAUD_CNT; BaudRate >= 0; BaudRate--)
 876   2              {
 877   3                if (Capt >= CmpTable[BaudRate])
 878   3                {
 879   4                      break;
 880   4                }
 881   3              }
 882   2      
 883   2              if (BaudRate < 0 || BaudRate == BAUD_CNT) // Error baud count
 884   2              {
 885   3                TH0    = 0;
 886   3                TL0    = 0;
 887   3                Capt_L = 0;
 888   3                Capt_H = 0;
 889   3                return;
 890   3              }
 891   2      
 892   2              TMOD = 0x21;                    // Timer 0, mode 1, 16-bit counter
 893   2              TH1  = BaudRateTable[BaudRate];
 894   2              TL1  = TH1;
 895   2              TR1  = TRUE;
 896   2      
 897   2              TH0  = 0xE0;
 898   2              TL0  = 0;
 899   2              TR0  = TRUE;
 900   2              while (!TF0);                   // Wait 4.4 ms
 901   2              TR0  = FALSE;
 902   2              TF0  = FALSE;
 903   2              ET0  = TRUE;
 904   2      
 905   2              AutoBaud = FALSE;               // Baudrate had been choose, disable Autobaud
 906   2      
 907   2              SBUF = NAK;
 908   2              while (!TI);
 909   2              TI   = FALSE;
 910   2              RI   = FALSE;
 911   2              ES   = TRUE;
 912   2        }
 913   1      }
 914          
 915          #pragma noaregs
 916          
 917          /****************************************************************************
 918          *                                                                           *
 919          * Function:     delay_50us                                                  *
 920          *                                                                           *
 921          * Input:        _50us                                                       *
 922          * Output:       -                                                           *
C51 COMPILER V6.23a  MAIN                                                                  09/14/2004 14:19:20 PAGE 16  

 923          *                                                                           *
 924          * Description:                                                              *
 925          *                                                                           *
 926          * Time delay with a resolution of 50 us.                                    *
 927          *                                                                           *
 928          ****************************************************************************/
 929          
 930          void    delay_50us (uchar _50us)
 931          {
 932   1      
 933   1        RCAP2LH = RCAP2_50us;
 934   1        T2LH    = RCAP2_50us;
 935   1        ET2 = 0;      // Disable timer2 interrupt
 936   1        T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
 937   1      
 938   1        while (_50us--)
 939   1        {
 940   2              while (!TF2);
 941   2              TF2 = FALSE;
 942   2        }
 943   1      
 944   1        TR2 = FALSE;
 945   1      
 946   1      }
 947          
 948          
 949          /****************************************************************************
 950          *                                                                           *
 951          * Function:     delay_1ms                                                   *
 952          *                                                                           *
 953          * Input:        _1ms                                                        *
 954          * Output:       -                                                           *
 955          *                                                                           *
 956          * Description:                                                              *
 957          *                                                                           *
 958          * Time delay with a resolution of 1 ms.                                     *
 959          *                                                                           *
 960          ****************************************************************************/
 961          
 962          void    delay_1ms (uchar _1ms)
 963          {
 964   1      
 965   1        RCAP2LH = RCAP2_1ms;
 966   1        T2LH    = RCAP2_1ms;
 967   1        ET2 = 0;      // Disable timer2 interrupt
 968   1        T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
 969   1      
 970   1        while (_1ms--)
 971   1        {
 972   2              while (!TF2);
 973   2              TF2 = FALSE;
 974   2        }
 975   1        TR2 = FALSE;
 976   1      
 977   1      }
 978          
 979          
 980          /****************************************************************************
 981          *                                                                           *
 982          * Function:     delay_10ms                                                  *
 983          *                                                                           *
 984          * Input:        _10ms                                                       *
C51 COMPILER V6.23a  MAIN                                                                  09/14/2004 14:19:20 PAGE 17  

 985          * Output:       -                                                           *
 986          *                                                                           *
 987          * Description:                                                              *
 988          *                                                                           *
 989          * Time delay with a resolution of 10 ms.                                    *
 990          *                                                                           *
 991          ****************************************************************************/
 992          
 993          void    delay_10ms (uint _10ms)
 994          {
 995   1          
 996   1        RCAP2LH = RCAP2_10ms;
 997   1        T2LH    = RCAP2_10ms;
 998   1        ET2 = 0;      // Disable timer2 interrupt
 999   1        T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
1000   1        
1001   1      
1002   1        while (_10ms--)
1003   1        {
1004   2              while (!TF2)
1005   2              {
1006   3                if (CmdValid || CmdReceived)
1007   3                {
1008   4                      TR2 = FALSE;
1009   4                      TF2 = FALSE;
1010   4                      return;
1011   4                }
1012   3              }
1013   2              TF2 = FALSE;
1014   2        }
1015   1        TR2 = FALSE;
1016   1      
1017   1      }
1018          
1019          
1020          
1021          void test_10ms(uint n_10ms)
1022          {
1023   1          
1024   1        RCAP2LH = RCAP2_10ms;
1025   1        T2LH    = RCAP2_10ms;
1026   1        ET2 = 0;      // Disable timer2 interrupt
1027   1        T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
1028   1        
1029   1      
1030   1        while (n_10ms--)
1031   1        {
1032   2              while (!TF2)
1033   2              {
1034   3                if (CmdValid || CmdReceived)
1035   3                {
1036   4                      TR2 = FALSE;
1037   4                      TF2 = FALSE;
1038   4                      return;
1039   4                }
1040   3              }
1041   2              TF2 = FALSE;
1042   2        }
1043   1        TR2 = FALSE;
1044   1      
1045   1      }
1046          
C51 COMPILER V6.23a  MAIN                                                                  09/14/2004 14:19:20 PAGE 18  

1047          
1048          
1049          
1050          
1051          
1052          
1053          #ifdef NOP_DELAY
              
              /****************************************************************************
              *                                                                           *
              * Function:     delay_50us_NOP                                              *
              *                                                                           *
              * Input:        -                                                           *
              * Output:       -                                                           *
              *                                                                           *
              * Description: 延时函数                                                     *
              *                                                                           *
              *                                                                           *
              *                                                                           *
              ****************************************************************************/
              
              void    delay_50us_NOP (void)
              {
                uchar i;
              
                for(i=0; i<81; i++) _nop_();
              }
              
              #endif
1076          
1077          
1078          /****************************************************************************
1079          *                                                                           *
1080          * Function:     delay_8us_NOP                                               *
1081          *                                                                           *
1082          * Input:        -                                                           *
1083          * Output:       -                                                           *
1084          *                                                                           *
1085          * Description:                                                              *
1086          *                                                                           *
1087          *                                                                           *
1088          ****************************************************************************/
1089          
1090          void    delay_8us_NOP (void)
1091          {
1092   1        uchar i;
1093   1      
1094   1        for(i=0; i<14; i++) _nop_();
1095   1      }
1096          
1097          
1098          /*****************************************************
1099          
1100          
1101          *******************************************************/
1102          void   RingOn (void)
1103          {
1104   1                BEEP = 0;
1105   1                delay_10ms(2);
1106   1                BEEP = 1;
1107   1                delay_10ms(2);
1108   1                BEEP = 0;
C51 COMPILER V6.23a  MAIN                                                                  09/14/2004 14:19:20 PAGE 19  

1109   1                delay_10ms(2);
1110   1                BEEP = 1;
1111   1                delay_10ms(2);
1112   1                BEEP = 0;
1113   1                delay_10ms(2);
1114   1                BEEP = 1;
1115   1       }
1116          
1117          
1118          #pragma aregs
1119          
1120          
1121          /****************************************************************************
1122          *                                                                           *
1123          * Function:     xtoa_h                                                      *
1124          *                                                                           *
1125          * Input:        _byte                                                       *
1126          * Output:       ASCII High-Nibble                                           *
1127          *                                                                           *
1128          * Description:                                                              *
1129          *                                                                           *
1130          * Wandelt das High-Nibble des 乥ergebenen Bytes in ein ASCII-Zeichen um.    *
1131          *                                                                           *
1132          ****************************************************************************/
1133          
1134          uchar   xtoa_h (uchar _byte)
1135          {
1136   1        uchar nibble = _byte >> 4;
1137   1      
1138   1        return ((nibble > 9)? nibble + 'A' - 10 : nibble + '0');
1139   1      }
1140          
1141          
1142          /****************************************************************************
1143          *                                                                           *
1144          * Function:     xtoa_l                                                      *
1145          *                                                                           *
1146          * Input:        _byte                                                       *

⌨️ 快捷键说明

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