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

📄 main.lst

📁 一个倒车雷达程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.09   MAIN                                                                  07/23/2005 16:37:43 PAGE 1   


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

line level    source

   1          /********************************************************************
   2          倒车雷达。
   3          UCFG1=0X63,使能RPE,BOE.震荡器选择内部RC震荡器(7.73MHz)
   4          *********************************************************************/
   5          /*
   6            a                    实验板 a--g,DP对应P0.7-P0.0;
   7          -----                   数码管共阳极            gfe  dcba                  abcd efg dot
   8          |f   |b                 对应数字: 0(abcdef):   1100 0000  0xC0            0000 0011 0x03 ,XIAN SHI DOT,zu
             -i hou yi wei 0;
   9          | g  |                            1(bc):       1111 1001  0xF9             1001 1111 0x9f
  10          ------                            2(abdeg):    1100 0100  0xA4             0010 0101 0x25
  11          |e   |c                           3(abcdg):    1011 0000  0xB0             0000 1101 0x0d
  12          |    |  ..                          4(bcfg):     1001 1001  0x99           1001 1001 0x99
  13          ------  ..                          5(acdfg):    1001 0010  0x92           0100 1001 0x49
  14             d                              6(acdefg):   1000 0010  0x82             0100 0001 0x41
  15                                            7(abc):      1111 1000  0xF8             0001 1111 0x1f
  16                                            8(abcdefg):  1000 0000  0x80             0000 0001 0x01
  17                                            9(abcdfg):   1001 0000  0x90             0000 1001 0x09
  18           数码管动态显示数字,保持时间1-5ms,这里利用了眼睛的视觉特性,在这里取适中3ms。'p' abefg--0011 0001 0x31   
             - 
  19          */
  20          #include<stdio.h>
  21          #include<reg922.h>
  22          #include"uart.h"
  23          //#include"i2c.h"
  24          #include <INTRINS.H>
  25          
  26          #include<ctype.h>
  27          #define RED_LED   XTAL1
  28          #define GREEN_LED XTAL2
  29          #define ON        0
  30          #define OFF       1
  31          #define SPK       TxD
  32          #define nCS       XTAL2
  33          #define SCK       INT0
  34          #define SIN       SCL
  35          #define SOUNDHIGH 20
  36          #define SOUNDLOW  100
  37          enum _sound_flag{tingche=1,weixian=10,jingshi=50,anquan=100}sound_flag;
  38          void t0_init();
  39          //uint sound_flag;
  40          void ChuLi_Disp_Data();
  41          //void Delay(uint);
  42          //void Sound_Alarm(); //GAO JIN YING HANG SHU;
  43          void ByteTo_M35055(uchar byte_to_m35055);//XIE BYTE SHU JU JIN M35055
  44          void DataTo_M35055();
  45          
  46          /*SPI function*/
  47          void Transfer16Bit(int sendData);
  48          
  49          void DelayNus(int n);
  50          
  51          uchar databyte[3];  //JIE SHOU SAN ZI JIE;
  52          float nearest_juli;  // ZUI JIN JU LI;
  53          uint unSoundSpace;
