ADC Library

ADC (Analog to Digital Converter) module is available with a number of ARM MCU modules. ADC is an electronic circuit that converts continuous signals to discrete digital numbers. ADC Library provides you a comfortable work with the module.

Library Routines

ADCx_Init

Prototype

void ADCx_Init();

Description

This routines configures ADC module.

The internal ADC module is set to:

  • single channel conversion
  • 10-bit conversion resolution for Stellaris devices and CEC1x02, 12-bit resolution for ST devices, 12-bit resolution for Kinetis devices and 14-bit for MSP432 devices.
  • unsigned integer data format
  • VRef+ : AVdd, VRef- : AVss

Parameters

None.

Returns

Nothing.

Requires
  • MCU with built-in ADC module.
Example
ADC1_Init();  // Initialize ADC module with default settings
Notes
  • ADC library routines require you to specify the module you want to use. To select the desired ADC module, simply change the letter x in the routine prototype for a number from 0 to 1.
  • Number of ADC modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.

ADCx_Init_Advanced

Prototype

void ADCx_Init_Advanced(unsigned short _external_reference);

// for MCUs with selectable ADC resolution

void ADCx_Init_Advanced(unsigned short _external_reference, unsigned short _adc_resolution);

// for MSP432

void ADC_Init_Advanced(unsigned long moduleclockSource, unsigned long moduleclockpredivider, unsigned long moduleclockdivider, unsigned long moduleinternalChannelMask);

// for ST M4, L4 subfamily :

void ADCx_Init_Advanced(char reference);

Description

This routine configures the internal ADC module to work with user defined settings.

Parameters

MSP432

  • moduleclockSource: clock source. Valid values :
    Value Description
    _ADC_CLOCKSOURCE_ADCOSC Internal low-power oscillator.
    _ADC_CLOCKSOURCE_SYSOSC System Oscillator.
    _ADC_CLOCKSOURCE_ACLK Auxiliary clock.
    _ADC_CLOCKSOURCE_MCLK Master clock.
    _ADC_CLOCKSOURCE_SMCLK Low-speed subsystem master clock.
    _ADC_CLOCKSOURCE_HSMCLK Subsystem master clock.
  • moduleclockpredivider: clock predivider. Valid values :
    Value Description
    _ADC_PREDIVIDER_1 Predivide by 1.
    _ADC_PREDIVIDER_4 Predivide by 4.
    _ADC_PREDIVIDER_32 Predivide by 32.
    _ADC_PREDIVIDER_64 Predivide by 64.
  • moduleclockdivider: clock divider. Valid values :
    Value Description
    _ADC_DIVIDER_1 Divide by 1.
    _ADC_DIVIDER_2 Divide by 2.
    _ADC_DIVIDER_3 Divide by 3.
    _ADC_DIVIDER_4 Divide by 4.
    _ADC_DIVIDER_5 Divide by 5.
    _ADC_DIVIDER_6 Divide by 6.
    _ADC_DIVIDER_7 Divide by 7.
    _ADC_DIVIDER_8 Divide by 8.
  • moduleinternalChannelMask: internal channel selection. Valid values :
    Value Description
    _ADC_MAPINTCH3 Controls internal channel 3 selection to ADC input channel MAX-5.
    _ADC_MAPINTCH2 Controls internal channel 2 selection to ADC input channel MAX-4.
    _ADC_MAPINTCH1 Controls internal channel 1 selection to ADC input channel MAX-3.
    _ADC_MAPINTCH0 Controls internal channel 0 selection to ADC input channel MAX-2.
    _ADC_TEMPSENSEMAP Controls temperature sensor ADC input channel selection.
    _ADC_BATTMAP Controls 1/2 AVCC ADC input channel selection.
    _ADC_NOROUTE No channel routing.

