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

📄 us100test.lst

📁 避障模块
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   US100TEST                                                             12/27/2010 10:30:28 PAGE 1   


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

stmt level    source

   1          
   2          #include "US100Test.h"
   3          
   4          void Delay1Ms(void);
   5          void Delay5Ms(void);
   6          void Delay400Ms(void);
   7          
   8          void UART_ISR(void);
   9          void UARTSnd(unsigned char dat);
  10          void UART_init();
  11          void init(void);
  12          
  13          sbit RCK_STMM = P2^7;
  14          sbit DIO_DS       = P2^6;
  15          sbit SCK_SHBit = P2^5;
  16          
  17          sbit Trig_Mode = P2^0;
  18          sbit UART_Mode = P2^1;
  19          sbit UART_TEMP  = P2^2;
  20          
  21          sbit Trig_Pin = P1^7;
  22          sbit Echo_Pin = P1^6;
  23          
  24          unsigned char LastRcvData;
  25          unsigned char GLengthHigh, GLengthLow, GTempera;
  26          unsigned char RcvIndex;
  27          
  28          void UART_ISR(void) interrupt 4
  29          {
  30   1              RI = 0;                                                 // clear receive interrupt flag
  31   1              LastRcvData=SBUF;                                               // copy input bufffer to ch
  32   1              if(RcvIndex == 0)
  33   1              {
  34   2                      GLengthHigh = LastRcvData;
  35   2                      RcvIndex++;
  36   2              }
  37   1              else if(RcvIndex == 1)
  38   1              {
  39   2                      GLengthLow = LastRcvData;
  40   2                      RcvIndex = 150;
  41   2              }
  42   1              else if(RcvIndex == 100)
  43   1              {
  44   2                      GTempera = LastRcvData;
  45   2                      RcvIndex++;
  46   2              }
  47   1      }
  48          
  49          void UARTSnd(unsigned char dat)
  50          {
  51   1      
  52   1              TI=0;                                           // clear transmit interrupt flag
  53   1              SBUF=dat;                               // start sending one byte
  54   1              while (!TI);                            // wait until sent
  55   1      
C51 COMPILER V7.06   US100TEST                                                             12/27/2010 10:30:28 PAGE 2   

  56   1      }
  57          
  58           
  59          void UART_init()
  60          {       
  61   1              SCON=0x50;                              // select BRG as UART Baud Rate Gen
  62   1              SSTAT=0x60;                             // separate Rx / Tx interrupts
  63   1              BRGR0=0xF0;                             // setup BRG for 9600 baud @ 7.373MHz internal RC oscillator
  64   1              BRGR1=0x02;
  65   1              //BRGR0=0x70;                           // setup BRG for 9600 baud @ 12MHz external Crystal
  66   1      //      BRGR1=0x04;
  67   1              BRGCON = 0x03;                  // enable BRG
  68   1      
  69   1              P1M1 = 0x00;     //push pull except RX
  70   1              P1M2 = 0xFD;
  71   1              ES = 1;                 // enable UART interrupt
  72   1              EA = 1;
  73   1      
  74   1              RcvIndex = 0;
  75   1      }
  76          
  77          unsigned char GetPreMode()//1: Trig mode, 2:UART Length, 3:UART Temperature
  78          {
  79   1              P2M1 |= 0X07;
  80   1              P2M2 &= 0XF8;
  81   1      
  82   1              Delay1Ms();//UARTSnd(tempa);
  83   1      
  84   1              if(Trig_Mode == 0)
  85   1                      return 1;
  86   1              if(UART_Mode == 0)
  87   1                      return 2;
  88   1              if(UART_TEMP == 0)
  89   1                      return 3;
  90   1              return 0;
  91   1      }
  92          
  93          
  94          
  95          void InitIOPort()
  96          {       
  97   1      //      P0M1 = 0XFF //p0口设为输入。
  98   1              P0M1 = 0;//P0口设为双向口,可输入输出
  99   1              P0M2 = 0;//P0口设为双向口,可输入输出
 100   1      
 101   1              P2M1 &= 0X0F;//P2口的P2.5,P2.6,P2.7设为双向口,可输入输出
 102   1              P2M2 &= 0X0F;//P2口的P2.5,P2.6,P2.7设为双向口,可输入输出
 103   1      }
 104          
 105          
 106          void DisplayLED(unsigned char LEDid, unsigned char Value, unsigned char Isdot)
 107          {
 108   1              unsigned char tempa, tempb;
 109   1              unsigned char tempc, tempd;
 110   1              const unsigned char NumValue[11] = {0X40, 0X79, 0X24, 0X30, 0X19, 0X12, 0X02, 0X78, 0X00, 0X10, 0X3F};//0
             -, 1, 2, 3, 4, 5, 6, 7, 8, 9, -.
 111   1              
 112   1              tempa = 1;
 113   1              tempa <<= (LEDid-1);
 114   1              if(Value >= 11)//value should little than 10
 115   1                      Value = 0;
 116   1              tempb = NumValue[Value];
C51 COMPILER V7.06   US100TEST                                                             12/27/2010 10:30:28 PAGE 3   

 117   1              if(Isdot == 0)
 118   1                      tempb += 0X80;
 119   1      
 120   1              //begin output
 121   1              tempd = 0X80;
 122   1              for(tempc = 0; tempc < 8; tempc++)
 123   1              {
 124   2                      SCK_SHBit = 0;
 125   2                      SCK_SHBit = 0;
 126   2                      DIO_DS  = (tempa&tempd);
 127   2                      SCK_SHBit = 1;
 128   2                      SCK_SHBit = 1;
 129   2                      tempd >>= 1;
 130   2              }
 131   1      
 132   1              tempd = 0X80;
 133   1              for(tempc = 0; tempc < 8; tempc++)
 134   1              {
 135   2                      SCK_SHBit = 0;
 136   2                      SCK_SHBit = 0;
 137   2                      DIO_DS  = (tempb&tempd);
 138   2                      SCK_SHBit = 1;
 139   2                      SCK_SHBit = 1;
 140   2                      tempd >>= 1;
 141   2              }
 142   1      
 143   1              RCK_STMM = 0;
 144   1              RCK_STMM = 0;
 145   1              RCK_STMM = 0;
 146   1              RCK_STMM = 0;
 147   1              RCK_STMM = 1;
 148   1              RCK_STMM = 1;
 149   1              RCK_STMM = 1;
 150   1              RCK_STMM = 1;
 151   1              //Delay1Ms();
 152   1      }
 153          
 154          void DisplayLength(unsigned long number)
 155          {
 156   1              unsigned char Thousand, Hundred, Decade, Unit;
 157   1              if(number > 9999)
 158   1                      number = 0;
 159   1              Thousand = number/1000;
 160   1      
 161   1              number = number%1000;
 162   1              Hundred = number/100;
 163   1      
 164   1              number = number%100;
 165   1              Decade = number/10;
 166   1      
 167   1              Unit = number%10;
 168   1      
 169   1              DisplayLED(1, Thousand, 0);
 170   1              DisplayLED(2, Hundred, 0);
 171   1              DisplayLED(3, Decade, 0);
 172   1              DisplayLED(4, Unit, 0);
 173   1      }
 174          
 175          void DisplayTemperature(unsigned char tempa)
 176          {
 177   1              unsigned char Decade, Unit;
 178   1              unsigned char FlagPosi;
C51 COMPILER V7.06   US100TEST                                                             12/27/2010 10:30:28 PAGE 4   

 179   1              if(tempa >= 45)
 180   1              {
 181   2                      tempa -= 45;
 182   2                      FlagPosi = 1;
 183   2              }
 184   1              else
 185   1              {
 186   2                      tempa = 45-tempa;
 187   2                      FlagPosi = 0;
 188   2              }
 189   1      
 190   1              if(tempa > 99)

⌨️ 快捷键说明

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