📄 adc.c
字号:
/**********************************************
ADC.C file
The ADuc841's ADC Operation
Creat by Computer-lov Date: 2005.8.30
Last edit date:2005.8.30
Copyright(C) 2005-2015 Computer-lov
All rights reserved
************************************************/
#include "ADC.H"
//*************************** select ADC channel *************
void set_channel(unsigned char ch)
{
ch&=0x0F;
ADCCON2=(ADCCON2&0xF0)|ch;
}
//*************************************************************
//*************************** ACD initialization *************
void ADC_init(void)
{
ADCCON1=0x0C;
ON_ADC();
// OFF_ADC();
// SET_EX_REF();
SET_IN_REF();
ADCCON2=0x07;
ADCCON3=0x14; //Number of Averages = 63
offset_calibration();
gain_calibration();
}
//*************************************************************
//**************************** Wait for end of ADC conversion **
void wait_end_of_ADC(void)
{
while(ADCCON3&0x80);
}
//***************************************************************
//*************************** Offset calibration. **************
void offset_calibration(void)
{
ADCCON3&=~0x02;
ADCCON3|=0x01;
}
//***************************************************************
//*************************** Gain calibration. ****************
void gain_calibration(void)
{
ADCCON3|=0x02;
ADCCON3|=0x01;
}
//***************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -