User manual

238
mikoPascal PRO for PIC32
MikroElektronika
ADC1_Get_Sample
Prototype
function ADC1_Get_Sample(channel : word) : word;
Description The function enables ADC module and reads the specied analog channel input.
Parameters - channel represents the channel from which the analog value is to be acquired.
Returns 10-bit unsigned value from the specied channel.
Requires - The MCU with built-in ADC module.
- Prior to using this routine, ADC module needs to be initialized. See ADCx_Init and ADCx_Init_
Advanced.
- Before using the function, be sure to congure the appropriate TRISx bits to designate pins as
inputs.
Example
var adc_value : word;
...
adc_value = ADC1_Get_Sample(10); // read analog value from ADC module
channel 10
Notes - The function sets the appropriate bit in the AD1PCFG registers to enable analog function of the
chosen pin.
- Refer to the appropriate Datasheet for channel-to-pin mapping.
ADC1_Init_Advanced
Prototype
procedure ADC1_Init_Advanced(Reference : word);
Description This routine congures the internal ADC module to work with user dened settings.
Parameters - Reference: voltage reference used in ADC process.
Returns Nothing.
Requires - The MCU with built-in ADC module.
Example
ADC1_Init_Advanced(_ADC_INTERNAL_REF); // set internal reference used
Notes - Not all MCUs support advanced conguration. Please, read the appropriate datasheet before utilizing
this library.
Description Predened library const
Voltage reference:
Internal voltage reference _ADC_INTERNAL_REF
External voltage reference _ADC_EXTERNAL_REF