User`s manual
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
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.
The function is currently unsupported by the following PIC MCU models:
P18F2331, P18F2431, P18F4331, and P18F4431.
You can use the library function to initialize internal AD converter, select channel,
and get the result of conversion:
sub function ADC_Read(dim Channel as byte) as word
It initializes ADC module to work with RC clock. Clock determines the time peri-
od necessary for performing AD conversion (min 12TAD). RC sources typically
have Tad 4uS.
Parameter Channel determines which channel will be sampled. Refer to the device
data sheet for information on device channels.
Before using the function above, 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 following code demonstrates use of library function ADC_read. Example
reads Channel 2 and stores value in variable temp_res.
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
111
page
ADC Library
Routines
Important
Example