找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 7778|回復: 6
打印 上一主題 下一主題
收起左側

c語言程序問題

[復制鏈接]
跳轉到指定樓層
樓主
ID:12970 發(fā)表于 2009-5-16 22:45 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式

#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcden=P2^7;
sbit lcdrs=P2^6;
sbit lcdrw=P3^6;
uchar count,shi,fen ,miao;
uchar code table[]="   2009-5-16";
uchar code table1[]="   00:00:00";
void delay(uint z)
{
  uint x,y;
  for(x=z;x>0;x--)
    for(y=110;y>0;y--);
}
void write_sfm(uchar add,uchar date)
{
  uchar ge, shi ;
  shi=date/10;
  ge=date%10; 
  write_com(0x80+0x40+add);
  write_data(0x30+shi);
  write_data(0x30+ge); 
}


void write_com(uchar com)
{
  lcdrs=0;
  lcden=0;
  delay(5);
  P0=com;
  delay(5);
  lcden=1;
  delay(5);
  lcden=0;
}
void write_data(uchar date)
{
  lcdrs=1;
  lcden=0;
  delay(5);
  P0=date;
  delay(5);
  lcden=1;
  delay(5);
  lcden=0;
}
void init()
{
 lcdrw=0;
 write_com(0x38);
 write_com(0x0c);
 write_com(0x06);
 write_com(0x01);
 write_com (0x80);
 TMOD=0X01;
 TH0=(65535-50000)/256;
 TL0=(65535-50000)%256;
 EA=1;
 ET0=1;
 TR0=1;
}
main()
 {
  uchar num;
  init();
  for(num=0;num<12;num++)
    {
  write_data(table[num]);
  delay(5);
 
  }
  write_com(0x80+0x40);
  for(num=0;num<11;num++)
    {
  write_data(table1[num]);
  delay(5);
 
 }
  while(1)
 { 
  if(count==20)
  {
    miao++;
    if(miao==60)
   {
      miao==0;
    fen++;
      if(fen==60)
     {fen=0;
    shi++;
    if(shi==24)
     {
      shi=0;
     }
     }
      }
  write_sfm(10,miao);

  }
 
 } 
}
void time0() interrupt 1
{
 TH0=(65535-50000)/256;
 TL0=(65535-50000)%256;
 count++;

 

 

}keil調試后,出現 warning C206: 'write_com': missing function-prototype。


  write_com(0x80+0x40+add);這句有何錯

 

 

 

 

 

 

 

 

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

使用道具 舉報

沙發(fā)
ID:13475 發(fā)表于 2009-5-27 07:08 | 只看該作者
將write_com函數放在調用它的函數之前就行.或在調用該函數時先聲明一下.C語言關于函數內容要補課了
回復

使用道具 舉報

板凳
ID:5810 發(fā)表于 2009-7-9 09:23 | 只看該作者

#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcden=P2^7;
sbit lcdrs=P2^6;
sbit lcdrw=P3^6;
uchar count,shi,fen ,miao;
uchar code table[]="   2009-5-16";
uchar code table1[]="   00:00:00";
void write_com(uchar com);
void write_data(uchar date);


void delay(uint z)
{
  uint x,y;
  for(x=z;x>0;x--)
    for(y=110;y>0;y--)
 ;
}
void write_sfm(uchar add,uchar date)
{
  uchar ge, shi ;
  shi=date/10;
  ge=date%10; 
  write_com(0x80+0x40+add);
  write_data(0x30+shi);
  write_data(0x30+ge); 
}


