📄 adc_test.c
字号:
/*********************************************************************************************
* File: adc_test.c
* Author: embest
* Desc: S3C2410 ADC Test
* History:
* wang Fub 16th 2006
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/* include files */
/*------------------------------------------------------------------------------------------*/
#include "2410lib.h"
/*------------------------------------------------------------------------------------------*/
/* constants define */
/*------------------------------------------------------------------------------------------*/
#define REQCNT 100
#define ADC_FREQ 2500000
#define LOOP 10000
/*------------------------------------------------------------------------------------------*/
/* variables declare */
/*------------------------------------------------------------------------------------------*/
volatile UINT8T unPreScaler;
volatile char nEndTest;
/*********************************************************************************************
* name: adc_test
* func: ADC convert test
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void adc_test(void)
{
int j;
UINT16T usConData;
float usEndData;
uart_printf("\n Adc Conversion Test Example \n");
uart_printf(" ADC_IN Test,channel 2\n");
uart_printf(" ADC conv. freq. = %dHz\n",ADC_FREQ);
unPreScaler = PCLK/ADC_FREQ -1;
rADCCON=(1<<14)|(unPreScaler<<6)|(2<<3)|(0<<2)|(1<<1);//enable prescaler,ain2,normal,start by read
uart_printf(" Please adjust AIN2 value!\n");
uart_printf(" The results of ADC are:\n");
usConData=rADCDAT0&0x3FF;
for(j=0;j<20;j++) // sample and show data both by UART and leds
{
while(!(rADCCON & 0x8000));
usConData=rADCDAT0&0x3FF;
usEndData=usConData*3.3000/0x3FF;
uart_printf(" %0.4f ",usEndData);
delay(10000);
}
uart_printf(" end.\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -