刚学单片机,用C语言写了一个小程序,可是编绎老是出错,程序如下,请教各位大侠??!!1
#include<REG51.H>voiddelay(unsignedinta);voidonshow(void);voiddelay(unsignedinta){uns...
#include <REG51.H>void delay(unsigned int a);void onshow(void);
void delay(unsigned int a) { unsigned int b; for(b=100;a>0;b--) if(b==0) {a--; b=124; }; }
void onshow(void) { unsigned int bt; unsigned int ba=0,bb=0; if(P1&0X80!=P1) bt=70+P1-0x80; else if(P1&0x40!=P1) {delay(10); bt=60+P1-0x40;} else if(P1&0x20!=P1) {delay(10); bt=50+P1-0x20;} else if(P1&0x10!=P1) {delay(10); bt=40+P1-0x10;} else bt=0; ba=bt/10; bb=bt%10; P2=0x80; switch(ba) { case 0: P0=0x77; break; case 1: P0=0x24; break; case 2: P0=0x5E; break; case 3: P0=0x6E; break; case 4: P0=0x2D; break; case 5: P0=0xCB; break; case 6: P0=0x7B; break; case 7: P0=0x26; break; case 8: P0=0x7F; break; case 9: P0=0x6F; break; }; P2=0x40; switch(bb) { case 0: P0=0x77; break; case 1: P0=0x24; break; case 2: P0=0x5E; break; case 3: P0=0x6E; break; case 4: P0=0x2D; break; case 5: P0=0xCB; break; case 6: P0=0x7B; break; case 7: P0=0x26; break; case 8: P0=0x7F; break; case 9: P0=0x6F; break; }; }
void main(viod) { while(1) {delay(1000); onshow(); }; }
出错如下:
Build target 'Target 1'compiling 键盘C.c...linking...*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?_MAIN?键盘C*** WARNING L10: CANNOT DETERMINE ROOT SEGMENTProgram Size: data=12.0 xdata=0 code=483"键盘" - 0 Error(s), 2 Warning(s).
之后就不能继续了!!!! 展开
void delay(unsigned int a) { unsigned int b; for(b=100;a>0;b--) if(b==0) {a--; b=124; }; }
void onshow(void) { unsigned int bt; unsigned int ba=0,bb=0; if(P1&0X80!=P1) bt=70+P1-0x80; else if(P1&0x40!=P1) {delay(10); bt=60+P1-0x40;} else if(P1&0x20!=P1) {delay(10); bt=50+P1-0x20;} else if(P1&0x10!=P1) {delay(10); bt=40+P1-0x10;} else bt=0; ba=bt/10; bb=bt%10; P2=0x80; switch(ba) { case 0: P0=0x77; break; case 1: P0=0x24; break; case 2: P0=0x5E; break; case 3: P0=0x6E; break; case 4: P0=0x2D; break; case 5: P0=0xCB; break; case 6: P0=0x7B; break; case 7: P0=0x26; break; case 8: P0=0x7F; break; case 9: P0=0x6F; break; }; P2=0x40; switch(bb) { case 0: P0=0x77; break; case 1: P0=0x24; break; case 2: P0=0x5E; break; case 3: P0=0x6E; break; case 4: P0=0x2D; break; case 5: P0=0xCB; break; case 6: P0=0x7B; break; case 7: P0=0x26; break; case 8: P0=0x7F; break; case 9: P0=0x6F; break; }; }
void main(viod) { while(1) {delay(1000); onshow(); }; }
出错如下:
Build target 'Target 1'compiling 键盘C.c...linking...*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?_MAIN?键盘C*** WARNING L10: CANNOT DETERMINE ROOT SEGMENTProgram Size: data=12.0 xdata=0 code=483"键盘" - 0 Error(s), 2 Warning(s).
之后就不能继续了!!!! 展开
3个回答
展开全部
首先要说的是 你这样把代码粘上来 是没人愿意看的 从出错信息看 是有两个警告 可以编译生成hex文件吧 前一个警告是说一个函数没有 调用 后边是说第10行的 错误 学这个还是要多学习别人的 代码 这个真心不用创新
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-06-27
展开全部
void main(void) 你的括号里写的是viod拼写错误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
怎么这样粘代码呢?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询