ST M4, L4 subfamily

  • reference : voltage reference used in ADC process :
    Value Description
    _ADC_EXTERNAL_VREFH Vref+ pin as voltage reference.
    _ADC_INTERNAL_FVRH2_048V 2.048V internal voltage reference.
    _ADC_INTERNAL_FVRH2_5V 2.5V internal voltage reference.

Other

  • _external_reference: voltage reference used in ADC process :
    Value Description
    _ADC_EXTERNAL_REF External voltage reference.
    _ADC_EXTERNAL_REF_3V 3V external voltage reference.
    _ADC_EXTERNAL_REF_1V 1V external voltage reference.
    _ADC_INTERNAL_REF Internal voltage reference.
  • _adc_resolution: voltage reference used in ADC process :
    Value Description
    _ADC_RESOLUTION_10BIT 10-bit ADC resolution.
    _ADC_RESOLUTION_12BIT 12-bit ADC resolution..
Returns

Nothing.

Requires
  • The MCU with built-in ADC module.
Example
// MSP432
ADC1_Init_Advanced(_ADC_CLOCKSOURCE_SYSOSC, _ADC_PREDIVIDER_1, _ADC_DIVIDER_1, _ADC_MAPINTCH3);	

// Stellaris
ADC1_Init_Advanced(_ADC_INTERNAL_REF);  // set internal reference used
Notes
  • ADC library routines require you to specify the module you want to use. To select the desired ADC module, simply change the letter x in the routine prototype for a number from 0 to 1.
  • Number of ADC modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.

ADC_Set_Input_Channel

Prototype // for Stellaris Cortex M3 devices and ST devices with 16 ADC channels or less :

void ADC_Set_Input_Channel(unsigned input_mask);

// for MSP432, Stellaris Cortex M4 devices and ST devices with more than 16 ADC channels :

void ADC_Set_Input_Channel(unsigned long input_mask);

// for CEC1x02 :

void ADC1_Set_Input_Channel(unsigned char input_mask);

// for Kinetis devices :

void ADCx_Set_Input_Channel(unsigned long input_mask);

Description

The function sets appropriate ADC channel as an analog input.

Parameters
  • channel: represents the channel which will be set as an analog input:
    Value Description
    _ADC_CHANNEL_0 ADC channel 0.
    _ADC_CHANNEL_1 ADC channel 1.
    _ADC_CHANNEL_2 ADC channel 2.
    _ADC_CHANNEL_3 ADC channel 3.
    _ADC_CHANNEL_4 ADC channel 4.
    _ADC_CHANNEL_5 ADC channel 5.
    _ADC_CHANNEL_6 ADC channel 6.
    _ADC_CHANNEL_7 ADC channel 7.
    _ADC_CHANNEL_8 ADC channel 8.
    _ADC_CHANNEL_9 ADC channel 9.
    _ADC_CHANNEL_10 ADC channel 10.
    _ADC_CHANNEL_11 ADC channel 11.
    _ADC_CHANNEL_12 ADC channel 12.
    _ADC_CHANNEL_13 ADC channel 13.
    _ADC_CHANNEL_14 ADC channel 14.
    _ADC_CHANNEL_15 ADC channel 15.
    _ADC_CHANNEL_16 ADC channel 16.
    _ADC_CHANNEL_17 ADC channel 17.
    _ADC_CHANNEL_18 ADC channel 18.
    _ADC_CHANNEL_19 ADC channel 19.
    _ADC_CHANNEL_20 ADC channel 20.
    _ADC_CHANNEL_21 ADC channel 21.
    _ADC_CHANNEL_22 ADC channel 22.
    _ADC_CHANNEL_23 ADC channel 23.
    _ADC_CHANNEL_24 ADC channel 24.
    _ADC_CHANNEL_25 ADC channel 25.
    _ADC_CHANNEL_26 ADC channel 26.
    _ADC_CHANNEL_27 ADC channel 27.
    _ADC_CHANNEL_28 ADC channel 28.
    _ADC_CHANNEL_29 ADC channel 29.
    _ADC_CHANNEL_30 ADC channel 30.
    _ADC_CHANNEL_31 ADC channel 31.
    _ADC_CHANNEL_ALL All ADC channels.
