keil 中用c 语言写的代码 error C231: 'TMOD': redefinition

ifree6   2010-4-23 20:57 楼主
#include
#include
#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).

回复评论 (4)

TIMEZHONGDUAN.C(30): error C231: 'TR0': redefinition  这个问题已经解决
  字母写错 把 unit 函数 改为 init 即可  
出现了一个提示
TIMEZHONGDUAN.C(40): warning C276: constant in condition expression
请问这是怎么回事?? 谢谢各位友友
点赞  2010-4-23 21:00
引用: 引用楼主 overif 的回复:
  1. #include
  2. #include
  3. #define uchar unsigned char
  4. #define uint unsigned int
  5. uchar temp, t0;
  6. void init();
  7. void main()
  8. {
  9.   uint();
  10. while(1)
  11. {

  12. }
  13. }


  14. void uint()
  15. {
  16. temp=0xfe;
  17. P1=temp;
  18. TMOD=0x11; //定时器 0,1
  19. TH0=(65536-50000)/256; //装初值
  20. TL0=(65536-50000)%256;
  21. TH1=(65536-50000)/256; //装初值
  22. TL1=(65536-50000)%256;   
  23. EA=1; // 开总中断
  24. ET0=1;
  25. ET1=1;
  26. TR1=1; // 开定时器中断
  27. TR0=1; //启动定时器

  28. }


  29. void time0() interrupt 1 //中断服务程序 1为定时器0函数序号
  30. {
  31. TH0=(65536-50000)/256; //设初值 从新开始计数
  32. TL0=(65536-50000)%256;
  33. t0++;
  34. [color=#FF0000]if(t0=10)[/color]
  35. {
  36. t0=0;
  37. temp=_crol_(temp,1);
  38. P1=temp;
  39. }
  40. }

明显是==,而不是=
点赞  2010-4-23 21:20
额..
为什么我登陆了
却看不到楼上的回帖捏..
点赞  2010-6-30 16:33
compiling Main.C...
MAIN.C(96): error C141: syntax error near 'void'
MAIN.C(109): error C231: 'spi_open': redefinition
MAIN.C(111): error C231: 'spi_open': redefinition
Main.C - 3 Error(s), 0 Warning(s).
点赞  2011-8-21 13:06
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复