当前位置: 代码迷 >> C语言 >> 请大家帮我看看我编的程序,谢谢了哦
  详细解决方案

请大家帮我看看我编的程序,谢谢了哦

热度:177   发布时间:2005-10-02 13:00:00.0
请大家帮我看看我编的程序,谢谢了哦

我没学过c,前几天看了几天c,现在照葫芦画瓢编了个c 小程序,结果编译出错,提示如下: D:\icc\bin\imakew -f led.mak iccavr -c -ID:\icc\include\ -e -DATMega8 -l -g -Mavr_enhanced_small -Wa-W D:\我的文档\led.c !W D:\我的文档\led.c(48):[warning] calling function without prototype may cause errors !W D:\我的文档\led.c(57):[warning] declaration of `display' does not match previous declaration at D:\我的文档\led.c(48) !E D:\我的文档\led.c(88): lvalue required !E D:\我的文档\led.c(102): lvalue required !W D:\我的文档\led.c(108):[warning] expression with no effect elided D:\icc\bin\imakew.exe: Error code 1 Done: there are error(s). Exit code: 1

源程序如下,请高手帮我解决一下这两个问题 “!W D:\我的文档\led.c(48):[warning] calling function without prototype may cause errors !W D:\我的文档\led.c(57):[warning] declaration of `display' does not match previous declaration at D:\我的文档\led.c(48)”

//ICC-AVR application builder : 2005-3-1 22:02:29 // Target : M8 // Crystal: 8.0000Mhz

#include <iom8v.h> #include <macros.h> unsigned int dis[4]; // 显示缓冲区 unsigned int adc; // 保存AD转换的值 unsigned int i; unsigned int time; // AD转换的时间间隔 //To计数器初始化 void timer0_init(void) { TCCR0 = 0x00; //stop TCNT0 = 0x64; //set count TCCR0 = 0x04; //start timer } //AD初始化 void adc_init(void) { ADCSR = 0x00; //disable adc ADMUX = 0x40; //select adc input 0 ACSR = 0x80; //关闭模拟比较器 ADCSR = 0x86; } //中断定义,10为中断序号,T0中断 #pragma interrupt_handler timer0_ovf_isr:10 void timer0_ovf_isr(void) { TCNT0 = 0x64; //重新装入计数值 //ad 200ms转换一次 if(++time == 40) //time 加1后判断 { time = 0; //time 归零 ADCSR = 0B11000110; // 开始转换(单次转换)64分频 while(!(ADCSR & 0x10)); // 等待转换完成 adc = ADCL; adc |= (unsigned int)(ADCH << 8); dis[0] = adc%10; //个 adc = adc / 10; dis[1] = adc%10; //十位 adc = adc / 10; dis[2] = adc%10; //百位 adc = adc / 10; dis[3] = adc%10; //千位 } // end ad // 要使4位数码管全部点亮要采用动态刷新的方式。首先第一个数码管点亮5豪秒,其他的数码管是灭的; // 然后再点亮第二个数码管,时间为5豪秒,依次循环下去。这样刷新一便要用20豪秒,每秒钟可以刷新50次,就可以骗过人的眼睛了 switch(i) { case 0: display(dis[0],i) ; break; case 1: display(dis[1],i) ; break; case 2: display(dis[2],i) ; break; case 3: display(dis[3],i) ; break; } if(++i > 3) i = 0; } //显示子程序 void display(unsigned int disch,unsigned int y) {

unsigned int j; unsigned int ch; unsigned int dischar;

switch(y) { case 0: ch=0x10 ; break; case 1: ch=0x30 ; break; case 2: ch=0x70 ; break; case 3: ch=0xf0 ; break; } switch(disch) { case 0: dischar = 0x3f ; break; case 1: dischar = 0x06 ; break; case 2: dischar = 0x5b ; break; case 3: dischar = 0x4f ; break; case 4: dischar = 0x66 ; break; case 5: dischar = 0x6d ; break; case 6: dischar = 0x7d ; break; case 7: dischar = 0x07 ; break; case 8: dischar = 0x7f ; break; case 9: dischar = 0x6f ; break; }

//开始送74164数据 ch = ch<<4; for (j=0;j<=3;j++) { if ((ch&0x80)=0x80) PORTD |=0x80; else PORTD &=0x7f;

// if ((ch&0x80)=0x80 // SBI 18 ,7; //PD7 置位1 // else CBI 18,7 //PD7 置零

PORTD &=0xbf; //PD6归零 PORTD |=0x40; //PD6置1 ch = ch<<1; } for (j=0;j<=7;j++) { if ((dischar&0x80)=0x80) PORTD |=0x80; else PORTD &=0x7f;

PORTD &=0xbf; //PD6归零 PORTD |=0x40; //PD6置1 dischar<<1; } } //主程序 void main(void) { CLI(); i=0; DDRB = 0x01; DDRD= 0xc0; //串口端 DDRC = 0x00; timer0_init(); adc_init(); MCUCR = 0x00; GICR = 0x00; TIMSK = 0x01; SEI(); while(1); }


----------------解决方案--------------------------------------------------------
  相关解决方案