📄 adc_test.c
字号:
/*********************************************************************************************
* File: adc_test.c
* Author: embest
* Desc: S3C2410 ADC Test
* History:
* H.T.Zhang, Programming modify, September 14, 2005
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/* include files */
/*------------------------------------------------------------------------------------------*/
#include "2410lib.h"
#include "demo.h"
#include "lcd.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 i;
char buf[60];
UINT16T usConData;
float usEndData;
uart_printf("\n Adc Conversion Test Example (Please look at 8-seg LED)\n");
uart_printf(" ADC_IN Test,channel 2\n");
uart_printf(" ADC conv. freq. = %dHz\n",ADC_FREQ);
sprintf(buf,"ADC conversion freq. = %dHz",ADC_FREQ);
lcd_disp_ascii8x16(20,75,BLUE,(UINT8T *)buf);
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;
i = 0;
f_nKeyPress = 0;
while(!f_nKeyPress) // any key to exit.
{
while(!(rADCCON & 0x8000));
usConData=rADCDAT0&0x3FF;
usEndData=usConData*3.3000/0x3FF;
sprintf(buf,"Ain2 = %1.4f", usEndData);
lcd_clr_rect(110,105+16*i,220,105+16*(i+1),BLUE);
lcd_disp_ascii8x16(110,105+16*i,WHITE,(UINT8T *)buf);
if (++i > 4) i = 0;
delay(10000);
}
uart_printf(" end.\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -