本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
这是我的程序,想用定时器实现数码管三位计数:
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code tabledu[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar code tablewe[]={
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07};
uchar count,discount;
void display(uchar,uchar,uchar);
void delay(uchar)
void main()
{
EA=1;
ET1=1;
TMOD=0X10;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR1=1;
while(1)
{
if(count==20)
{
count=0;
discount++;
}
display(discount/100,discount/100%10,discount%10);
}
}
void time() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
count++;
}
void display(uchar bai,uchar shi,uchar ge)
{
P2=tabledu[bai];
P1=tablewe[2];
delay(10);
P2=tabledu[shi];
P1=tablewe[1];
delay(10);
P2=tabledu[ge];
P1=tablewe[0];
delay(10);
}
void delay(uchar a)
{
uchar b,c;
for(b=a;b>0;b--)
for(c=100;c>0;c--);
}
但是出现如下报错:
Build target 'Target 1'
compiling test.c...
TEST.C(14): error C158: '_delay': function contains unnamed parameter
TEST.C(15): error C132: 'main': not in formal parameter list
TEST.C(15): error C141: syntax error near '{'
TEST.C(16): error C136: 'EA': 'void' on variable
TEST.C(16): error C244: 'EA': can't initialize, bad type or class
TEST.C(16): error C136: 'EA': 'void' on variable
TEST.C(16): error C132: 'EA': not in formal parameter list
TEST.C(17): error C244: 'ET1': can't initialize, bad type or class
TEST.C(17): error C132: 'ET1': not in formal parameter list
TEST.C(18): error C244: 'TMOD': can't initialize, bad type or class
TEST.C(18): error C132: 'TMOD': not in formal parameter list
TEST.C(19): error C244: 'TH1': can't initialize, bad type or class
TEST.C(19): error C132: 'TH1': not in formal parameter list
TEST.C(20): error C244: 'TL1': can't initialize, bad type or class
TEST.C(20): error C132: 'TL1': not in formal parameter list
TEST.C(21): error C244: 'TR1': can't initialize, bad type or class
TEST.C(21): error C132: 'TR1': not in formal parameter list
TEST.C(22): error C141: syntax error near 'while'
TEST.C(22): error C141: syntax error near '1'
TEST.C(24): error C141: syntax error near '==', expected ')'
TEST.C(26): error C231: 'count': redefinition
TEST.C(27): error C129: missing ';' before '++'
Target not created
这是什么原因呢,像EA、ET1、TMOD、TH1、TL1、TR1不是在reg52.h里面给了吗,怎么还有问题呢?
望大虾指教,感谢~~ |