C51 COMPILER V7.09   MAIN                                                                  07/23/2005 16:37:43 PAGE 2   

  54          uint byte_wei=1;      //ZI JIE WEI;
  55          uchar uchar_disp_wei;
  56          uint first_suzi,sec_suzi,thir_suzi; 
  57          uchar disp_data[10]={0x03,0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x09};
  58          int to_m35055_no=1;
  59          bit show_flag;
  60          uchar first_char,sec_char,thir_char,forth_char;
  61          uchar first_detector,forth_detector;
  62          //M35055 ZI FU DING YI    0(0X20),    1(0X21),   2,3,4,5,6,7,8,9  dot(0x1E)
  63          //uchar M35055_char[10]={0x20.0x21};                 
  64          void main(void)
  65          {
  66   1                 
  67   1          //start_data_flag=0;
  68   1          uchar_disp_wei=0x00;
  69   1               databyte[2]=0x80;
  70   1               first_suzi=0;
  71   1               sec_suzi=0;
  72   1               thir_suzi=0;
  73   1              unSoundSpace=0;
  74   1               SPK=OFF;
  75   1              /*Port configation*/
  76   1              P3M1  = 3;           //DING YI RED_LED,GREEN_LED;
  77   1              P3M2  = 3;
  78   1              P1M1 = 0X00;  //DING SHU MA GUAN SHU CHU;
  79   1              P1M2 = 0X00; 
  80   1              //PEI ZHI SCK,DIN   WEI KAI LOU SHU CHU
  81   1              P1M1|=0X0C;
  82   1              P1M2|=0X0C;
  83   1              //P1M1
  84   1              P0M1 = 0xFF;
  85   1              P0M2 = 0xFF;
  86   1              /*P1 value*/
  87   1          SPK = 1;
  88   1          SCK         = 1;//HIGH;  //UART clock pin
  89   1              SIN             = 1;//HIGH;  //UART data pin 
  90   1              /*P3 value*/
  91   1              nCS      = 0;//HIGH;
  92   1          RED_LED = 1;//LED_OFF;
  93   1      
  94   1              uart_init();
  95   1          t0_init();
  96   1      //      nCS=0;
  97   1      //Transfer16Bit(0x00f8);
  98   1      //      Transfer16Bit
  99   1              while(1)
 100   1              {       //nCS=1;
 101   2              if(show_flag)
 102   2              {
 103   3      //      /*
 104   3                      show_flag=0;
 105   3                      if(to_m35055_no==1)
 106   3                      {       
 107   4                      XTAL2=0;
 108   4                              Transfer16Bit(0x00f8);
 109   4                              Transfer16Bit(0x3f40); //2
 110   4                              Transfer16Bit(0x00ff);
 111   4                              Transfer16Bit(0x00ff);              //8
 112   4                              Transfer16Bit(0x00ff);
 113   4                              Transfer16Bit(0x00ff);
 114   4                      //      Transfer16Bit(0x00ff);
 115   4                              //Transfer16Bit(0x00ff);                           //10
C51 COMPILER V7.09   MAIN                                                                  07/23/2005 16:37:43 PAGE 3   

 116   4                              //Transfer16Bit(0x00ff);
 117   4                              if(nearest_juli<0.3)
 118   4                              {
 119   5                              Transfer16Bit(0x0143);  //12      //xian shi 'stop'
 120   5                              Transfer16Bit(0x0144);
 121   5                              Transfer16Bit(0x013f);  //14
 122   5                              Transfer16Bit(0x0140);
 123   5                              Transfer16Bit(0x01ff);
 124   5                              }
 125   4                              else
 126   4                              if(nearest_juli>3.15)
 127   4                              {
 128   5                              Transfer16Bit(0x01ff);  //12
 129   5                              Transfer16Bit(0x01ff);
 130   5                              Transfer16Bit(0x01ff);  //14
 131   5                              Transfer16Bit(0x01ff);
 132   5                              Transfer16Bit(0x01ff);
 133   5                              }
 134   4                              else
 135   4                              {
 136   5                              Transfer16Bit(0x0100+0x20+first_suzi);  //12
 137   5                              Transfer16Bit(0x011e);
 138   5                              Transfer16Bit(0x0100+0x20+sec_suzi);  //14
 139   5                              Transfer16Bit(0x0100+0x20+thir_suzi);
 140   5                              Transfer16Bit(0x015d);
 141   5                              }  
 142   4                              Transfer16Bit(0x00ff);
 143   4                         // Transfer16Bit(0x0100+first_detector);                        //10
 144   4                      //      Transfer16Bit(0x0100+forth_detector);
 145   4                         Transfer16Bit(0x00ff);
 146   4                              Transfer16Bit(first_char);
 147   4                              Transfer16Bit(sec_char);
 148   4                              Transfer16Bit(thir_char); 
 149   4                              Transfer16Bit(forth_char);
 150   4      
 151   4                      }
 152   3      
 153   3                      while(to_m35055_no>17&&to_m35055_no<243)
 154   3                      {
 155   4                              Transfer16Bit(0x01ff);
 156   4                              //Transfer16Bit(0x0200);
 157   4                      //      Transfer16Bit(0x0400);
 158   4                              //Transfer16Bit(0x0740);
 159   4      
 160   4                  }
 161   3              //       
 162   3                      if(to_m35055_no==243)
 163   3                      {
 164   4                      Transfer16Bit(0x0480);             //F0
 165   4                      //Transfer16Bit(0x00f1);
 166   4                      Transfer16Bit(0x1f0f);          //244  F1
 167   4                      Transfer16Bit(0x1f20);              //F2
 168   4                      Transfer16Bit(0x0001);    //246 F3
 169   4                      Transfer16Bit(0x0000);             //F4                 
 170   4                      Transfer16Bit(0x0088);      //248 F5
 171   4                      Transfer16Bit(0x201B);            //F6
 172   4                      Transfer16Bit(0x0800);   //250    //F7
 173   4                      } 
 174   3                      if(to_m35055_no==251)
 175   3                      {
 176   4                      Transfer16Bit(0x3F40);
 177   4                      to_m35055_no=1;
C51 COMPILER V7.09   MAIN                                                                  07/23/2005 16:37:43 PAGE 4   

 178   4                      XTAL2=1;
 179   4                      }
 180   3              //      */
 181   3      
 182   3                      //databyte[2]=0xd2;
 183   3              //ChuLi_Disp_Data();  
 184   3                      //Sound_Alarm();
 185   3              //DataTo_M35055();
 186   3              }
 187   2      
 188   2              }
 189   1      //      while(1){;}
 190   1      }
 191          
 192          
 193          //jie shou UART xin hao ,jiang san zi jie fen bie fang ru shu zu databyt;
 194          
 195          void rx_interrupt() interrupt 4

⌨️ 快捷键说明

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