ADC (Analog to Digital Converter) module is available with a number of PIC
MCU models. Library function
Adc_Read
is included to provide you comfortable
work with the module.
MikroElektronika: Development tools - Books - Compilers
139
page
mikroC - C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
ADC Library
Prototype
unsigned
Adc_Read(
char
channel);
Returns
10-bit unsigned value read from the specified ADC channel.
Description
Initializes PIC’s internal ADC module to work with RC clock. Clock determines the
time period necessary for performing AD conversion (min 12TAD).
Parameter
channel
represents the channel from which the analog value is to be
acquired. For channel-to-pin mapping please refer to documentation for the appropriate
PIC MCU.
Requires
PIC MCU with built-in ADC module. You should consult the Datasheet documentation
for specific device (most devices from PIC16/18 families have it).
Before using the function, be sure to configure the appropriate TRISA bits to designate
the pins as input. Also, configure the desired pin as analog input, and set Vref (voltage
reference value).
The function is currently unsupported by the following PICmicros: P18F2331,
P18F2431, P18F4331, and P18F4431.
Example
unsigned
tmp;
...
tmp = Adc_Read(1);
/* read analog value from channel 1 */
Adc_Read