Returns

Nothing.

Requires
  • The MCU with built-in ADC module.
Example
// sets ADC channels 0 and 1 as analog inputs
ADC_Set_Input_Channel(_ADC_CHANNEL_0 | _ADC_CHANNEL_1);

// sets ADC channels 0 and 1 as analog inputs for CEC1x02 and Kinetis
ADC1_Set_Input_Channel(_ADC_CHANNEL_0 | _ADC_CHANNEL_1);
Notes
  • This routine is available only for MCUs with ADC module located on GPIO pins.
  • Refer to the appropriate Datasheet for the number of available channels.
  • For Kinetis devices, this routine require you to specify the module you want to use. To select the desired ADC module, simply change the letter x in the routine prototype for a number from 0 to 1.

ADCx_Get_Sample

Prototype

unsigned ADCx_Get_Sample(unsigned channel);

// for MSP432 :

unsigned ADC_Get_Sample(unsigned channel);

Description

The function enables ADC module and reads the specified analog channel input.

Parameters
  • channel: represents the channel from which the analog value is to be acquired :
    Value Description
    0 ADC channel 0.
    1 ADC channel 1.
    2 ADC channel 2.
    3 ADC channel 3.
    4 ADC channel 4.
    5 ADC channel 5.
    6 ADC channel 6.
    7 ADC channel 7.
    8 ADC channel 8.
    9 ADC channel 9.
    10 ADC channel 10.
    11 ADC channel 11.
    12 ADC channel 12.
    13 ADC channel 13.
    14 ADC channel 14.
    15 ADC channel 15.
    16 ADC channel 16.
    17 ADC channel 17.
    18 ADC channel 18.
    19 ADC channel 19.
    20 ADC channel 20.
    21 ADC channel 21.
    22 ADC channel 22.
    23 ADC channel 23.
    24 ADC channel 24.
    25 ADC channel 25.
    26 ADC channel 26.
    27 ADC channel 27.
    28 ADC channel 28.
    29 ADC channel 29.
    30 ADC channel 30.
    31 ADC channel 31.
Returns

10-bit (CEC1x02 and Stellaris devices), 12-bit (ST and Kinetis devices), 14-bit (MSP432 devices) unsigned value from the specified channel.

Requires
  • The MCU with built-in ADC module.
  • Prior to using this routine, appopriate ADC channels must be set as an analog input. Please see ADC_Set_Input_Channel.
  • Also, ADC module needs to be previously initialized. See ADCx_Init and ADCx_Init_Advanced.
Example
unsigned adc_value;
...
ADC_Set_Input_Channel(_ADC_CHANNEL_10); // Set ADC channel 10 as an analog input
ADC1_Init();                            // Initialize ADC module
adc_value = ADC1_Get_Sample(10);        // read analog value from ADC module channel 10
Notes
  • Refer to the appropriate Datasheet for the number of available channels.
  • ADC library routines require you to specify the module you want to use. To select the desired ADC module, simply change the letter x in the routine prototype for a number from 0 to 1.
  • Number of ADC modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.

ADCx_Read

Prototype // for Stellaris and Tiva :

unsigned ADCx_Read(unsigned channel, unsigned short _external_reference);

// for CEC1x02 :

unsigned ADCx_Read(unsigned char channel);

// for Kinetis :

unsigned ADCx_Read(unsigned long channel);

// for MSP432 and ST :

unsigned ADC_Read(unsigned channel);

Description

The function sets appropriate ADC channel as an analog input, enables ADC module, initializes ADC module and reads the specified analog channel input.

