2440 bare metal programming seven analog-to-digital converter ADC

Publisher:温柔阳光Latest update time:2019-11-09 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The S3C2440A has an internal 10-bit analog-to-digital converter (ADC) with 8 analog signal inputs.



The registers used are:
ADCCON: used to select channel, set frequency, start conversion, and end mark
   ADC frequency = PCLK/(ADCCON[13:6]+1)
ADCDATn: used to read the conversion result of ADC channel n: ADCDATn[9:0]


The following is an experimental program for ADC channel 0:
//********************************************************************
#define adc_frequency 2000000

void Main(void)
{     
    int i;
    ...Hardware initialization...

Uart_Printf("ADC experiment nn");

rADCCON = 1<<3 | (PCLK/adc_frequency - 1)<<6 | 1<<14 ; //Select channel 1, set ADC frequency, the frequency is valid

while(1)
{
     rADCCON|=0x1; //Start ADC

     while(!(rADCCON & 0x8000)); //Wait for the conversion to complete
  Uart_Printf("AIN1: %dn",rADCDAT0&0x3FF); //Output the conversion result
  Delay(1000); //Delay for 1 second
}
}

//***********************************************************************

The results are as follows:


Reference address:2440 bare metal programming seven analog-to-digital converter ADC

Previous article:2440 Bare Metal Programming 8 UART Universal Asynchronous Receiver and Transmitter
Next article:2440 bare metal programming six real-time clock

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号