pot.c
来自「ADI公司的ARM7的功能模块的源码」· C语言 代码 · 共 45 行
C
45 行
/*********************************************************************
Author : ADI - Apps www.analog.com/MicroConverter
Date : Sept. 2005
File : pot.c
Hardware : Applicable to ADuC7020/ADuC7024/ADuC7026
Currently targetting ADuC7026.
Description : Performs repeated single ADC conversions on ADC0
Adjusts output of DAC1 to vary with potentiometer
S1.3 adn S1.8 must be in ON position on board for
this demonstration
*********************************************************************/
#include<aduc7026.h>
void ADCpoweron(int);
int main(void){
// ADC and DAC configuration
ADCpoweron(20000); // power on ADC
ADCCP = 0x00; // conversion on ADC0
DAC1CON = 0x13; // AGND-AVDD range
REFCON = 0x01; // internal 2.5V reference
while (1) {
ADCCON = 0x6A3; // software conv., single-ended, conv. enabled
while (!ADCSTA){} // wait for end of conversion
DAC1DAT = ADCDAT; // result format is identical for DAC and ADC
}
}
void ADCpoweron(int time){
ADCCON = 0x620; // power-on the ADC
while (time >=0) // wait for ADC to be fully powered on
time--;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?