Parameters
  • channel: represents the channel from which the analog value is to be acquired :
    Value Description
    0 ADC channel 0.
    1 ADC channel 1.
    2 ADC channel 2.
    3 ADC channel 3.
    4 ADC channel 4.
    5 ADC channel 5.
    6 ADC channel 6.
    7 ADC channel 7.
    8 ADC channel 8.
    9 ADC channel 9.
    10 ADC channel 10.
    11 ADC channel 11.
    12 ADC channel 12.
    13 ADC channel 13.
    14 ADC channel 14.
    15 ADC channel 15.
    16 ADC channel 16.
    17 ADC channel 17.
    18 ADC channel 18.
    19 ADC channel 19.
    20 ADC channel 20.
    21 ADC channel 21.
    22 ADC channel 22.
    23 ADC channel 23.
    24 ADC channel 24.
    25 ADC channel 25.
    26 ADC channel 26.
    27 ADC channel 27.
    28 ADC channel 28.
    29 ADC channel 29.
    30 ADC channel 30.
    31 ADC channel 31.
  • _external_reference: voltage reference used in ADC process :
    Value Description
    _ADC_EXTERNAL_REF External voltage reference.
    _ADC_INTERNAL_REF Internal voltage reference.
Returns

10-bit (CEC1x02 and Stellaris devices), 12-bit (ST and Kinetis devices), 14-bit (MSP432) unsigned value from the specified channel.

Requires
  • The MCU with built-in ADC module.
Example
unsigned adc_value;
...
adc_value = ADC1_Read(10);    // read analog value from ADC1 module channel 10
Notes
  • Not all MCUs support external reference configuration. Please, read the appropriate datasheet before utilizing this library.
  • Refer to the appropriate Datasheet for the number of available channels.
  • ADC library routines require you to specify the module you want to use. To select the desired ADC module, simply change the letter x in the routine prototype for a number from 0 to 1.
  • Number of ADC modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.
  • Since this routine enables, initializes and reads value from ADC module, its execution will be much slower than the ADCx_Get_Sample which only samples analog value.
    If the speed is a key factor, it is advisable to initialize the ADC module first, and then sample analog value, rather than using ADCx_Read routine.

ADC_Configure_Single_Sample_Mode

Prototype

unsigned short ADC_Configure_Single_Sample_Mode(unsigned long memoryDestination, unsigned short repeatMode);

Description

The function configures single sampling mode.

Parameters
  • memoryDestination: coversion memory register. Valid values :
    Value Description
    _ADC_MEM0 ADC conversion memory register 0.
    _ADC_MEM1 ADC conversion memory register 1.
    _ADC_MEM2 ADC conversion memory register 2.
    _ADC_MEM3 ADC conversion memory register 3.
    _ADC_MEM4 ADC conversion memory register 4.
    _ADC_MEM5 ADC conversion memory register 5.
    _ADC_MEM6 ADC conversion memory register 6.
    _ADC_MEM7 ADC conversion memory register 7.
    _ADC_MEM8 ADC conversion memory register 8.
    _ADC_MEM9 ADC conversion memory register 9.
    _ADC_MEM10 ADC conversion memory register 10.
    _ADC_MEM11 ADC conversion memory register 11.
    _ADC_MEM12 ADC conversion memory register 12.
    _ADC_MEM13 ADC conversion memory register 13.
    _ADC_MEM14 ADC conversion memory register 14.
    _ADC_MEM15 ADC conversion memory register 15.
    _ADC_MEM16 ADC conversion memory register 16.
    _ADC_MEM17 ADC conversion memory register 17.
    _ADC_MEM18 ADC conversion memory register 18.
    _ADC_MEM19 ADC conversion memory register 19.
    _ADC_MEM20 ADC conversion memory register 20.
    _ADC_MEM21 ADC conversion memory register 21.
    _ADC_MEM22 ADC conversion memory register 22.
    _ADC_MEM23 ADC conversion memory register 23.
    _ADC_MEM24 ADC conversion memory register 24.
    _ADC_MEM25 ADC conversion memory register 25.
    _ADC_MEM26 ADC conversion memory register 26.
    _ADC_MEM27 ADC conversion memory register 27.
    _ADC_MEM28 ADC conversion memory register 28.
    _ADC_MEM29 ADC conversion memory register 29.
    _ADC_MEM30 ADC conversion memory register 30.
    _ADC_MEM31 ADC conversion memory register 31.
  • repeatMode: repeat mode. Valid values :
    Value Description
    0 ADC repeat mode disabled.
    1 ADC repeat mode enabled.
