//****************************************************************************
// @Module Analog / Digital Converter (ADC)
// @Filename ADC.C
// @Project ADC.dav
//----------------------------------------------------------------------------
// @Controller Infineon XC164CS-16F20
//
// @Compiler Keil
//
// @Codegenerator 2.8
//
// @Description This file contains functions that use the ADC module.
//
//----------------------------------------------------------------------------
// @Date 2007-5-25 13:23:04
//
//****************************************************************************
// USER CODE BEGIN (ADC_General,1)
// USER CODE END
//****************************************************************************
// @Project Includes
//****************************************************************************
#include "MAIN.H"
// USER CODE BEGIN (ADC_General,2)
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (ADC_General,3)
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (ADC_General,4)
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (ADC_General,5)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (ADC_General,6)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN (ADC_General,7)
unsigned int idata AD_DATA[16]; //AD转换结果存放数组
unsigned char ad_end = 0; //AD转换标志
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (ADC_General,8)
// USER CODE END
//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************
// USER CODE BEGIN (ADC_General,9)
// USER CODE END
//****************************************************************************
// @Function void ADC_vInit(void)
//
//----------------------------------------------------------------------------
// @Description This is the initialization function of the ADC function
// library. It is assumed that the SFRs used by this library
// are in its reset state.
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2007-5-25
//
//****************************************************************************
// USER CODE BEGIN (Init,1)
// USER CODE END
void ADC_vInit(void)
{
// USER CODE BEGIN (Init,2)
// USER CODE END
/// - compatibility mode is selected
/// - fixed channel continuous conversion mode is selected
/// - 10-bit resolution
/// - repeatedly converts channel 15
/// - ADC start bit is set
/// - wait for ADDAT read mode is disabled
/// - converter basic clock tbc is fcpu / 4
/// - sample time tsc is tbc * 8
/// - conversion time tc = 11.500 祍
ADC_CON = 0x001F; // load ADC control register
ADC_CON1 = 0x0000; // load ADC control register 1
/// -----------------------------------------------------------------------
/// Configuration of the used ADC Interrupts:
/// -----------------------------------------------------------------------
/// Conv service request node configuration:
/// - Conv interrupt priority level (ILVL) = 14
/// - Conv interrupt group level (GLVL) = 0
/// - Conv group priority extension (GPX) = 0
ADC_CIC = 0x0078;
/// Use PEC channel 0 for ADC Conv INT:
/// - decrement counter
/// - increment destination pointer
/// - transfer a word
/// - service End of PEC interrrupt by a EOP interrupt node is disabled
PECC0 = 0x0210; // load PECC0 control register
SRCP0 = _sof_(&ADC_DAT); //set source pointer
//// - Source-pointer for PECC channel 0 is set because it is selected for
//// user defined
DSTP0 = _sof_(0x0000); //set destination pointer
/// -----------------------------------------------------------------------
/// Configuration of the used ADC Port Pins:
/// -----------------------------------------------------------------------
/// - P5.15 is used for Analog Input Pin (AN15)
/// - digital input stage is disconnected from port line P5.15
P5DIDIS = 0x8000; // load Port 5 digital input disable register
ADC_CON_ADST = 1; // set start bit
// USER CODE BEGIN (Init,3)
DSTP0 = _sof_(&AD_DATA); //设置PEC0的目标地址指针
// USER CODE END
} // End of function ADC_vInit
//****************************************************************************
// @Function void ADC_vConfConv(ubyte ubMode, ubyte ubChannel)
//
//----------------------------------------------------------------------------
// @Description This function configures a new A/D conversion. In fixed
// channel single conversion mode (ADC_FIXED) the forwarded
// channel is converted once. In fixed channel continuous
// conversion mode (ADC_FIXED_CONTI) the forwarded channel is
// converted continuously. In auto scan single conversion mode
// (ADC_SCAN) a sequence beginning with the forwarded channel
// and ending with channel 0 is converted. In auto scan
// continuous conversion mode (ADC_SCAN_CONTI) the sequence is
// converted continuously. To start the conversion it is
// necessary to call ADC_vStartConv().
// Note:
// While a conversion is in progress, the mode and the channel
// may be changed. The new mode will be evaluated after the
// current conversion. The new channel will be evaluated after
// the current conversion (fixed channel modes) or after the
// current conversion sequence (auto scan modes). The
// following constants are available for ubMode:
// ADC_FIXED
// ADC_FIXED_CONTI
// ADC_SCAN
// ADC_SCAN_CONTI
//
// The following constants are available for ubChannel:
// ADC_ANA_0 .. ADC_ANA_7 and
// ADC_ANA_10 .. ADC_ANA_15 (see @Defines in header file)
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters ubMode:
// Conversion mode
// @Parameters ubChannel:
// Channel number
//
//------------------------------------------------------
ADC.zip_adc转换的代码_www.adcdaV,com
版权申诉
61 浏览量
2022-09-21
17:26:09
上传
评论
收藏 415KB ZIP 举报
钱亚锋
- 粉丝: 88
- 资源: 1万+
最新资源
- vscode-1.64.1.tar源码文件
- vscode-1.64.0.tar源码文件
- vscode-1.52.0.tar源码文件
- Music-Player +PlayerActivity+ rockplayer+ SeeJoPlayer 播放器JAVA源码
- vscode-1.46.0.tar源码文件
- 最近很火植物大战僵尸杂交版2.08苹果+安卓+PC+防闪退工具V2+修改工具+高清工具+通关存档整合包更新
- 超级好用的截图工具PixPin,可录制Gif图
- Screenshot_2024-05-21-17-06-42-64_2332cb9b27b851b548ba47a91682926c.jpg
- 毕业设计参考 - 基于树莓派、OpenCV及Python的人脸识别
- node-v18.20.2-linux-arm64
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