找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

帖子
查看: 14096|回復(fù): 10
打印 上一主題 下一主題
收起左側(cè)

warning C318: can't open file 'delay.h' Keil編譯出錯

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:524762 發(fā)表于 2019-4-29 22:05 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
LCD1602顯示環(huán)境溫度程序運(yùn)行出錯怎么解決LCD1602顯示環(huán)境溫度程序運(yùn)行出錯怎么解決

compiling text.c...
text.c(3): warning C318: can't open file '18B20.h'
text.c(4): warning C318: can't open file 'delay.h'
text.c(5): warning C318: can't open file 'LCD1602.h'
text.c(109): warning C206: 'write_com': missing function-prototype
text.c(109): error C267: 'write_com': requires ANSI-style prototype
text.c - 1 Error(s), 4 Warning(s).


單片機(jī)源程序如下:
  1. #include <reg51.h>
  2. #include<intrins.h>
  3. #include "18B20.h"
  4. #include "delay.h"
  5. #include "LCD1602.h"
  6. float TM;  
  7. int tvalue;
  8. unsigned char tflag;
  9. unsigned char data disdata[5];  

  10. sbit DQ = P3^4;
  11. sbit LcdRs                = P2^0;
  12. sbit LcdRw                = P2^1;
  13. sbit LcdEn          = P2^2;
  14. sfr  DBPort         = 0x80;                //P0=0x80,P1=0x90,P2=0xA0,P3=0xB0.
  15. void delay_18B20(unsigned int i)
  16. {
  17.          while(i--);
  18. }

  19. void Init_DS18B20(void)   
  20. {
  21.          unsigned char x=0;
  22.          DQ = 1;   
  23.          delay_18B20(8);  
  24.          DQ = 0;   
  25.          delay_18B20(80);
  26.          DQ = 1;
  27.          delay_18B20(14);
  28.          x=DQ;
  29.          delay_18B20(20);
  30. }  

  31. unsigned char ReadOneChar(void)  
  32. {
  33.         unsigned char i=0;
  34.         unsigned char dat = 0;
  35.         for (i=8;i>0;i--)
  36.          {
  37.                   DQ = 0;
  38.                   dat>>=1;
  39.                   DQ = 1;
  40.                   if(DQ)
  41.                   dat|=0x80;
  42.                   delay_18B20(4);
  43.          }
  44.          return(dat);
  45. }
  46. void WriteOneChar(unsigned char dat)   
  47. {
  48.          unsigned char i=0;
  49.          for (i=8; i>0; i--)
  50.          {
  51.                   DQ = 0;
  52.                  DQ = dat&0x01;
  53.             delay_18B20(5);
  54.                  DQ = 1;
  55.             dat>>=1;
  56. }
  57. }
  58.         
  59. unsigned char *ReadTemperature(char TH,char TL,unsigned char RS)
  60. {        unsigned char tt[2];
  61.         Init_DS18B20();
  62.         WriteOneChar(0xCC);   
  63.         WriteOneChar(0x4E);   
  64.    
  65.         WriteOneChar(TH);   
  66.         WriteOneChar(TL);   
  67.         WriteOneChar(RS);   
  68.                                                 

  69.         delay_18B20(80);       // this message is wery important
  70.         Init_DS18B20();
  71.         WriteOneChar(0xCC);   
  72.         WriteOneChar(0x44);   

  73.         delay_18B20(80);       // this message is wery important
  74.         Init_DS18B20();
  75.         WriteOneChar(0xCC);   
  76.         WriteOneChar(0xBE);   
  77.         delay_18B20(80);

  78.         tt[0]=ReadOneChar();   
  79.         tt[1]=ReadOneChar();   
  80.         return(tt);
  81. }

  82. void ds1820disp()
  83.         {
  84.                 unsigned char flagdat;
  85.           disdata[0]=tvalue/1000+0x30;
  86.     disdata[1]=tvalue%1000/100+0x30;
  87.     disdata[2]=tvalue%100/10+0x30;
  88.     disdata[3]=tvalue%10+0x30;
  89.    
  90.     if(tflag==0)
  91.             flagdat=0x20;
  92.     else
  93.        flagdat=0x2d;

  94.     if(disdata[0]==0x30)
  95.           {disdata[0]=0x20;
  96.                 if(disdata[1]==0x30)
  97.                 {disdata[1]=0x20;
  98.                 }
  99.                 }

  100.            write_com(0x80+0x40);
  101.            write_date(flagdat);
  102.            write_com(0x80+0x41);
  103.            write_date(disdata[0]);
  104.            write_com(0x80+0x42);
  105.            write_date(disdata[1]);      
  106.            write_com(0x80+0x43);
  107.            write_date(disdata[2]);         
  108.            write_com(0x80+0x44);
  109.            write_date(0x2e);        
  110.            write_com(0x80+0x45);
  111.            write_date(disdata[3]);
  112.            write_com(0x80+0x46);
  113.            write_date('C');
  114.    }
復(fù)制代碼


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:96682 發(fā)表于 2019-4-29 23:09 | 只看該作者
軟件提示缺少這些文件必要的文件
回復(fù)

使用道具 舉報

板凳
ID:524762 發(fā)表于 2019-4-30 10:24 | 只看該作者
wc86110 發(fā)表于 2019-4-29 23:09
軟件提示缺少這些文件必要的文件

是.h文件里面的嘛?
回復(fù)

使用道具 舉報

地板
ID:110606 發(fā)表于 2019-4-30 16:34 | 只看該作者
是你編譯所在的文件夾下,缺少那幾個文件,
#include "18B20.h"
#include "delay.h"
#include "LCD1602.h"
的意思是去調(diào)用這三個文件,但是你的文件夾下面沒有這三個文件,就會報錯
回復(fù)

使用道具 舉報

5#
ID:123289 發(fā)表于 2019-4-30 17:02 | 只看該作者
你在程序中引用了它,編譯平臺就去找了,但平臺在你指定或默認(rèn)的路徑中未找到它。
所以請你補(bǔ)一下。
回復(fù)

使用道具 舉報

6#
ID:524762 發(fā)表于 2019-5-1 21:31 | 只看該作者
好的,謝謝你們
回復(fù)

使用道具 舉報

7#
ID:478236 發(fā)表于 2019-5-7 15:25 | 只看該作者
可能是#include"  "改為這個#include<>
回復(fù)

使用道具 舉報

8#
ID:522450 發(fā)表于 2019-5-7 23:52 | 只看該作者
把那三個文件放在這個工程的target還是source里面,就是跟main.c放在一個文件夾下,一定要一個文件夾下,就可以了,就能找到了,現(xiàn)在是同目錄下找不到這三個文件。
回復(fù)

使用道具 舉報

9#
ID:530349 發(fā)表于 2019-5-8 13:52 | 只看該作者
看看有沒有這種文件
回復(fù)

使用道具 舉報

10#
ID:530609 發(fā)表于 2019-5-8 14:39 | 只看該作者
#include<reg52.h> #include<intrins.h> #define uchar unsigned char #define uint  unsigned int
回復(fù)

使用道具 舉報

11#
ID:522654 發(fā)表于 2019-5-8 16:22 | 只看該作者
同一工程文件里 你是不是沒有加那些.h文件
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表