Embedded
Linux Bare Metal Development (14)--ADC First,
Introduction to AD conversion
ad conversions are analog -to-digital conversions , is to convert analog signals into digital signals. A/D converters are used to convert analog quantities into digital quantities through a certain circuit. Analog can be voltage, current and other electrical signals, can also be pressure, temperature, humidity, displacement, sound and other non-electrical signals. Before the A/D conversion, the input signal to A/D converter must be converted to a voltage signal by various sensors to the various physical quantities. After A/D conversion, the output digital signal can be 8-bit, 10-bit, 12-bit, 14-bit and 16-bit.
Second,
ADC Controller
ADC Controller clock:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/82/93/wKiom1dba2_RIayZAABD_22V2TY437.png "title=" Picture 1.png "alt=" Wkiom1dba2_riayzaabd_22v2ty437.png "/>
The clock source is Pclk_psys, and the ADCCLK is obtained after a one-time crossover.
the S5PV210 supports 10 ADC channels, Ain[0] - ain[9] (analog type), can support simultaneous 10-way AD conversion.
TSADCCON0 : ADC Converter Settings Register
TSDATX0 : Conversion of the resulting digital amount
CLRINTADC0 : Clear ADC0 Channel Interrupt
Adcmux : Analog input channel selection
Third,
ADC Programming 1.
Initializing the Controller
void Adc_init (void)
{
TSADCCON0 |= (1<<16); set The precision of the digits
TSADCCON0 |= (1<<14); turn on prescaler settings for ADC converters
TSADCCON0 &= ~ (0xff<<6);//
TSADCCON0 |= (65<<6);// Set the Prescaler parameter, the prescaler coefficient is 65+1
TSADCCON0 &= ~ (1<<2);// set Normal mode
TSADCCON0 &= ~ (1<<1);// turn on ADC
Adcmux &= ~ (0x0f<<0); Select Channel 0
}
2.
Engineering Implementation
Project source code to The UART transplant printf is modeled, but the Smart210 does not have an ADC interface, so the code cannot be tested.
ADC Conversion Source:
void adc_printf (void)
{
int Val;
Adc_init ();
while (1)
{
turn on ADC conversion
TSADCCON0 |= (1<<0);
waiting for AD conversion to complete
while (!) ( TSADCCON0 & (1<<15));
Read the ADC Conversion number
val = TSDATX0;
Processing Display
printf ("val =%d\r\n", (Val & (0xfff<<0)));
Delay
Delay (0X1FFFFF);
}
}
Engineering source See annex
This article from "Endless life, Struggle not only" blog, please be sure to keep this source http://9291927.blog.51cto.com/9281927/1787883
Embedded Linux bare Metal Development (14)--ADC