User manual

244
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
ADC_Set_Active
Prototype
procedure ADC_Set_Active(adc_gs : ^TADC_Get_Sample);
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
program ADC_on_LEDs;
var ADCresult : word;
txt : array[6] of char;
begin
PORTB := 0x0000; // clear PORTB
TRISB := 0xFFFF; // PORTB is input
ADC1_Init(); // Enable ADC module
UART1_Init(9600); // Initialize UART communication
while (TRUE) do
begin
ADCresult := ADC1_Get_Sample(1); // Acquire ADC sample
WordToStr(ADCresult, txt); // convert its value to string
UART1_Write_Text(txt); // and send it to UART terminal
Delay_ms(50);
end;
end.