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

📄 host.lst

📁 主从式总线型SIO系统(多机双向通信)
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.16   HOST                                                                  03/21/2009 23:04:12 PAGE 1   


C51 COMPILER V8.16, COMPILATION OF MODULE HOST
OBJECT MODULE PLACED IN Host.OBJ
COMPILER INVOKED BY: E:\Program Files\设计软件\Keil\C51\BIN\C51.EXE Host.c DEBUG OBJECTEXTEND

line level    source

   1           //*********主机代码******
   2           #include <reg51.h>
   3           #include "Clicent_Setting.h"
   4           #include "LCD_Funtion.h"
   5           #include "Futions.h"
   6           #include "Host_Interrupt_Funtion.h"
   7          
   8           int num1=1;   //从机数码管起始数
   9           int num2=0;
  10           int num3=1;
  11          //*****************
  12          void main(void)
  13          {
  14   1              Serial_Set();    //串口设置
  15   1              Lcd_Init();               //LCD初始化
  16   1              Interrupt_Init();       //中断初始化
  17   1              ClrScreen();            //LCD清屏
  18   1      
  19   1              while(1)
  20   1              {
  21   2               if(Intval1&&Int_pro1)                  //如果第一次中断0,采集从机1温度
  22   2               {
  23   3                              Serial_Init();                          //初始化串口
  24   3                              SBUF=STD1;                                      //发送从机1 ID
  25   3                              while(!TI);                                     //等待发送完成
  26   3                              TI=0;
  27   3                                                      
  28   3                              while(Int_pro1)                         //如果没触发第二次中断
  29   3                                      {
  30   4                                      if(Serial1)                             //从机1响应是否正确
  31   4                                      {  
  32   5                                              if(Serial1==1)          //如果从机正确接收到地址
  33   5                                              {       
  34   6                                                      SCON=0xd0;               //串口允许接收数据
  35   6                                                      Serial1=0;
  36   6                                                      SBUF=Clicent_Command1;   //发送命令给从机1告知从机这是命令
  37   6                                                      while(!TI);
  38   6                                                      TI=0;
  39   6                                              }
  40   5                                              if(Serial1==2&&SendTo1==1)              //
  41   5                                              {       
  42   6                                                      Serial1=0;
  43   6                                                      SBUF=Clicent_Receive_Data1;      //发送从机1接收数据的命令
  44   6                                                      while(!TI);
  45   6                                                      TI=0;
  46   6                                              }
  47   5      
  48   5                                              if(Serial1==2&&ReceiveFrom1==1)         //如果从机1正确接受到命令
  49   5                                              {       
  50   6                                                      Serial1=0;              //
  51   6                                                      SBUF=Clicent_Data_Command1;             //发送把从机1结果送主机的命令
  52   6                                                      while(!TI);
  53   6                                                      TI=0;
  54   6                                              }
  55   5                                              if(Serial1==3)     //接收从机1 温度数据
C51 COMPILER V8.16   HOST                                                                  03/21/2009 23:04:12 PAGE 2   

  56   5                                              {       
  57   6                                                      Serial1=0;
  58   6      
  59   6                                                      SBUF=Clicent_Send_Data1;         //发送给从机发送数据命令
  60   6                                                      while(!TI);
  61   6                                                      TI=0;
  62   6      
  63   6                                                      while(!RI);
  64   6                                                      RI=0;
  65   6                                                      DS18B20_Data[0]=SBUF;                     //接收温度数据
  66   6                                                      while(!RI);
  67   6                                                      RI=0;
  68   6                                                      DS18B20_Data[1]=SBUF;
  69   6                                                       
  70   6                                                      ClrScreen();  //LCD清屏
  71   6                                                      GotoXY(0,0);                                            
  72   6                                                      Print_Str("NUM1");//LCD显示从机号
  73   6                                                      temperature_process(DS18B20_Data[0],DS18B20_Data[1]);  //温度数据处理
  74   6                                                 
  75   6                                                 if(!flag) //正                          LCD显示正温度
  76   6                                                      {
  77   7                                                      GotoXY(0,1);
  78   7                                                      Print_Str(zhen_temp);
  79   7                                                      if(dot_dis)     
  80   7                                                      Print_Str(".");
  81   7                                                      Print_Str(xiaoshu_temp);
  82   7                                                      Print_Char(0xdf);
  83   7                                                      Print_Str("C");
  84   7                                      }
  85   6                                      else   //负                             LCD显示负温度
  86   6                                      {
  87   7                                                      GotoXY(0,1);
  88   7                                                      Print_Str("-");
  89   7                                                      Print_Str(zhen_temp);   
  90   7                                                      Print_Str(".");
  91   7                                                      Print_Str(xiaoshu_temp);
  92   7                                                  Print_Char(0xdf);
  93   7                                                      Print_Str("C");
  94   7                                      }
  95   6                                              
  96   6                                              }
  97   5                                              if(Serial1==4)                          //主机向从机发送数据
  98   5                                              {
  99   6                                               Serial1=0;                     
 100   6                                              SBUF=num1;                                      //发送数据1 3 5 7 9....给从机1测试(奇数递增)
 101   6                                              while(!TI);                                     //等待发送完成
 102   6                                      TI=0;
 103   6                                              num1=num1+2; 
 104   6                                              }        
 105   5                                      }
 106   4                               }
 107   3               }
 108   2      //****************************
 109   2      
 110   2      //*****************************
 111   2               if(Intval2&&Int_pro2)                  //如果第二次中断0,采集从机2温度
 112   2               {
 113   3                              Serial_Init();                          //初始化串口
 114   3                              SBUF=STD2;                                      //发送从机2 ID
 115   3                              while(!TI);                                     //等待发送完成
 116   3                              TI=0;
 117   3                              while(Int_pro2)                         //如果没触发下次中断0,循环
C51 COMPILER V8.16   HOST                                                                  03/21/2009 23:04:12 PAGE 3   

 118   3                              { 
 119   4                                      if(Serial2)                             //从机2响应是否正确
 120   4                                      {  
 121   5                                              if(Serial2==1)          //如果从机2正确接收到地址
 122   5                                              {       
 123   6                                                      SCON=0xd0;
 124   6                                                      Serial2=0;
 125   6                                                      SBUF=Clicent_Command2;   //发送从机2命令
 126   6                                                      while(!TI);
 127   6                                                      TI=0;
 128   6                                              }
 129   5                                              if(Serial2==2&&SendTo2==1)              //
 130   5                                              {       
 131   6                                                      Serial2=0;
 132   6                                                      SBUF=Clicent_Receive_Data2;      //发送从机2接收数据命令
 133   6                                                      while(!TI);
 134   6                                                      TI=0;
 135   6                                              }
 136   5                                              if(Serial2==2&&ReceiveFrom2==1)         //如果从机正确接受到命令
 137   5                                              {       
 138   6                                                      Serial2=0;              //
 139   6                                                      SBUF=Clicent_Data_Command2;             //发送把从机结果送主机的命令
 140   6                                                      while(!TI);
 141   6                                                      TI=0;
 142   6                                              }
 143   5                                              if(Serial2==3)     //如果从机发送结果完成
 144   5                                              {       
 145   6                                                      //ClrScreen();
 146   6                                                      Serial2=0;
 147   6      

⌨️ 快捷键说明

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