Returns
  • 2: if conversion is still running,
  • 1: if invalid memory selection,
  • 0: if there were no errors.
Requires
  • The MCU with built-in ADC module.
Example

Notes
  • Available only for MSP432 devices.

ADC_Configure_Multi_Sequence_Mode

Prototype

unsigned short ADC_Configure_Multi_Sequence_Mode(unsigned long memoryStart, unsigned long memoryEnd, unsigned short repeatMode);

Description

The function configures multi sequence sampling mode.

Parameters
  • memoryStart: starting memory conversion register. Valid values :
    Value Description
    _ADC_MEM0 ADC conversion memory register 0.
    _ADC_MEM1 ADC conversion memory register 1.
    _ADC_MEM2 ADC conversion memory register 2.
    _ADC_MEM3 ADC conversion memory register 3.
    _ADC_MEM4 ADC conversion memory register 4.
    _ADC_MEM5 ADC conversion memory register 5.
    _ADC_MEM6 ADC conversion memory register 6.
    _ADC_MEM7 ADC conversion memory register 7.
    _ADC_MEM8 ADC conversion memory register 8.
    _ADC_MEM9 ADC conversion memory register 9.
    _ADC_MEM10 ADC conversion memory register 10.
    _ADC_MEM11 ADC conversion memory register 11.
    _ADC_MEM12 ADC conversion memory register 12.
    _ADC_MEM13 ADC conversion memory register 13.
    _ADC_MEM14 ADC conversion memory register 14.
    _ADC_MEM15 ADC conversion memory register 15.
    _ADC_MEM16 ADC conversion memory register 16.
    _ADC_MEM17 ADC conversion memory register 17.
    _ADC_MEM18 ADC conversion memory register 18.
    _ADC_MEM19 ADC conversion memory register 19.
    _ADC_MEM20 ADC conversion memory register 20.
    _ADC_MEM21 ADC conversion memory register 21.
    _ADC_MEM22 ADC conversion memory register 22.
    _ADC_MEM23 ADC conversion memory register 23.
    _ADC_MEM24 ADC conversion memory register 24.
    _ADC_MEM25 ADC conversion memory register 25.
    _ADC_MEM26 ADC conversion memory register 26.
    _ADC_MEM27 ADC conversion memory register 27.
    _ADC_MEM28 ADC conversion memory register 28.
    _ADC_MEM29 ADC conversion memory register 29.
    _ADC_MEM30 ADC conversion memory register 30.
    _ADC_MEM31 ADC conversion memory register 31.
  • memoryEnd: ending memory conversion register. Valid values :
    Value Description
    _ADC_MEM0 ADC conversion memory register 0.
    _ADC_MEM1 ADC conversion memory register 1.
    _ADC_MEM2 ADC conversion memory register 2.
    _ADC_MEM3 ADC conversion memory register 3.
    _ADC_MEM4 ADC conversion memory register 4.
    _ADC_MEM5 ADC conversion memory register 5.
    _ADC_MEM6 ADC conversion memory register 6.
    _ADC_MEM7 ADC conversion memory register 7.
    _ADC_MEM8 ADC conversion memory register 8.
    _ADC_MEM9 ADC conversion memory register 9.
    _ADC_MEM10 ADC conversion memory register 10.
    _ADC_MEM11 ADC conversion memory register 11.
    _ADC_MEM12 ADC conversion memory register 12.
    _ADC_MEM13 ADC conversion memory register 13.
    _ADC_MEM14 ADC conversion memory register 14.
    _ADC_MEM15 ADC conversion memory register 15.
    _ADC_MEM16 ADC conversion memory register 16.
    _ADC_MEM17 ADC conversion memory register 17.
    _ADC_MEM18 ADC conversion memory register 18.
    _ADC_MEM19 ADC conversion memory register 19.
    _ADC_MEM20 ADC conversion memory register 20.
    _ADC_MEM21 ADC conversion memory register 21.
    _ADC_MEM22 ADC conversion memory register 22.
    _ADC_MEM23 ADC conversion memory register 23.
    _ADC_MEM24 ADC conversion memory register 24.
    _ADC_MEM25 ADC conversion memory register 25.
    _ADC_MEM26 ADC conversion memory register 26.
    _ADC_MEM27 ADC conversion memory register 27.
    _ADC_MEM28 ADC conversion memory register 28.
    _ADC_MEM29 ADC conversion memory register 29.
    _ADC_MEM30 ADC conversion memory register 30.
    _ADC_MEM31 ADC conversion memory register 31.
  • repeatMode: repeat mode. Valid values :
    Value Description
    0 ADC repeat mode disabled.
    1 ADC repeat mode enabled.
