找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

求救,数码管、定时器问题!

[复制链接]
admin 发表于 2012-9-2 08:26:37 | 显示全部楼层 |阅读模式

本文包含原理图、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里面给了吗,怎么还有问题呢?
望大虾指教,感谢~~
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-24 09:53 , Processed in 0.053241 second(s), 10 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表