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

📄 max6675.lst

📁 Application examples max6675Application examples max6675Application examples max6675
💻 LST
字号:
C51 COMPILER V8.02   MAX6675                                                               04/04/2007 11:14:45 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE MAX6675
OBJECT MODULE PLACED IN Max6675.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Max6675.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg51.h>
   2          #include <stdlib.h>
   3          #include <stdio.h>
   4          #include "SVM12864_lcd.h"
   5          
   6          #define uchar unsigned char
   7          #define uint unsigned int
   8          //--------------热电偶数字转换器MAX6675
   9          sbit SO=P1^0;
  10          sbit CS=P1^1;
  11          sbit SCK=P1^2;
  12          
  13          sbit P1_7=P1^7;
  14          sbit P1_6=P1^6;
  15          
  16          sbit P2_0=P2^0;
  17          sbit P2_1=P2^1;
  18          
  19          /*******************************************************
  20          FUNCTION:delay_ms(uchar ntimes)
  21          parameter: nTimes--延迟的毫秒数
  22          cai 2006.05.20
  23          *******************************************************/
  24          void delay_ms(uchar ntimes)
  25          {
  26   1         uchar i;
  27   1         for (i = 0; i<ntimes;i++)
  28   1         {
  29   2           TH0 = 256 - (1000/256);
  30   2           TL0 = 1000%256;
  31   2           TR0 = 1;
  32   2           while (!TF0);
  33   2           TF0 = 0;
  34   2         }
  35   1           TR0 = 0;
  36   1      }
  37          /**************************************************************
  38          //FUNCTION:delay_ms(uchar ntimes)
  39          //parameter: nTimes--延迟的微秒数
  40          //sample:delay_ms(10);
  41          //cai 2006.05.20
  42          //*************************************************************/
  43          void delay_us(uchar ntimes)
  44          {
  45   1         TH0 = 0xFF;
  46   1         TL0 = 256 - ntimes;
  47   1         TR0 = 1;
  48   1         while (!TF0);
  49   1         TR0 = 0;
  50   1         TF0 = 0;   
  51   1      }
  52          /********************************
  53          //读取MAX6675
  54          *********************************/
  55          int Read_6675()
C51 COMPILER V8.02   MAX6675                                                               04/04/2007 11:14:45 PAGE 2   

  56          { uchar i;
  57   1        uint dat_temp; 
  58   1        uint dat_6675;
  59   1        i=0;
  60   1        dat_temp=0;
  61   1        dat_6675=0;
  62   1        //ready
  63   1        CS=0;
  64   1        //delay_us(10);
  65   1        SCK=0;
  66   1        //delay_us(10);
  67   1        //get D15-D0 from 6675
  68   1        for(i=0;i<16;i++)
  69   1        {       
  70   2         SCK=1;  
  71   2         dat_temp=dat_temp<<1; 
  72   2         if(SO==1)
  73   2          dat_temp=dat_temp|0x01;
  74   2         SCK=0;
  75   2         //delay_us(10);
  76   2        }
  77   1        CS=1;
  78   1        dat_temp=dat_temp<<1;
  79   1        dat_temp=dat_temp>>4;
  80   1        dat_temp=dat_temp/4;
  81   1        dat_6675 =    dat_temp;
  82   1        return dat_6675;
  83   1      }
  84          /* *******************************
  85          //转换读取MAX6675的数据dat
  86          *********************************/
  87          void dat_cov(uint dat)
  88          {
  89   1      }
*** WARNING C280 IN LINE 87 OF MAX6675.C: 'dat': unreferenced local variable
  90          
  91          main()
  92          {
  93   1      uint j;
  94   1      uint dat;
  95   1      uint margin;
  96   1      uchar i;
  97   1      char a[16];
  98   1      char smargin[16];
  99   1      
 100   1      margin=0;
 101   1      dat=0;
 102   1      j=0;
 103   1      margin=25;
 104   1      
 105   1      //LCDRST=0;
 106   1      for(i=0;i<5;i++) delay_ms(200);
 107   1      //LCDRST=1;
 108   1      LCD_Ini();
 109   1      LCD_At(1);
 110   1      LCD_Printf("Test clear CMD ..");
 111   1      LCD_At(2);
 112   1      LCD_Printf("Foracb!");
 113   1      LCD_At(3);
 114   1      LCD_Printf("The MRGN is 25`C");
 115   1       while(1)
 116   1        {
C51 COMPILER V8.02   MAX6675                                                               04/04/2007 11:14:45 PAGE 3   

 117   2          LCD_At(4);
 118   2              //读取MAX6675的温度值
 119   2          dat=Read_6675();
 120   2              if(dat>=0)
 121   2              {
 122   3          sprintf(a,"T is %d`C",dat);
 123   3              LCD_Printf(a);
 124   3              }
 125   2              //低于MRGN/margin 警报!
 126   2              if(dat<=margin) P1_6=0;
 127   2              else P1_6=1;
 128   2      
 129   2              //键盘扫描 调整参数MRGN/margin
 130   2              P2_0=1; //      用于调整参数MRGN/margin
 131   2              P2_1=1; //      用于调整参数MRGN/margin
 132   2              while(P2_0&&P2_1&&j<60000){j++;};
 133   2              if(P2_0==0) 
 134   2              {
 135   3              margin=margin-1;
 136   3              }
 137   2              else if(P2_1==0)
 138   2              {
 139   3              margin=margin+1;
 140   3              };
 141   2              if(j<60000)
 142   2              {
 143   3              LCD_At(3);
 144   3              sprintf(smargin,"The MRGN is %d`C",margin);
 145   3          LCD_Printf(smargin);
 146   3              for(i=0;i<80;i++) delay_ms(200);
 147   3              }
 148   2              j=0;
 149   2        }
 150   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    911    ----
   CONSTANT SIZE    =     70    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      44
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  1 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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