Returns
  • 2: if conversion is still running,
  • 1: if invalid memory selection,
  • 0: if there were no errors.
Requires
  • The MCU with built-in ADC module.
Example

Notes
  • Available only for MSP432 devices.

ADC_Configure_Conversion_Memory

Prototype

unsigned short ADC_Configure_Conversion_Memory(unsigned long memorySelect, unsigned long refSelect, unsigned long channelSelect, unsigned short differntialMode);

Description

The function configures conversion memory.

Parameters
  • memorySelect: conversion memory register. Valid values :
    Value Description
    _ADC_MEM0 ADC conversion memory register 0.
    _ADC_MEM1 ADC conversion memory register 1.
    _ADC_MEM2 ADC conversion memory register 2.
    _ADC_MEM3 ADC conversion memory register 3.
    _ADC_MEM4 ADC conversion memory register 4.
    _ADC_MEM5 ADC conversion memory register 5.
    _ADC_MEM6 ADC conversion memory register 6.
    _ADC_MEM7 ADC conversion memory register 7.
    _ADC_MEM8 ADC conversion memory register 8.
    _ADC_MEM9 ADC conversion memory register 9.
    _ADC_MEM10 ADC conversion memory register 10.
    _ADC_MEM11 ADC conversion memory register 11.
    _ADC_MEM12 ADC conversion memory register 12.
    _ADC_MEM13 ADC conversion memory register 13.
    _ADC_MEM14 ADC conversion memory register 14.
    _ADC_MEM15 ADC conversion memory register 15.
    _ADC_MEM16 ADC conversion memory register 16.
    _ADC_MEM17 ADC conversion memory register 17.
    _ADC_MEM18 ADC conversion memory register 18.
    _ADC_MEM19 ADC conversion memory register 19.
    _ADC_MEM20 ADC conversion memory register 20.
    _ADC_MEM21 ADC conversion memory register 21.
    _ADC_MEM22 ADC conversion memory register 22.
    _ADC_MEM23 ADC conversion memory register 23.
    _ADC_MEM24 ADC conversion memory register 24.
    _ADC_MEM25 ADC conversion memory register 25.
    _ADC_MEM26 ADC conversion memory register 26.
    _ADC_MEM27 ADC conversion memory register 27.
    _ADC_MEM28 ADC conversion memory register 28.
    _ADC_MEM29 ADC conversion memory register 29.
    _ADC_MEM30 ADC conversion memory register 30.
    _ADC_MEM31 ADC conversion memory register 31.
  • refSelect: voltage reference selection. Valid values :
    Value Description
    _ADC_VREFPOS_AVCC_VREFNEG_VSS V(R+) = AVCC, V(R-) = AVSS.
    _ADC_VREFPOS_INTBUF_VREFNEG_VSS V(R+) = VREF buffered, V(R-) = AVSS.
    _ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG V(R+) = VeREF+, V(R-) = VeREF-.
    _ADC_VREFPOS_EXTBUF_VREFNEG_EXTNEG VeREF+ buffered, V(R-) = VeREF.
  • channelSelect: channel select. Valid values :
    Value Description
    _ADC_CHANNEL_0 ADC channel 0.
    _ADC_CHANNEL_1 ADC channel 1.
    _ADC_CHANNEL_2 ADC channel 2.
    _ADC_CHANNEL_3 ADC channel 3.
    _ADC_CHANNEL_4 ADC channel 4.
    _ADC_CHANNEL_5 ADC channel 5.
    _ADC_CHANNEL_6 ADC channel 6.
    _ADC_CHANNEL_7 ADC channel 7.
    _ADC_CHANNEL_8 ADC channel 8.
    _ADC_CHANNEL_9 ADC channel 9.
    _ADC_CHANNEL_10 ADC channel 10.
    _ADC_CHANNEL_11 ADC channel 11.
    _ADC_CHANNEL_12 ADC channel 12.
    _ADC_CHANNEL_13 ADC channel 13.
    _ADC_CHANNEL_14 ADC channel 14.
    _ADC_CHANNEL_15 ADC channel 15.
    _ADC_CHANNEL_16 ADC channel 16.
    _ADC_CHANNEL_17 ADC channel 17.
    _ADC_CHANNEL_18 ADC channel 18.
    _ADC_CHANNEL_19 ADC channel 19.
    _ADC_CHANNEL_20 ADC channel 20.
    _ADC_CHANNEL_21 ADC channel 21.
    _ADC_CHANNEL_22 ADC channel 22.
    _ADC_CHANNEL_23 ADC channel 23.
    _ADC_CHANNEL_ALL All ADC channels.

  • differntialMode: differential mode. Valid values :
    Value Description
    0 Differential mode disabled.
    1 Differential mode enabled.
