📄 adc.c
字号:
/******************************************************************************/
/* This file is part of the uVision/ARM development tools */
/* Copyright KEIL ELEKTRONIK GmbH 2002-2005 */
/******************************************************************************/
/* */
/* ADC.c: ADC Example */
/* */
/******************************************************************************/
#include <ADuC7026.H> // ADuC7026 definitions
#define CLOCK 22544384 // CPU configured for 22.544384 MHz clock
#define T0_FREQ 5000 // Timer 0 Reload Frequency
#define T0_LD ((unsigned short)(CLOCK/16 / T0_FREQ))
int ADC_samples[16];
extern volatile int T0_Tick; // Timer 0 Current Tick Value
int T0_Last; // Timer 0 Last Tick Value
int main (void) {
int i;
ADCCON = 0x23; // Configure DAC1 (LED) Range 0..VDD
ADCCN = 0x10; // Set the negative ADC input to "reference" (ground)
while (1) { // Loop forever
for(i = 1; i < 16; i++)
{
ADCCP = i; // Set the MUX to read the next input
ADCCON |= 0x80; // Start the conversion
while(ADCSTA); // Wait until the converstion finishes
ADC_samples[i] = (ADCDAT >> 0x10)&0x0FFF;
ADCCP = 0; // Sample ADC0 every time
ADCCON |= 0x80; // Start the conversion
while(ADCSTA); // Wait until the converstion finishes
ADC_samples[0] = (ADCDAT >> 0x10)&0x0FFF;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -