找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3214|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

單片機(jī)C語言錯(cuò)誤C141:syntax error near 'void'請大家?guī)兔聪鲁绦,謝謝

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:910118 發(fā)表于 2021-4-23 10:00 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#include<reg52.h>
#include "intrins.h"      //調(diào)用_nop_();延時(shí)函數(shù)用
unsigned char code dispbitcode[]=
{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char dispbuf[4];
unsigned char getdata;
unsigned int temp;
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^2;
sbit CLK=P3^3;
sbit ALE=P3^7;
sbit P34=P3^4;
sbit P35=P3^5;
sbit P36=P3^6;
sbit P20=P2^0;
sbit P21=P2^1;
sbit P22=P2^2;
sbit P23=P2^3;
sbit P17=P1^7;
sbit P26=P2^6;
sbit P27=P2^7;
void TimeInitial();
void Delay(unsigned int i);
void TimeInitial()
{ TMOD=0x01;
TH0=(65536-200)/256;
TL0=(65536-200)%256;
EA=1;
ET0=1;
TR0=1;
}
void Delay(unsigned int i)
{
  unsigned int j;
  for(;i>0;i--)
  {
  for(j=0;j<100;j++)
  {;}
  }
}
void Display()
{
P1=dispbitcode[dispbuf[3]];
P20=0;
P21=1;
P22=1;
P23=1;
Delay(10);//避免閃爍
P1=0x00;  //關(guān)閉一下,否則顯示不全
P1=dispbitcode[dispbuf[2]];
P17=1;
P20=1;
P21=0;
P22=1;
P23=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[1]];
P20=1;
P21=1;
P22=0;
P23=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[0]];
P20=1;
P21=1;
P22=1;
P23=0;
Delay(10);
P1=0x00;
}
void adzhuanh()
{P34=0;        //地址通道
P35=0;
P36=0;
ALE=1;
_nop_();
_nop_();
ALE=0;
ST=1;
_nop_();
_nop_();
ST=0;
_nop_();
_nop_();
_nop_();
_nop_();
while(EOC==0);
OE=1;
getdata=P0;
OE=0;/*
temp=getdata*1.0/255*500;*/temp=getdata*200.0/255.0*12.0;
if (temp>1800)
{_nop_();
_nop_();
_nop_();
_nop_();
P26=1;
P27=0;
dispbuf[0]=temp/2%10;
dispbuf[1]=temp/20%10;
dispbuf[2]=temp/200%10;
dispbuf[3]=temp/2000;
}
void main()
{
TimeInitial();
while(1)
{adzhuanh();
Display(); }
else
{_nop_();
_nop_();
_nop_();
_nop_();
P27=1;
P26=0;
dispbuf[0]=temp/2%10;
dispbuf[1]=temp/20%10;
dispbuf[2]=temp/200%10;
dispbuf[3]=temp/2000;
Display();}

}
}
void t0(void) interrupt 1 using 0
{
  TH0=(65536-200)/256;
  TL0=(65536-200)%256;
  CLK=~CLK;
  }

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

使用道具 舉報(bào)

沙發(fā)
ID:64089 發(fā)表于 2021-4-23 11:45 | 只看該作者
1  void adzhuanh()
{}兩個(gè)大括號不對成,你可以點(diǎn)擊左邊一個(gè)括號,看看右邊的在哪里就知道了;
2  主循環(huán)里面while(1) 和else 沒有這種用法,else 和 if是一對,把while(1)改成if(1)就編譯過了。
注,我只是幫你查找編譯問題,功能邏輯自己整理。

評分

參與人數(shù) 1黑幣 +30 收起 理由
admin + 30 回帖助人的獎(jiǎng)勵(lì)!

查看全部評分

回復(fù)

使用道具 舉報(bào)

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

本版積分規(guī)則

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

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

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