找回密码
 立即注册

QQ登录

只需一步,快速开始

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

error C202: 'ADC_RES': undefined identifier这个怎么改啊?

[复制链接]
跳转到指定楼层
楼主
ID:1065394 发表于 2023-3-6 13:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include "lcd1602.h"
#include "intrins.h"
sbit Init0=P3^2;//外部中断0引脚        
sbit Init1=P3^3;//外部中断1引脚
unsigned int Num=0;
unsigned int i=0;
unsigned int SouthRate=0;  //南 频率
unsigned int NorthRate=0;  //北 频率
unsigned int WestRate=0;   //西 频率
unsigned int EastRate=0;   //东 频率
unsigned int SouthStrength=0;  //南 强度
unsigned int NorthStrength=0;  //北 强度
unsigned int WestStrength=0;   //西 强度
unsigned int EastStrength=0;   //东 强度
/********************************************************************
* 名称 : unsigned int Read_ADC(unsigned char a)
* 功能 : 获取指定通道的AD值 10位ADC
* 输入 : a 通道
* 输出 : 当前通道的AD值
***********************************************************************/
unsigned int Read_ADC(unsigned char a)
{
            P1ASF = 0xff;                //P1做ADC               
            ADC_RES = 0;                //清除结果寄存器
            ADC_RESL = 0;
                        ADC_CONTR=0XE8|a;
                        _nop_();
                        _nop_();
                        _nop_();
                        _nop_();
      while(!(ADC_CONTR&0x10));
                        ADC_CONTR&=~0X10;
                        return (unsigned int)ADC_RES<<2|ADC_RESL;  
}


1.c(23): error C202: 'P1ASF': undefined identifier
1.c(24): error C202: 'ADC_RES': undefined identifier
1.c(25): error C202: 'ADC_RESL': undefined identifier
1.c(26): error C202: 'ADC_CONTR': undefined identifier
1.c(31): error C202: 'ADC_CONTR': undefined identifier
1.c(32): error C202: 'ADC_CONTR': undefined identifier
1.c(33): error C202: 'ADC_RES': undefined identifier

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:1034262 发表于 2023-3-6 15:43 | 只看该作者
你的MCU头文件呢?
回复

使用道具 举报

板凳
ID:883242 发表于 2023-3-6 23:32 | 只看该作者
你需要先找到ADC_RES这个变量在哪里定义的。
回复

使用道具 举报

地板
ID:807182 发表于 2023-3-9 14:47 | 只看该作者
未定义呗,全局搜一下,有的话把头文件包括进来,没有的话就自己定义吧
回复

使用道具 举报

5#
ID:378108 发表于 2023-3-12 00:19 | 只看该作者
把 单片机 的头文件包括进来,比如:
#include <STC8H.H>,看你用的是什么单片机,或者你头铁,自己定义一遍也行.
回复

使用道具 举报

6#
ID:939553 发表于 2023-3-12 10:01 | 只看该作者
未包含该定义的头文件,如#include “reg51.h”
回复

使用道具 举报

7#
ID:206581 发表于 2023-3-12 11:05 | 只看该作者
#include<reg52.h>
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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