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

📄 main.lst

📁 一整套电梯控制器源程序
💻 LST
字号:
C51 COMPILER V6.12  MAIN                                                                   05/25/2005 14:58:14 PAGE 1   


C51 COMPILER V6.12, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\main.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE .\main.c DEBUG OBJECTEXTEND

stmt level    source

   1          #include "public.h"
   2          
   3          void main(void)
   4          {
   5   1      
   6   1          P1_2=1;       //确保上电时LED光耦不动作
   7   1          //MCU初始化
   8   1          init();
   9   1      
  10   1          //读5045(得到5种数据,将在can初始化时使用,实际上显示板仅F0控制器号F2显示方式有用)
  11   1          read5states();
  12   1      
  13   1          //can初始化
  14   1          can_init();
  15   1      
  16   1          //数据初始化
  17   1          init_data();
  18   1          
  19   1          P1_2=0;       //取消上电时LED光耦不动作
  20   1      
  21   1          while(1){
  22   2              //若200ms没有CAN数据则认为应该复位CAN
  23   2              if(time_nocan200ms_flg==1){
  24   3                  time_nocan_count=TIMER_NOCANDATA_NUM; //无CAN数据计数
  25   3                  time_nocan_flg=0;                     //无CAN数据标志
  26   3                  time_nocan200ms_flg=0;                //无CAN数据计时到标志  
  27   3                  P2_7=0;
  28   3                  _nop_();
  29   3                  _nop_();
  30   3                  _nop_();
  31   3                  _nop_();
  32   3                  _nop_();
  33   3                  _nop_();
  34   3                  _nop_();
  35   3                  _nop_();
  36   3                  _nop_();
  37   3                  _nop_();
  38   3                  _nop_();
  39   3                  _nop_();
  40   3              
  41   3                  P2_7=1;
  42   3                  can_init();
  43   3              }
  44   2      
  45   2              if(m_set5045flg==0){
  46   3              	write5045();
  47   3              	m_set5045flg=1;
  48   3              }
  49   2      
  50   2              //can接收
  51   2      	    receivedata();
  52   2      
  53   2              //功能设置
  54   2              setfunc();
  55   2      
C51 COMPILER V6.12  MAIN                                                                   05/25/2005 14:58:14 PAGE 2   

  56   2              //显示当前应该显示的内容
  57   2              display();
  58   2      
  59   2              led();
  60   2      
  61   2              ReportStop();
  62   2      
  63   2              watchdog();
  64   2      
  65   2          }
  66   1      }
  67          //功能设置(F0-F4切换时,设置各种功能)
  68          void setfunc(void)
  69          {
  70   1          //"跳线+上呼或下呼按钮按下",进入子功能设置状态
  71   1          //"跳线+上呼或下呼按钮未按下+脱离子功能设定超3s",进入父功能设置状态
  72   1          if(P1_7==0){                        
  73   2              if(P1_6==0){                //功能按钮被按下(对应上呼按钮按下)
  74   3                  m_cSettingFuncFlg=0;
  75   3                  m_cSettingSubFuncFlg=1;
  76   3                  m_cSubToParLess2sFlg=1;
  77   3              }else if(m_cSubToParLess2sFlg==1){
  78   3                  m_cSettingFuncFlg=0;
  79   3                  m_cSettingSubFuncFlg=1; 
  80   3              }else if(m_cSubToParLess2sFlg==0){
  81   3                  m_cSettingFuncFlg=1;
  82   3                  m_cSettingSubFuncFlg=0;
  83   3              }
  84   2          }
  85   1      
  86   1      
  87   1          if(P1_7==0)                         //功能切换
  88   1          if((m_cSettingFuncFlg==1) && (m_cSettingSubFuncFlg==0))
  89   1          if(m_cNewFuncFlg==1){
  90   2      //  if((m_cFuncTimer--)==0){    			//2004.08.31  14:21 LHM  
  91   2              m_cFuncCnt++;
  92   2              if(m_cFuncCnt>=FUNC_NUM)
  93   2                  m_cFuncCnt=0;
  94   2      
  95   2              if(m_cFuncCnt==0){
  96   3                  m_cSubFuncCnt=data5045.cF0;
  97   3              }else if(m_cFuncCnt==1){
  98   3                  m_cSubFuncCnt=data5045.cF1;
  99   3              }else if(m_cFuncCnt==2){
 100   3                  m_cSubFuncCnt=data5045.cF2;
 101   3              }else if(m_cFuncCnt==3){
 102   3                  m_cSubFuncCnt=data5045.cF3;
 103   3              }else if(m_cFuncCnt==4){
 104   3                  m_cSubFuncCnt=data5045.cF4;
 105   3      		}else if(m_cFuncCnt==5){
 106   3                  m_cSubFuncCnt=data5045.cF5;
 107   3      		}else if(m_cFuncCnt==6){
 108   3                  m_cSubFuncCnt=data5045.cF6;
 109   3      		}else if(m_cFuncCnt==7){
 110   3                  m_cSubFuncCnt=data5045.cF7;
 111   3      		}
 112   2      
 113   2              m_cNewFuncFlg=0;
 114   2              m_cFuncTimer=TIMER_FUNC_NUM;
 115   2      
 116   2          }  
 117   1      
C51 COMPILER V6.12  MAIN                                                                   05/25/2005 14:58:14 PAGE 3   

 118   1          if(P1_7==0)                         //子功能切换
 119   1          if((m_cSettingFuncFlg==0) && (m_cSettingSubFuncFlg==1))
 120   1          if(m_cNewSubFuncFlg==1){
 121   2              //最大取值
 122   2              if(m_cFuncCnt==0){
 123   3                  m_cMaxSubNum=7;
 124   3              }else if(m_cFuncCnt==1){
 125   3                  m_cMaxSubNum=47;
 126   3      //            m_cMaxSubNum=m_RecData.cMaxFloor;
 127   3              }else if(m_cFuncCnt==2){
 128   3                  m_cMaxSubNum=3;
 129   3              }else if(m_cFuncCnt==3){
 130   3                  m_cMaxSubNum=1;
 131   3              }else if(m_cFuncCnt==4){
 132   3                  m_cMaxSubNum=1;
 133   3      		}else if(m_cFuncCnt==5){
 134   3                  m_cMaxSubNum=55;
 135   3              }else if(m_cFuncCnt==6){
 136   3                  m_cMaxSubNum=1;
 137   3              }
 138   2              
 139   2              //范围检查
 140   2              if(m_cSubFuncCnt>m_cMaxSubNum)
 141   2                  m_cSubFuncCnt=m_cMaxSubNum;
 142   2      
 143   2              if(P1_6==0){                    //功能选择按钮被按下(对应上呼按钮按下,累加)
 144   3      //            if((m_cSubFuncTimer--)==0){            
 145   3                      if(m_cSubFuncCnt<m_cMaxSubNum) 
 146   3                      	m_cSubFuncCnt++;
 147   3                      else
 148   3                      	m_cSubFuncCnt=0;
 149   3                      m_cNewSubFuncFlg=0;
 150   3                      m_cSubFuncTimer=TIMER_SUBFUNC_NUM;
 151   3      //            } 
 152   3              }
 153   2      
 154   2              if(m_cFuncCnt==0){
 155   3                  data5045.cF0=m_cSubFuncCnt;
 156   3      			m_set5045flg=0;
 157   3                  /*在给SJA1000进行初始化时,发现有这样一个问题,当SJA1000工作之后,就没办法将其进行初始化了。
 158   3                    除非将其硬件复位。为了改正这个状况,现在的解决办法是,当设置发生变化时,进行写5045操作:s5045
             -();
 159   3                    在写操作后,将sja1000复位管脚复位,然后重新调用sja1000初始化程序。
 160   3                    此时将重新进行SJA1000的初始化工作
 161   3                    最初执行的操作为:在重新写设置数据到4045后,执行死循环.此时将导致CPU复位.程序将重新的开始,但
             -现在
 162   3                    可通过对sja1000的复位脚进行操作对其硬件复位。
 163   3                  */          
 164   3                  P2_7=0;                
 165   3                  _nop_();
 166   3                  _nop_();
 167   3                  _nop_();
 168   3                  _nop_();
 169   3                  _nop_();
 170   3                  P2_7=1;
 171   3                  can_init();
 172   3              }else if(m_cFuncCnt==1){
 173   3                  data5045.cF1=m_cSubFuncCnt;
 174   3                  m_set5045flg=0;
 175   3      //楼层设置无用
 176   3      /*
 177   3                  P2_7=0;                
C51 COMPILER V6.12  MAIN                                                                   05/25/2005 14:58:14 PAGE 4   

 178   3                  _nop_();
 179   3                  _nop_();
 180   3                  _nop_();
 181   3                  _nop_();
 182   3                  _nop_();
 183   3                  P2_7=1;
 184   3                  can_init();*/
 185   3              }else if(m_cFuncCnt==2){
 186   3                  data5045.cF2=m_cSubFuncCnt;
 187   3      			m_set5045flg=0;
 188   3              }else if(m_cFuncCnt==3){
 189   3                  data5045.cF3=m_cSubFuncCnt;
 190   3      			m_set5045flg=0;
 191   3              }else if(m_cFuncCnt==4){
 192   3                  data5045.cF4=m_cSubFuncCnt;
 193   3      			m_set5045flg=0;
 194   3      		}else if(m_cFuncCnt==5){
 195   3                  data5045.cF5=m_cSubFuncCnt;
 196   3      			m_set5045flg=0;
 197   3      		}else if(m_cFuncCnt==6){
 198   3                  data5045.cF6=m_cSubFuncCnt;
 199   3      			m_set5045flg=0;
 200   3      		}else if(m_cFuncCnt==7){
 201   3                  data5045.cF7=m_cSubFuncCnt;
 202   3      			m_set5045flg=0;
 203   3      		}
 204   2          }
 205   1      }
 206          
 207          //报站(报站)
 208          void ReportStop(void)
 209          {
 210   1      	uchar cTemp=0;
 211   1      
 212   1          m_cReportData = m_cReportIdx;
 213   1      
 214   1          if(m_cReportFlg==1){
 215   2              m_cReportingFlg = 1;
 216   2              m_cReportFlg=0;         //设置后,立即清标记
 217   2              time_report_flg=1;
 218   2          }
 219   1      
 220   1          if(time_report2s_flg==1){   //报时2s时间到,停止报时
 221   2          	m_cReportData=m_cReportData&0x7F;
 222   2              m_cReportingFlg=0;
 223   2              time_report_count=TIMER_REPORT_NUM;
 224   2              time_report_flg=0;
 225   2              time_report2s_flg=0;
 226   2          }
 227   1          
 228   1          if(m_cReportingFlg==1){
 229   2              m_cReportData = 0x80|m_cReportIdx;
 230   2          }else if(m_cReportingFlg==0){
 231   2              m_cReportData = m_cReportData&0x7F;
 232   2          }
 233   1      	
 234   1      	if(data5045.cF7==1){		//报站输出高有效
 235   2      		cTemp = m_cReportData;
 236   2      	}else if(data5045.cF7==0){	//报站输出低有效
 237   2      		cTemp = ~m_cReportData;
 238   2      	}
 239   1      
C51 COMPILER V6.12  MAIN                                                                   05/25/2005 14:58:14 PAGE 5   

 240   1      //    PF377 = m_cReportData;
 241   1      	PF377 = cTemp;
 242   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    565    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   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 + -