User manual
mikroBasic PRO for PIC32
MikroElektronika
241
ADCx_Get_Sample
Prototype
sub function ADC1_Get_Sample(dim channel as word) as word
Description The function enables ADC module and reads the specied analog channel input.
Parameters - channel represents the channel from which the analog value is to be acquired.
Returns 10-bit unsigned value from the specied 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 congure the appropriate TRISx bits to designate pins as
inputs.
Example
dim adc_value as 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.
ADCx_Read
Prototype
sub function ADC1_Read(dim channel as word) as word
Description The function initializes, enables ADC module and reads the specied analog channel input.
Parameters - channel represents the channel from which the analog value is to be acquired.
Returns 10-bit unsigned value from the specied channel.
Requires - The MCU with built-in ADC module.
- Before using the function, be sure to congure the appropriate TRISx bits to designate pins as
inputs.
Example
dim adc_value as word
...
adc_value = ADC1_Read(10) ‘ read analog value from ADCmodule channel 10
Notes - This is a standalone routine, so there is no need for a previous initialization of ADC module.
- The function sets the appropriate bit in the ADPCFG registers to enable analog function of the
chosen pin.
- Refer to the appropriate Datasheet for channel-to-pin mapping.