User manual
mikroC PRO for dsPIC
MikroElektronika
273
ADC_Set_Active
Prototype
void ADC_Set_Active(unsigned (*adc_gs)(unsigned));
Description Sets active ADC module.
Parameters Parameters:
- adc_gs: ADCx_Get_Sample handler.
Returns Nothing.
Requires Routine is available only for MCUs with multiple ADC modules.
Used ADC module must be initialized before using this routine. See ADCx_Init and ADCx_Init_
Advanced routines.
Example
// Activate ADC2 module
ADC_Set_Active(ADC2_Get_Sample);
Notes None.
Library Example
This code snippet reads analog value from the channel 1 and sends readings as a text over UART1.
Copy Code To Clipboard
unsigned adcRes;
char txt[6];
void main() {
PORTB = 0x0000;
TRISB.F1 = 1; // set pin as input - needed for ADC to work
ADC1_Init();
UART1_Init(9600);
while (1) {
adcRes = ADC1_Get_Sample(1);
WordToStr(adcRes, txt);
UART1_Write_Text(txt);
Delay_ms(50);
}
}