www.pudn.com > u241test.rar > Adc.c


//==================================================================== 
// File Name : Adc.c 
// Function  : S3C2410 ADC Test  
// Program   : Kang, Weon Tark  
// Date      : May 22, 2002 
// Version   : 0.0 
// History 
//   0.0 : Programming start (March 29,2002) -> KWT 
//         ADC Test                          -> May 15, 2002 SOP 
//==================================================================== 
#include  
#include "2410addr.h" 
#include "2410lib.h" 
#include "adc.h" 
#include "def.h" 
 
#define REQCNT 100              //May 08, 2002 SOP 
//#define ADC_FREQ 2500000 
#define ADC_FREQ   1250000 
//#define LOOP 1 
#define LOOP 10000 
 
void __irq DMA0_Done(void);	//Declare Prototype function 
 
int ReadAdc(int ch);	        //Return type is int, Declare Prototype function 
volatile U32 preScaler; 
 
//================================================================================== 
void Test_Adc(void) 
{ 
    int i,key; 
    int a0=0,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0; //Initialize variables 
     
    Uart_Printf("[ ADC_IN Test ]\n"); 
    Uart_Printf("0. Dispaly Count 100     1. Continued ...\n\n"); 
    Uart_Printf("Selet : "); 
    key = Uart_GetIntNum(); 
    Uart_Printf("\n\n");     
         
    Uart_Printf("The ADC_IN are adjusted to the following values.\n");	       
    Uart_Printf("Push any key to exit!!!\n");	  
 
    preScaler = ADC_FREQ; 
    Uart_Printf("ADC conv. freq. = %dHz\n",preScaler); 
    preScaler = PCLK/ADC_FREQ -1;               //PCLK:50.7MHz 
    //ADC conversion time = 5CYCLES*(1/(ADC Freq.)), ADC Freq. = PCLK/(ADCPSR+1) 
     
    Uart_Printf("PCLK/ADC_FREQ - 1 = %d\n",preScaler); 
     
    if (key == 0) 
    { 
        Uart_Printf("[ AIN2 ]\n");                          //May 08, 2002 SOP    
     
        for(i=0;i