单片机C程序问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了单片机C程序问题相关的知识,希望对你有一定的参考价值。
#include<reg52.h>
#define uchar unsigned char
#define uint unsignes int
sbit led=P1^0;
sbit key=P3^0;
unsigned char code smg_du[]=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90
void delay_50us(uint t)
uchar j;
for(;t>0;t--)
for(j=19;j>0;j--);
void main()
uchar num;
while(1)
if(key==0)
delay_50us(200);
if(key==0)
num++;
led=0;
if(num==10) num=0;
while(!key);
delay_50us(200);
while(!key);
else
led=1;
P0=smg_du(num);
错哪了?偶是初学的,请哪位高手帮忙下,,,
加上分号后keill3提示有以下错误:
DJ.C(10):error c141:syntax error near 'int',expexted ')'
DJ.C(13):error c202:'t';underfined identifier
DJ.C(39):error c211;call not to afunction
DJ.C(39):error c208:'function:too many actual parameters
第10句:void delay(uint t)
第13句:for(t;t>0;t--)
第39句:P0=smg_du(num);
#define uchar unsigned char
#define uint unsigned int
sbit led=P1^0;
sbit key=P3^0;
unsigned char code smg_du[]=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90;
void delay_50us(uint t)
uchar j;
for(;t>0;t--)
for(j=19;j>0;j--);
void main()
uchar num;
while(1)
if(key==0)
delay_50us(200);
if(key==0)
num++;
led=0;
if(num==10) num=0;
while(!key);
delay_50us(200);
while(!key);
else
led=1;
P0=smg_du[num];
问题1:#define uint unsignes int笔误吧,应该是:#define uint unsigned int
问题2:少分号,上面的已经说了;
问题3:P0=smg_du(num)应该是:P0=smg_du[num]; 参考技术A unsigned char code smg_du[]=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90;
少了个分号,其它好像无错哇~~~ 参考技术B #define uint unsignes int
拼写错误 是 unsigned
unsigned char code smg_du[]=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90 少个分号
以上是关于单片机C程序问题的主要内容,如果未能解决你的问题,请参考以下文章