永发信息网

单片机 KEIL C程序

答案:2  悬赏:60  手机版
解决时间 2021-03-05 07:59
  • 提问者网友:你独家记忆
  • 2021-03-04 14:43
#include
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
uint a=0;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar code tablewe[]={
0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
void display(uint z)
void main()
{
while(1)
{
for(;a!=0;a++)
{wela=1;
P1=tablewe[a];
wela=0;
delay(1);
dula=1;
P1=table[7-a];
dula=0;
delay(1);
if(a==6)
{a=0;}
}
}
}
void delay(uint z)
{uint x=1000,y;
for(;x>0;x--)
for(y=z;y>0;y--);
}
654321.C(16): error C132: 'main': not in formal parameter list
654321.C(16): error C141: syntax error near '{'
654321.C(19): error C132: 'a': not in formal parameter list
654321.C(19): error C136: 'a': 'void' on variable
654321.C(19): error C132: 'a': not in formal parameter list
654321.C(20): error C136: 'wela': 'void' on variable
654321.C(20): error C244: 'wela': can't initialize, bad type or class
654321.C(20): error C136: 'wela': 'void' on variable
654321.C(20): error C132: 'wela': not in formal parameter list
654321.C(21): error C244: 'P1': can't initialize, bad type or class
654321.C(21): error C132: 'P1': not in formal parameter list
654321.C(22): error C244: 'wela': can't initialize, bad type or class
654321.C(22): error C132: 'wela': not in formal parameter list
654321.C(23): error C141: syntax error near '1'
654321.C(23): error C132: 'delay': not in formal parameter list
654321.C(24): error C244: 'dula': can't initialize, bad type or class
654321.C(24): error C132: 'dula': not in formal parameter list
654321.C(25): error C244: 'P1': can't initialize, bad type or class
654321.C(25): error C132: 'P1': not in formal parameter list
654321.C(26): error C244: 'dula': can't initialize, bad type or class
654321.C(26): error C132: 'dula': not in formal parameter list
654321.C(27): error C141: syntax error near '1'
654321.C(27): error C132: 'delay': not in formal parameter list
654321.C(28): error C141: syntax error near 'if'
654321.C(28): error C141: syntax error near '==', expected ')'
654321.C(29): error C279: 'a': multiple initialization
654321.C(29): error C231: 'a': redefinition
654321.C(29): error C141: syntax error near '}'
Target not created请问哪错了啊
最佳答案
  • 五星知识达人网友:逐風
  • 2021-03-04 15:24
0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
void display(uint z)
void main()

void display(uint z);少了个冒号
全部回答
  • 1楼网友:往事埋风中
  • 2021-03-04 16:12
程序本身是没有问题的,我已经把你的程序在我使用的keil编译,0警告,0错误 随便要指出的就是,在p1_1口上的led点亮的时间太短了,你可以适当延长一下那个时间,以下是我稍微修改后的程序,供你参考: #include //预处理命令 void main(void) //主函数名 { unsigned int a; //定义变量a为unsigned int类型 unsigned int b; //我修改为 int 类型了 do { //do while组成循环 for (a=0; a<65535; a++) p1_0 = 0; //65535次设p1.0口为低电平,点亮led p1_0 = 1; //设p1.0口为高电平,熄灭led for (a=0; a<30000; a++); //空循环 for (b=0; b<10000; b++) p1_1 = 0; //10000次设p1.1口为低电平,点亮led p1_1 = 1; //设p1.1口为高电平,熄灭led for (a=0; a<30000; a++); //空循环 } while(1); }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