void write_com(uchar com)
{
  lcdrs=0;
  lcden=0;
  delay(5);
  P0=com;
  delay(5);
  lcden=1;
  delay(5);
  lcden=0;
}
void write_data(uchar date)
{
  lcdrs=1;
  lcden=0;
  delay(5);
  P0=date;
  delay(5);
  lcden=1;
  delay(5);
  lcden=0;
}
void init()
{
 lcdrw=0;
 write_com(0x38);
 write_com(0x0c);
 write_com(0x06);
 write_com(0x01);
 write_com (0x80);
 TMOD=0X01;
 TH0=(65535-50000)/256;
 TL0=(65535-50000)%256;
 EA=1;
 ET0=1;
 TR0=1;
}
main()
 {
  uchar num;
  init();
  for(num=0;num<12;num++)
    {
  write_data(table[num]);
  delay(5);
 
  }
  write_com(0x80+0x40);
  for(num=0;num<11;num++)
    {
  write_data(table1[num]);
  delay(5);
 
 }
  while(1)
 { 
  if(count==20)
  {
    miao++;
    if(miao==60)
   {
      miao==0;
    fen++;
      if(fen==60)
     {fen=0;
    shi++;
    if(shi==24)
     {
      shi=0;
     }
     }
      }
  write_sfm(10,miao);

  }
 
 } 
}
void time0() interrupt 1
{
 TH0=(65535-50000)/256;
 TL0=(65535-50000)%256;
 count++;

 

 

}

回復

使用道具 舉報

地板
ID:23217 發(fā)表于 2010-4-25 10:17 | 只看該作者

 #include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcden=P2^7;
sbit lcdrs=P2^6;
sbit lcdrw=P3^6;
uchar count,shi,fen ,miao;
uchar code table[]="   2009-5-16";
uchar code table1[]="   00:00:00";
void delay(uint z)
{
  uint x,y;
  for(x=z;x>0;x--)
    for(y=110;y>0;y--);
}

  void write_data(uchar date)
{
  lcdrs=1;
  lcden=0;
  delay(5);
  P0=date;
  delay(5);
  lcden=1;
  delay(5);
  lcden=0;
}
void write_com( uchar com)
{
  lcdrs=0;
  lcden=0;
  delay(5);
  P0=com;
  delay(5);
  lcden=1;
  delay(5);
  lcden=0;
}
 
void write_sfm(uchar add,uchar date)
{
  uchar ge, shi ;
  shi=date/10;
  ge=date%10; 
  write_com(0x80+0x40+add);
  write_data(0x30+shi);
  write_data(0x30+ge); 
}

 


void init()
{
 lcdrw=0;
 write_com(0x38);
 write_com(0x0c);
 write_com(0x06);
 write_com(0x01);
 write_com (0x80);
 TMOD=0X01;
 TH0=(65535-50000)/256;
 TL0=(65535-50000)%256;
 EA=1;
 ET0=1;
 TR0=1;
}
main()
 {
  uchar num;
  init();
  for(num=0;num<12;num++)
    {
  write_data(table[num]);
  delay(5);
 
  }
  write_com(0x80+0x40);
  for(num=0;num<11;num++)
    {
  write_data(table1[num]);
  delay(5);
 
 }
  while(1)
 { 
  if(count==20)
  {
    miao++;
    if(miao==60)
   {
      miao==0;
    fen++;
      if(fen==60)
     {fen=0;
    shi++;
    if(shi==24)
     {
      shi=0;
     }
     }
      }
  write_sfm(10,miao);

  }
 
 } 
}
void time0() interrupt 1
{
 TH0=(65535-50000)/256;
 TL0=(65535-50000)%256;
 count++;

 

 

}

回復

使用道具 舉報

5#
ID:22103 發(fā)表于 2010-4-30 17:58 | 只看該作者

支持樓上了,寫函數之前,在main之前聲明一下啊。

回復

使用道具 舉報

6#
ID:24670 發(fā)表于 2010-7-9 13:51 | 只看該作者

一樓正解,write_com()跟write_data()這兩個函數要寫在write_sfm()前面,在者在它前面需要有個函數說明,不然調用的時候找不到地址,系統(tǒng)不知道去哪里找這個函數

 

回復

使用道具 舉報

7#
ID:24818 發(fā)表于 2010-7-14 10:12 | 只看該作者
樓上說得很詳細哦,支持一個
回復

使用道具 舉報

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

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表