Returns
  • 2: if conversion is still running,
  • 1: if invalid memory selection,
  • 0: if there were no errors.
Requires
  • The MCU with built-in ADC module.
Example

Notes
  • Available only for MSP432 devices.

ADC_Enable_Sample_Timer

Prototype

unsigned short ADC_Enable_Sample_Timer(unsigned long multiSampleConvert);

Description

The function enables sampling timer.

Parameters
  • multiSampleConvert: conversion memory register. Valid values :
    Value Description
    _ADC_MANUAL_ITERATION ADC manual iteration.
    _ADC_AUTOMATIC_ITERATION ADC automatic iteration.
Returns
  • 1: if invalid memory selection,
  • 0: if there were no errors.
Requires
  • The MCU with built-in ADC module.
Example

Notes
  • Available only for MSP432 devices.

ADC_Enable_Conversion

Prototype

unsigned short ADC_Enable_Conversion();

Description

The function enables ADC conversion.

Parameters

None.

Returns
  • 2: if conversion is still running,
  • 1: if ADC module is off,
  • 0: if there were no errors.
Requires
  • The MCU with built-in ADC module.
Example

Notes
  • Available only for MSP432 devices.

ADC_Disable_Conversion

Prototype

unsigned short ADC_Disable_Conversion();

Description

The function disables ADC conversion.

Parameters

None.

Returns
  • 2: if conversion is still running,
  • 1: if ADC module is off,
  • 0: if there were no errors.
Requires
  • The MCU with built-in ADC module.
Example

Notes
  • Available only for MSP432 devices.

ADC_Start_Conversion

Prototype

unsigned short ADC_Start_Conversion();

Description

The function starts ADC conversion.

Parameters

None.

Returns
  • 2: if conversion is still running,
  • 1: if ADC module is off,
  • 0: if there were no errors.
Requires
  • The MCU with built-in ADC module.
Example

Notes
  • Available only for MSP432 devices.
Copyright (c) 2002-2019 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code