找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 10841|回复: 17
打印 上一主题 下一主题
收起左侧

新手,不知道错在哪里?error C202: 'IT0': undefined identifier

  [复制链接]
跳转到指定楼层
楼主
#ifndef __STC8F_H_
#define __STC8F_H_
#include <stdio.h>           


void delayms(unsigned char ms)        

{                                                
        unsigned char i;
        while(ms--)
        {
                for(i = 0; i < 120; i++);
        }
}


main()
{
        int P3;
        unsigned char LED;
        LED = 0xfe;          //0xfe = 1111 1110
         while(1)
        {
             P3 = LED;
                 delayms(250);
                 LED = LED << 1;  
                  if(LED == 0x00 )         {LED = 0xfe;  } // 0xfe = 1111 1110
                    
                 
        }
}
void Int0Init()
{
        IT0=1;
        EX0=1;
        EA=1;
}
void main()
{
                Int0Init();
                while(1);
}
void Int0() interrupt 0
        {
                 delayms(3600);
                if(IT0=0)
                {
                        LED  = 0xff;
                        
                }
               
        }



Rebuild target 'Target 1'
assembling STARTUP.A51...
compiling ledshuo.c...
ledshuo.c(34): error C202: 'IT0': undefined identifier
ledshuo.c(35): error C202: 'EX0': undefined identifier
ledshuo.c(36): error C202: 'EA': undefined identifier
ledshuo.c(39): error C231: 'main': redefinition
ledshuo.c(42): error C231: 'main': redefinition
ledshuo.c(46): error C202: 'IT0': undefined identifier
ledshuo.c(48): error C202: 'LED': undefined identifier
ledshuo.c(55): warning C316: unterminated conditionals
Target not created.
Build Time Elapsed:  00:00:02


请高手们指点一二,谢谢
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:735180 发表于 2020-4-23 09:02 | 只看该作者
undefined identifier“未定义的标识符”,也就是编译器找不到 TMOD、TH1... 这些符号的定义。
redefinition是重复定义
回复

使用道具 举报

板凳
ID:735526 发表于 2020-4-23 09:33 | 只看该作者
有可能你缺少定义TMOD的说明,或是写了了.inc或.h文件没有include进来,你仔细检查一下,地址定义文件
回复

使用道具 举报

地板
ID:191511 发表于 2020-4-23 10:09 | 只看该作者
没有包含相应的单片机头文件,导致里边单片机的寄存器定义编译的时候出现检测到未定义。
回复

使用道具 举报

5#
ID:584814 发表于 2020-4-23 10:11 | 只看该作者
这么短的程序里居然有2个main(),抄也得长点心罢
回复

使用道具 举报

6#
ID:519352 发表于 2020-4-23 10:51 | 只看该作者
应该是头文件没选好,要加载相应的头文件
回复

使用道具 举报

7#
ID:722595 发表于 2020-4-23 10:58 | 只看该作者
纯新手的话,建议从流水灯开始,第一步不要跨太大
回复

使用道具 举报

8#
ID:601478 发表于 2020-4-23 11:50 | 只看该作者
两个main,感觉是打错了吧
回复

使用道具 举报

9#
ID:735989 发表于 2020-4-23 12:38 | 只看该作者
缺少定义TMOD的说明
回复

使用道具 举报

10#
ID:592807 发表于 2020-4-23 13:03 | 只看该作者
你还是从头开始吧

]}OGZ5E$N%TBBTKVKI@]SNN.png (36.97 KB, 下载次数: 63)

]}OGZ5E$N%TBBTKVKI@]SNN.png
回复

使用道具 举报

11#
ID:282850 发表于 2020-4-23 14:25 | 只看该作者
ledshuo.c(34): error C202: 'IT0': undefined identifier
ledshuo.c(35): error C202: 'EX0': undefined identifier
ledshuo.c(36): error C202: 'EA': undefined identifier
几个标识未定义,加#include “REG51.h”,就有定义了

ledshuo.c(39): error C231: 'main': redefinition
ledshuo.c(42): error C231: 'main': redefinition
两main重复定义。
回复

使用道具 举报

12#
ID:706724 发表于 2020-5-17 14:29 | 只看该作者
f556 发表于 2020-4-23 14:25
ledshuo.c(34): error C202: 'IT0': undefined identifier
ledshuo.c(35): error C202: 'EX0': undefined  ...

谢谢大神的指点,因为我用的单片机是STC15F104W 它的使用说明里,说不用另外包含REG51.H。所以没有写上去。
现在加上去了,是不是中断的程序都要51的头文件?
回复

使用道具 举报

13#
ID:706724 发表于 2020-5-17 14:31 | 只看该作者
黄youhui 发表于 2020-4-23 13:03
你还是从头开始吧

谢谢,指点。
回复

使用道具 举报

14#
ID:706724 发表于 2020-5-17 14:31 | 只看该作者
贤鱼 发表于 2020-4-23 09:02
undefined identifier“未定义的标识符”,也就是编译器找不到 TMOD、TH1... 这些符号的定义。
redefiniti ...

谢谢,高手指点
回复

使用道具 举报

15#
ID:706724 发表于 2020-5-17 14:32 | 只看该作者
21is 发表于 2020-4-23 09:33
有可能你缺少定义TMOD的说明,或是写了了.inc或.h文件没有include进来,你仔细检查一下,地址定义文件[em01 ...

是的,少了51的头文件。谢谢指点
回复

使用道具 举报

16#
ID:706724 发表于 2020-5-17 14:33 | 只看该作者
man1234567 发表于 2020-4-23 10:11
这么短的程序里居然有2个main(),抄也得长点心罢

谢谢,指点,真的是菜鸟来的
回复

使用道具 举报

17#
ID:706724 发表于 2020-5-17 14:34 | 只看该作者
PDDDF 发表于 2020-4-23 11:50
两个main,感觉是打错了吧

是的,小白来的。
回复

使用道具 举报

18#
ID:755472 发表于 2020-5-20 09:58 | 只看该作者
头文件有问题
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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