【求助】c语言编程报错,急!!附有程序及报错内容。(芯片是AT90S8535的,用ICC编的)
程序如下:#include "io8535.h"
#include "macros.h"
#include "iom164.h"
#define uchar unsigned char
void WD164(unsigned char *disdata)
{
uchar mid;
int i,j;
int x;
PORTA&=~0x02;
for(j=0;j<3;j++)
{
mid=disdata;
for(i=0;i<8;i++)
{
x=mid&0x80l;
if(x==0)
PORTA&=~0x01;
else
PORTA|=0x01;
PORTA|=0x02;
mid=mid<<1;
PORTA&=~0x02;
}
}
}
main()
uchar ddata;
{
ddata={1,2,3};
do{
WD164(ddata);
}While(1);
}
报错如下:
!W C:/icc/include/io8535.h(3): C:\shuma\s.c(1): #warning directive: "This header file may not be current. Please use io8535v.h instead"
!W C:/icc/include/iom164.h(4): C:\shuma\s.c(3): #warning directive: "This header file may not be current. Please use iom16??v.h instead"
C:\icc\bin\imakew -f s.mak
iccavr -c -IC:\icc\include\ -e -DAT90S8535-l -g -Wa-WC:\shuma\s.c
!W C:/icc/include/io8535.h(3): C:\shuma\s.c(1): #warning directive: "This header file may not be current. Please use io8535v.h instead"
!W C:/icc/include/iom164.h(4): C:\shuma\s.c(3): #warning directive: "This header file may not be current. Please use iom16??v.h instead"
!E C:\shuma\s.c(28): declared parameter `ddata' is missing
!E C:\shuma\s.c(30): type error: pointer expected
!E C:\shuma\s.c(30): illegal expression
!E C:\shuma\s.c(30): syntax error; found `1' expecting `;'
!W C:\shuma\s.c(30): expression with no effect elided
!W C:\shuma\s.c(30): expression with no effect elided
!W C:\shuma\s.c(30): expression with no effect elided
!E C:\shuma\s.c(30): syntax error; found `}' expecting `;'
!W C:\shuma\s.c(30): missing return value
!W C:\shuma\s.c(30): empty declaration
!E C:\shuma\s.c(31): unrecognized declaration
!E C:\shuma\s.c(31): unrecognized declaration
!E C:\shuma\s.c(32): extraneous old-style parameter list
!W C:\shuma\s.c(32): declaring a function without prototype may cause errors
!E C:\shuma\s.c(32): redeclaration of `WD164' previously declared at C:\shuma\s.c(5)
!E C:\shuma\s.c(33): unrecognized declaration
!E C:\shuma\s.c(33): syntax error; found `1' expecting `)'
!E C:\shuma\s.c(33): skipping `1'
!W C:\shuma\s.c(33): declaring a function without prototype may cause errors
!E C:\shuma\s.c(34): unrecognized declaration
C:\icc\bin\imakew.exe: Error code 1
C:\icc\bin\imakew.exe: 's.o' removed.
Done: there are error(s). Exit code: 1 #include "io8535v.h"
//#include "iom164.h"
#include "macros.h"
#define uchar unsigned char
void WD164(unsigned char *disdata)
{
uchar mid;
int i, j;
int x;
PORTA &= ~0x02;
for (j = 0; j < 3; j++)
{
mid = disdata;
for (i = 0; i < 8; i++)
{
x = mid & 0x80l;
if (x == 0)
PORTA &= ~0x01;
else
PORTA |= 0x01;
PORTA |= 0x02;
mid = mid << 1;
PORTA &= ~0x02;
}
}
}
int main()
//uchar ddata;
{
uchar ddata = {1, 2, 3};
do
{
WD164(ddata);
}
while (1);
return 0;
} 谢谢,你能不能好人做到底呢?在Proteus中怎样实现这个程序的仿真呢?我的就是不行,帮我改改行吗?图如下:
http://cache.amobbs.com/bbs_upload782111/files_16/ourdev_460313.jpg
(原文件名:22.jpg) 我只帮你改了语法问题,逻辑问题没有看。
你把proteus的工程文件发上来看看。
PS:
从程序逻辑上看了下,这句
x = mid & 0x80l;
应该为
x = mid & 0x80;
两点疑问:
1. 你的数码管打算用164来同时驱动 位和段?而且不用限流电阻? ,常见的用法是共阳端接VCC,段经限流电阻接164的Qn
2. 你没有进行数码管的段码编码,是不能直接显示出1,2,3的,要先定义一个数组,存放1,2,3三个数字的段码,然后在w164的程序中
对这个操作
void WD164(unsigned char *disdata)
{
flash uchar segs[]={/*你定义的段码在这里,google一下数据管段码生生器*/};
uchar mid;
uchar i, j;
PORTA &= ~0x02;
for (j = 0; j < 3; j++)
{
mid = seg];//转换
for (i = 0; i < 8; i++)
{
if (mid & 0x80)
PORTA |= 0x01;
else
PORTA &= ~0x01;
PORTA |= 0x02;
mid = mid << 1;
PORTA &= ~0x02;
}
}
}
int main()
{
uchar ddata = {1, 2, 3};
WD164(ddata);//静态显示,不是扫描,不用循环
while (1);
return 0;
} 点击此处下载 ourdev_460371.rar(文件大小:14K) (原文件名:Proteus文件.rar) 谢谢啦!! 你的proteus文件我打不开,我的版本低,不过道理我已经给你说了,自己试着改吧,其实只要按我在3楼说的做就行了。 哦,谢谢了 这个段码好了,可是这个C文件怎么用呢?先前的那个C文件怎么办呢?
http://cache.amobbs.com/bbs_upload782111/files_16/ourdev_460515.jpg
(原文件名:312.jpg) 晕,成生段码选择生成C格式,不是汇编格式。 算了,俺好人做到底,都帮你做好,已调试通过,以后“不急”的时候加强练习,不能永远吃现成的,这样永远学不好。
1.我重画的Proteus 图(6.9SP4),注意我没有在数码管的段到164的Q输出端加限流电阻(手懒),仿真无所谓,你做实际电路的时一定要加,500欧姆左右,否则长时间工作会烧数码管或164。
点击此处下载 ourdev_460563.rar(文件大小:12K) (原文件名:led164.rar)
2. LED 段码生成器软件
点击此处下载 ourdev_460564.rar(文件大小:315K) (原文件名:LED.rar)
3. 段码生成器使用截图
http://cache.amobbs.com/bbs_upload782111/files_16/ourdev_460562.JPG
(原文件名:LED.JPG)
4.源程序
#include "io8535v.h"
//#include "iom164v.h"
#include "macros.h"
#define uchar unsigned char
void WD164(unsigned char *disdata)
{
flash uchar segs[]={
0xC0,/*0*/
0xF9,/*1*/
0xA4,/*2*/
0xB0,/*3*/
0x99,/*4*/
0x92,/*5*/
0x82,/*6*/
0xF8,/*7*/
0x80,/*8*/
0x90,/*9*/};
uchar mid;
uchar i, j;
PORTA &= ~0x02;
for (j = 0; j < 3; j++)
{
mid = segs];//转换
for (i = 0; i < 8; i++)
{
if (mid & 0x80)
PORTA |= 0x01;
else
PORTA &= ~0x01;
PORTA |= 0x02;
mid = mid << 1;
PORTA &= ~0x02;
}
}
}
int main()
{
uchar ddata = {1, 2, 3};
PORTA=0;
DDRA = 0XFF;
WD164(ddata);//静态显示,不是扫描,不用循环
while (1);
return 0;
}
5.运行结果
http://cache.amobbs.com/bbs_upload782111/files_16/ourdev_460567.JPG
(原文件名:LED164.JPG) 怎么程序还是通不过呢?又报错:
C:\icc\bin\imakew -f led.mak
iccavr -c -IC:\icc\include\ -e -DAT90S8535-l -g -Wa-WD:\lcd\led.c
!E D:\lcd\led.c(18): "const" object 'segs' cannot have local storage class. Please make it a static or global object.
C:\icc\bin\imakew.exe: Error code 1
Done: there are error(s). Exit code: 1
http://cache.amobbs.com/bbs_upload782111/files_16/ourdev_460729.jpg
(原文件名:baocuo.jpg)
你帮了我这么多次,我就认你为师傅吧,以后我不懂就就来找你哟! 好像是什么储存空间不够用了,难道是icc让我们用常量或是全局变量吗? 你的ICC版本太低(我用的7.16A),不支持局部flash变量 ,把它改成全局的就行了。
flash uchar segs[]={
0xC0,/*0*/
0xF9,/*1*/
0xA4,/*2*/
0xB0,/*3*/
0x99,/*4*/
0x92,/*5*/
0x82,/*6*/
0xF8,/*7*/
0x80,/*8*/
0x90,/*9*/};
void WD164(unsigned char *disdata)
{
uchar mid;
uchar i, j;
PORTA &= ~0x02;
for (j = 0; j < 3; j++)
{
mid = segs];//转换
for (i = 0; i < 8; i++)
{
if (mid & 0x80)
PORTA |= 0x01;
else
PORTA &= ~0x01;
PORTA |= 0x02;
mid = mid << 1;
PORTA &= ~0x02;
}
}
} 谢谢了,我一定从现在开始打牢基础。 shark 发表于 2009-7-11 16:13 static/image/common/back.gif
#include "io8535v.h"
//#include "iom164.h"
#include "macros.h"
大神求助,方便留Q吗我等级低操作不方便,想请教AT90S8535
页:
[1]