这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » 第一次用C 遇到奇怪的问题 望高手帮忙看看

共2条 1/1 1 跳转至

第一次用C 遇到奇怪的问题 望高手帮忙看看

院士
2006-09-17 18:14:16     打赏
第一次用C 遇到奇怪的问题 望高手帮忙看看



关键词: 第一次     遇到     怪的     问题     高手     帮忙     看看    

院士
2006-12-22 22:43:00     打赏
2楼
问 #include <reg52.h>
typedef unsigned char uchar;

//油箱液面检测输入点
sbit p_in_oil_a_1=P1^0;
sbit p_in_oil_a_2=P1^1;
sbit p_in_oil_a_3=P1^2;
sbit p_in_oil_b_1=P1^3;
sbit p_in_oil_b_2=P1^4;
sbit p_in_oil_b_3=P1^5;
//用液信号输入
sbit p_in_oil_flow=P1^6;
//键盘输入
sbit p_in_key1=P0^0;
sbit p_in_key2=P0^1;
sbit p_in_key3=P0^2;
sbit p_in_key4=P0^3;
//报警量输出
sbit p_out_w_pre=P1^7;
sbit p_out_w_pwr=P3^5;
sbit p_out_w_burst=P3^6;
sbit p_out_w_oila=P0^6;
sbit p_out_w_oilb=P0^7;
//控制信号输出
sbit p_out_oila=P0^4;
sbit p_out_oilb=P0^5;
sbit p_out_power_c=P2^6;
//AD转换
sbit p_ad_cs=P3^4;
sbit p_ad_di=P2^2;
sbit p_ad_do=P2^1;
sbit p_ad_clk=P2^0;
//24C01
sbit p_24cx_sda=P2^5;
sbit p_24cx_scl=P2^4;
sbit p_24cx_wr_c=P2^3;
//LED清0
sbit p_clr_led=P2^7;

sbit acc_7=ACC^7;





uchar code ch_data_press_now[256]={0};//未计算出来

void main()
{
  void tlc_0832_sCAN();
  void tlc_0832_handle();
  
  uchar ch_data_collect[18],ch_data_collect_times,ch_data_press_now;
  ch_data_collect_times=18;//初始化采集次数
  
  // 压力采集
  tlc_0832_sCAN(&ch_data_collect_times,ch_data_collect);
  tlc_0832_handle(&ch_data_collect_times,&ch_data_press_now,ch_data_collect);
}

void tlc_0832_sCAN(times,collect_data)

  uchar *times,collect_data[18];
{
  uchar i;
  *times--;

  p_ad_clk=0;  //使能 ad
  p_ad_cs=0;  

  p_ad_di=1;  // 写控制字到AD,H0为+,单痛道采集
  p_ad_clk=1;
  p_ad_clk=0;
  p_ad_di=1;
  p_ad_clk=1;
  p_ad_clk=0;
  p_ad_di=0;
  p_ad_clk=1;

  p_ad_clk=0;  
  p_ad_clk=1;

  for(i=0;i++;i<15){ // 采集一个数据点
    p_ad_clk=0;
    acc_7=p_ad_do;    
    ACC>>1;
    p_ad_clk=1;
  }

  p_ad_cs=1;
  collect_data[*times]=ACC;//保存采集到的数据  
}

void tlc_0832_handle(times,press_now,collect_data)
  uchar *times,*press_now,collect_data[18];
{  
   uchar i,j,collect_max=0;
   if(*times=0){        //18个点全部采集完?
      *times=18;
     for(i=17;i--;i>=0){  //对采集到的18个点排序(增序)
       for(j=0;j++;j<i){
        if(collect_data[i]<collect_data[j]){
           collect_max=collect_data[j];
           collect_data[j]=collect_data[i];
           collect_data[i]=collect_max;
         }
       }
     }

     for(i=1;i++;i<17){
       collect_data[i] >> 4;  //去掉两个极值,然后取平均值
     }
     collect_max=0;  
     for(i=1;i++;i<17){
       collect_max=collect_max+collect_data[i];
       *press_now=ch_data_press_now[collect_max]; //查表并返回当前压力值
     }
   }     
}

Build target 'Target 1'
compiling MAIN.C...
MAIN.C(57): error C267: 'tlc_0832_sCAN': requires ANSI-style prototype
Target not created

   为什么会有这个错误啊,在函数调用时C51和标准C有什么不同吗 ??
   望各位赐教!!!感激不尽!!!! 1: 我找到问题了 呵呵 自己太粗心了 2: 没法说你的程序太多语法错误,requires ANSI-style prototype是没有函数声明.
你的程序我重新编译了一下,我也是新手.
你看看能不能用.
#include <reg52.h>
typedef unsigned char uchar;

