#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar temp, t0;
void init();
void main()
{
uint();
while(1)
{
}
}
void uint()
{
temp=0xfe;
P1=temp;
TMOD=0x11; //定时器 0,1
TH0=(65536-50000)/256; //装初值
TL0=(65536-50000)%256;
TH1=(65536-50000)/256; //装初值
TL1=(65536-50000)%256;
EA=1; // 开总中断
ET0=1;
ET1=1;
TR1=1; // 开定时器中断
TR0=1; //启动定时器
}
void time0() interrupt 1 //中断服务程序 1为定时器0函数序号
{
TH0=(65536-50000)/256; //设初值 从新开始计数
TL0=(65536-50000)%256;
t0++;
if(t0=10)
{
t0=0;
temp=_crol_(temp,1);
P1=temp;
}
}
compiling timezhongduan.c...
TIMEZHONGDUAN.C(9): error C141: syntax error near ')'
TIMEZHONGDUAN.C(17): error C141: syntax error near 'unsigned'
TIMEZHONGDUAN.C(17): error C141: syntax error near ')'
TIMEZHONGDUAN.C(19): error C231: 'temp': redefinition
TIMEZHONGDUAN.C(20): error C231: 'P1': redefinition
TIMEZHONGDUAN.C(20): error C247: non-address/-constant initializer
TIMEZHONGDUAN.C(20): error C231: 'P1': redefinition
TIMEZHONGDUAN.C(21): error C231: 'TMOD': redefinition
TIMEZHONGDUAN.C(21): error C231: 'TMOD': redefinition
TIMEZHONGDUAN.C(22): error C231: 'TH0': redefinition
TIMEZHONGDUAN.C(22): error C231: 'TH0': redefinition
TIMEZHONGDUAN.C(23): error C231: 'TL0': redefinition
TIMEZHONGDUAN.C(23): error C231: 'TL0': redefinition
TIMEZHONGDUAN.C(24): error C231: 'TH1': redefinition
TIMEZHONGDUAN.C(24): error C231: 'TH1': redefinition
TIMEZHONGDUAN.C(25): error C231: 'TL1': redefinition
TIMEZHONGDUAN.C(25): error C231: 'TL1': redefinition
TIMEZHONGDUAN.C(26): error C231: 'EA': redefinition
TIMEZHONGDUAN.C(26): error C231: 'EA': redefinition
TIMEZHONGDUAN.C(27): error C231: 'ET0': redefinition
TIMEZHONGDUAN.C(27): error C231: 'ET0': redefinition
TIMEZHONGDUAN.C(28): error C231: 'ET1': redefinition
TIMEZHONGDUAN.C(28): error C231: 'ET1': redefinition
TIMEZHONGDUAN.C(29): error C231: 'TR1': redefinition
TIMEZHONGDUAN.C(29): error C231: 'TR1': redefinition
TIMEZHONGDUAN.C(30): error C231: 'TR0': redefinition
TIMEZHONGDUAN.C(30): error C231: 'TR0': redefinition
TIMEZHONGDUAN.C(32): error C141: syntax error near '}'
timezhongduan.c - 28 Error(s), 0 Warning(s).
------解决方案--------------------
[Quote=引用:]
- C/C++ code
#include <reg52.h>#include <intrins.h>#define uchar unsigned char#define uint unsigned intuchar temp, t0;void init();void main(){ uint();while(1){}}void uint(){temp=0xfe;P1=temp;TMOD=0x11; //定时器 0,1TH0=(65536-50000)/256; //装初值TL0=(65536-50000)%256;TH1=(65536-50000)/256; //装初值TL1=(65536-50000)%256; EA=1; // 开总中断ET0=1;ET1=1;TR1=1; // 开定时器中断TR0=1; //启动定时器}void time0() interrupt 1 //中断服务程序 1为定时器0函数序号{TH0=(65536-50000)/256; //设初值 从新开始计数TL0=(65536-50000)%256;t0++;[color=#FF0000]if(t0=10)[/color]{t0=0;temp=_crol_(temp,1);P1=temp;}}