//&Oacute;&Iacute;&Iuml;&auml;&Ograve;&ordm;&Atilde;&aelig;&frac14;ì&sup2;&acirc;&Ecirc;&auml;&Egrave;&euml;&micro;&atilde;
sbit p_in_oil_a_1=P1^0;
sbit p_in_oil_a_2=P1^1;
sbit p_in_oil_a_3=P1^2;
sbit p_in_oil_b_1=P1^3;
sbit p_in_oil_b_2=P1^4;
sbit p_in_oil_b_3=P1^5;
//&Oacute;&Atilde;&Ograve;&ordm;&ETH;&Aring;&ordm;&Aring;&Ecirc;&auml;&Egrave;&euml;
sbit p_in_oil_flow=P1^6;
//&frac14;ü&Aring;&Igrave;&Ecirc;&auml;&Egrave;&euml;
sbit p_in_key1=P0^0;
sbit p_in_key2=P0^1;
sbit p_in_key3=P0^2;
sbit p_in_key4=P0^3;
//±¨&frac34;&macr;&Aacute;&iquest;&Ecirc;&auml;&sup3;&ouml;
sbit p_out_w_pre=P1^7;
sbit p_out_w_pwr=P3^5;
sbit p_out_w_burst=P3^6;
sbit p_out_w_oila=P0^6;
sbit p_out_w_oilb=P0^7;
//&iquest;&Oslash;&Ouml;&AElig;&ETH;&Aring;&ordm;&Aring;&Ecirc;&auml;&sup3;&ouml;
sbit p_out_oila=P0^4;
sbit p_out_oilb=P0^5;
sbit p_out_power_c=P2^6;
//AD×&ordf;&raquo;&raquo;
sbit p_ad_cs=P3^4;
sbit p_ad_di=P2^2;
sbit p_ad_do=P2^1;
sbit p_ad_clk=P2^0;
//24C01
sbit p_24cx_sda=P2^5;
sbit p_24cx_scl=P2^4;
sbit p_24cx_wr_c=P2^3;
//LED&Ccedil;&aring;0
sbit p_clr_led=P2^7;
sbit acc_7=ACC^7;
void tlc_0832_sCAN(uchar *times,uchar collect_data[18]);
void tlc_0832_handle(uchar *times,uchar *press_now,uchar collect_data[18]);
uchar code ch_data_press_now[256]={0};//&Icirc;&acute;&frac14;&AElig;&Euml;&atilde;&sup3;&ouml;&Agrave;&acute;

void main()
{   
  uchar ch_data_collect[18],ch_data_collect_times,ch_data_press_now;
  ch_data_collect_times=18;//&sup3;&otilde;&Ecirc;&frac14;&raquo;&macr;&sup2;&Eacute;&frac14;&macr;&acute;&Icirc;&Ecirc;&yacute;
  // &Ntilde;&sup1;&Aacute;&brvbar;&sup2;&Eacute;&frac14;&macr;
  tlc_0832_sCAN(&ch_data_collect_times,ch_data_collect);
  tlc_0832_handle(&ch_data_collect_times,&ch_data_press_now,ch_data_collect);
}

void tlc_0832_sCAN(uchar *times,uchar collect_data[18])
// uchar *times,collect_data[18];
{
  uchar i;
  times--;
  p_ad_clk=0;  //&Ecirc;&sup1;&Auml;&Uuml; ad
  p_ad_cs=0;  
  p_ad_di=1;  // &ETH;&acute;&iquest;&Oslash;&Ouml;&AElig;×&Ouml;&micro;&frac12;AD&pound;&not;H0&Icirc;&ordf;+&pound;&not;&micro;&yen;&Iacute;&acute;&micro;&Agrave;&sup2;&Eacute;&frac14;&macr;
  p_ad_clk=1;
  p_ad_clk=0;
  p_ad_di=1;
  p_ad_clk=1;
  p_ad_clk=0;
  p_ad_di=0;
  p_ad_clk=1;
  p_ad_clk=0;  
  p_ad_clk=1;

  for(i=0;i++;i<15)
  { // &sup2;&Eacute;&frac14;&macr;&Ograve;&raquo;&cedil;&ouml;&Ecirc;&yacute;&frac34;&Yacute;&micro;&atilde;
    p_ad_clk=0;
    acc_7=p_ad_do;    
    ACC>>=1;
    p_ad_clk=1;
  }
   p_ad_cs=1;
  collect_data[*times]=ACC;//±&pound;&acute;&aelig;&sup2;&Eacute;&frac14;&macr;&micro;&frac12;&micro;&Auml;&Ecirc;&yacute;&frac34;&Yacute;  
}

void tlc_0832_handle(uchar *times,uchar *press_now,uchar collect_data[18])
// uchar *times,*press_now,collect_data[18];
{  
   uchar i,j,collect_max=0;
   if(*times==0)
    {        //18&cedil;&ouml;&micro;&atilde;&Egrave;&laquo;&sup2;&iquest;&sup2;&Eacute;&frac14;&macr;&Iacute;ê&pound;&iquest;
      *times=18;
     for(i=17;i--;i>=0)
      {  //&para;&Ocirc;&sup2;&Eacute;&frac14;&macr;&micro;&frac12;&micro;&Auml;18&cedil;&ouml;&micro;&atilde;&Aring;&Aring;&ETH;ò(&Ocirc;&ouml;&ETH;ò)
       for(j=0;j++;j<i)
       {
        if(collect_data[i]<collect_data[j])
        {
           collect_max=collect_data[j];
           collect_data[j]=collect_data[i];
           collect_data[i]=collect_max;
         }
       }
     }

     for(i=1;i++;i<17)
      {
       collect_data[i] >>= 4;  //&Egrave;&yen;&micro;&ocirc;&Aacute;&frac12;&cedil;&ouml;&frac14;&laquo;&Ouml;&micro;,&Egrave;&raquo;&ordm;ó&Egrave;&iexcl;&AElig;&frac12;&frac34;ù&Ouml;&micro;
        }
        collect_max=0;  
     for(i=1;i++;i<17)
     {
       collect_max=collect_max+collect_data[i];
       *press_now=ch_data_press_now[collect_max]; //&sup2;é±í&sup2;&cent;·&micro;&raquo;&Oslash;&micro;±&Ccedil;°&Ntilde;&sup1;&Aacute;&brvbar;&Ouml;&micro;
     }
   }     
} 3: 把函数放在main()前 4: 谢谢了

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]