MSP430 DriverLib for MSP430FR2xx_4xx Devices  2.10.00.09
 All Data Structures Functions Variables Modules Pages
adc

Functions

void ADC_init (uint16_t baseAddress, uint16_t sampleHoldSignalSourceSelect, uint8_t clockSourceSelect, uint16_t clockSourceDivider)
 Initializes the ADC Module. More...
 
void ADC_enable (uint16_t baseAddress)
 Enables the ADC block. More...
 
void ADC_disable (uint16_t baseAddress)
 Disables the ADC block. More...
 
void ADC_setupSamplingTimer (uint16_t baseAddress, uint16_t clockCycleHoldCount, uint16_t multipleSamplesEnabled)
 Sets up and enables the Sampling Timer Pulse Mode. More...
 
void ADC_disableSamplingTimer (uint16_t baseAddress)
 Disables Sampling Timer Pulse Mode. More...
 
void ADC_configureMemory (uint16_t baseAddress, uint8_t inputSourceSelect, uint8_t positiveRefVoltageSourceSelect, uint8_t negativeRefVoltageSourceSelect)
 Configures the controls of the selected memory buffer. More...
 
void ADC_enableInterrupt (uint16_t baseAddress, uint8_t interruptMask)
 Enables selected ADC interrupt sources. More...
 
void ADC_disableInterrupt (uint16_t baseAddress, uint8_t interruptMask)
 Disables selected ADC interrupt sources. More...
 
void ADC_clearInterrupt (uint16_t baseAddress, uint8_t interruptFlagMask)
 Clears ADC10B selected interrupt flags. More...
 
uint8_t ADC_getInterruptStatus (uint16_t baseAddress, uint8_t interruptFlagMask)
 Returns the status of the selected memory interrupt flags. More...
 
void ADC_startConversion (uint16_t baseAddress, uint8_t conversionSequenceModeSelect)
 Enables/Starts an Analog-to-Digital Conversion. More...
 
void ADC_disableConversions (uint16_t baseAddress, bool preempt)
 Disables the ADC from converting any more signals. More...
 
int16_t ADC_getResults (uint16_t baseAddress)
 Returns the raw contents of the specified memory buffer. More...
 
void ADC_setResolution (uint16_t baseAddress, uint8_t resolutionSelect)
 Use to change the resolution of the converted data. More...
 
void ADC_setSampleHoldSignalInversion (uint16_t baseAddress, uint16_t invertedSignal)
 Use to invert or un-invert the sample/hold signal. More...
 
void ADC_setDataReadBackFormat (uint16_t baseAddress, uint16_t readBackFormat)
 Use to set the read-back format of the converted data. More...
 
void ADC_setReferenceBufferSamplingRate (uint16_t baseAddress, uint16_t samplingRateSelect)
 Use to set the reference buffer's sampling rate. More...
 
void ADC_setWindowComp (uint16_t baseAddress, uint16_t highThreshold, uint16_t lowThreshold)
 Sets the high and low threshold for the window comparator feature. More...
 
uint32_t ADC_getMemoryAddressForDMA (uint16_t baseAddress)
 Returns the address of the memory buffer for the DMA module. More...
 
uint8_t ADC_isBusy (uint16_t baseAddress)
 Returns the busy status of the ADC core. More...
 

Detailed Description

Function Documentation

void ADC_clearInterrupt ( uint16_t  baseAddress,
uint8_t  interruptFlagMask 
)

Clears ADC10B selected interrupt flags.

The selected ADC interrupt flags are cleared, so that it no longer asserts. The memory buffer interrupt flags are only cleared when the memory buffer is accessed.

Parameters
baseAddressis the base address of the ADC module.
interruptFlagMaskis a bit mask of the interrupt flags to be cleared. Mask value is the logical OR of any of the following:
  • ADC_OVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new conversion is about to overwrite the previous one
  • ADC_TIMEOVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new conversion is starting before the previous one has finished
  • ADC_ABOVETHRESHOLD_INTERRUPT_FLAG - Interrup flag for when the input signal has gone above the high threshold of the window comparator
  • ADC_BELOWTHRESHOLD_INTERRUPT_FLAG - Interrupt flag for when the input signal has gone below the low threshold of the window comparator
  • ADC_INSIDEWINDOW_INTERRUPT_FLAG - Interrupt flag for when the input signal is in between the high and low thresholds of the window comparator
  • ADC_COMPLETED_INTERRUPT_FLAG - Interrupt flag for new conversion data in the memory buffer

Modified bits of ADCIFG register.

Returns
None
void ADC_configureMemory ( uint16_t  baseAddress,
uint8_t  inputSourceSelect,
uint8_t  positiveRefVoltageSourceSelect,
uint8_t  negativeRefVoltageSourceSelect 
)

Configures the controls of the selected memory buffer.

Maps an input signal conversion into the memory buffer, as well as the positive and negative reference voltages for each conversion being stored into the memory buffer. If the internal reference is used for the positive reference voltage, the internal REF module has to control the voltage level. Note that if a conversion has been started with the startConversion() function, then a call to disableConversions() is required before this function may be called.

Parameters
baseAddressis the base address of the ADC module.
inputSourceSelectis the input that will store the converted data into the specified memory buffer. Valid values are:
  • ADC_INPUT_VEREF_N [Default]
  • ADC_INPUT_VEREF_P
  • ADC_INPUT_A2
  • ADC_INPUT_A3
  • ADC_INPUT_A4
  • ADC_INPUT_A5
  • ADC_INPUT_A6
  • ADC_INPUT_A7
  • ADC_INPUT_A8 - [Valid for FR4xx devices]
  • ADC_INPUT_A9 - [Valid for FR4xx devices]
  • ADC_INPUT_TEMPSENSOR
  • ADC_INPUT_REFVOLTAGE
  • ADC_INPUT_DVSS
  • ADC_INPUT_DVCC
    Modified bits are ADCINCHx of ADCMCTL0 register.
positiveRefVoltageSourceSelectis the reference voltage source to set as the upper limit for the conversion that is to be stored in the specified memory buffer. Valid values are:
  • ADC_VREFPOS_AVCC [Default]
  • ADC_VREFPOS_INT
  • ADC_VREFPOS_EXT_BUF
  • ADC_VREFPOS_EXT_NOBUF
    Modified bits are ADCSREF of ADCMCTL0 register.
negativeRefVoltageSourceSelectis the reference voltage source to set as the lower limit for the conversion that is to be stored in the specified memory buffer. Valid values are:
  • ADC_VREFNEG_AVSS [Default]
  • ADC_VREFNEG_EXT
    Modified bits are ADCSREF of ADCMCTL0 register.
Returns
None
void ADC_disable ( uint16_t  baseAddress)

Disables the ADC block.

This will disable operation of the ADC block.

Parameters
baseAddressis the base address of the ADC module.

Modified bits are ADCON of ADCCTL0 register.

Returns
None
void ADC_disableConversions ( uint16_t  baseAddress,
bool  preempt 
)

Disables the ADC from converting any more signals.

Disables the ADC from converting any more signals. If there is a conversion in progress, this function can stop it immediatly if the preempt parameter is set as ADC_PREEMPTCONVERSION, by changing the conversion mode to single- channel, single-conversion and disabling conversions. If the conversion mode is set as single-channel, single-conversion and this function is called without preemption, then the ADC core conversion status is polled until the conversion is complete before disabling conversions to prevent unpredictable data. If the ADC_startConversion() has been called, then this function has to be called to re-initialize the ADC, reconfigure a memory buffer control, enable/disable the sampling pulse mode, or change the internal reference voltage.

Parameters
baseAddressis the base address of the ADC module.
preemptspecifies if the current conversion should be preemptly stopped before the end of the conversion Valid values are:
  • ADC_COMPLETECONVERSION - Allows the ADC to end the current conversion before disabling conversions.
  • ADC_PREEMPTCONVERSION - Stops the ADC10B immediatly, with unpredicatble results of the current conversion. Cannot be used with repeated conversion.

Modified bits of ADCCTL0 register and bits of ADCCTL1 register.

Returns
None
void ADC_disableInterrupt ( uint16_t  baseAddress,
uint8_t  interruptMask 
)

Disables selected ADC interrupt sources.

Disables the indicated ADC interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

Parameters
baseAddressis the base address of the ADC module.
interruptMaskis the bit mask of the memory buffer interrupt sources to be disabled. Mask value is the logical OR of any of the following:
  • ADC_OVERFLOW_INTERRUPT - Interrupts when a new conversion is about to overwrite the previous one
  • ADC_TIMEOVERFLOW_INTERRUPT - Interrupts when a new conversion is starting before the previous one has finished
  • ADC_ABOVETHRESHOLD_INTERRUPT - Interrups when the input signal has gone above the high threshold of the window comparator
  • ADC_BELOWTHRESHOLD_INTERRUPT - Interrupts when the input signal has gone below the low threshold of the low window comparator
  • ADC_INSIDEWINDOW_INTERRUPT - Interrupts when the input signal is in between the high and low thresholds of the window comparator
  • ADC_COMPLETED_INTERRUPT - Interrupt for new conversion data in the memory buffer

Modified bits of ADCIE register.

Returns
None
void ADC_disableSamplingTimer ( uint16_t  baseAddress)

Disables Sampling Timer Pulse Mode.

Disables the Sampling Timer Pulse Mode. Note that if a conversion has been started with the startConversion() function, then a call to disableConversions() is required before this function may be called.

Parameters
baseAddressis the base address of the ADC module.

Modified bits are ADCSHP of ADCCTL1 register.

Returns
None
void ADC_enable ( uint16_t  baseAddress)

Enables the ADC block.

This will enable operation of the ADC block.

Parameters
baseAddressis the base address of the ADC module.

Modified bits are ADCON of ADCCTL0 register.

Returns
None
void ADC_enableInterrupt ( uint16_t  baseAddress,
uint8_t  interruptMask 
)

Enables selected ADC interrupt sources.

Enables the indicated ADC interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor. Does not clear interrupt flags.

Parameters
baseAddressis the base address of the ADC module.
interruptMaskis the bit mask of the memory buffer interrupt sources to be enabled. Mask value is the logical OR of any of the following:
  • ADC_OVERFLOW_INTERRUPT - Interrupts when a new conversion is about to overwrite the previous one
  • ADC_TIMEOVERFLOW_INTERRUPT - Interrupts when a new conversion is starting before the previous one has finished
  • ADC_ABOVETHRESHOLD_INTERRUPT - Interrups when the input signal has gone above the high threshold of the window comparator
  • ADC_BELOWTHRESHOLD_INTERRUPT - Interrupts when the input signal has gone below the low threshold of the low window comparator
  • ADC_INSIDEWINDOW_INTERRUPT - Interrupts when the input signal is in between the high and low thresholds of the window comparator
  • ADC_COMPLETED_INTERRUPT - Interrupt for new conversion data in the memory buffer

Modified bits of ADCIE register.

Returns
None

uint8_t ADC_getInterruptStatus ( uint16_t  baseAddress,
uint8_t  interruptFlagMask 
)

Returns the status of the selected memory interrupt flags.

Returns the status of the selected interrupt flags.

Parameters
baseAddressis the base address of the ADC module.
interruptFlagMaskis a bit mask of the interrupt flags status to be returned. Mask value is the logical OR of any of the following:
  • ADC_OVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new conversion is about to overwrite the previous one
  • ADC_TIMEOVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new conversion is starting before the previous one has finished
  • ADC_ABOVETHRESHOLD_INTERRUPT_FLAG - Interrup flag for when the input signal has gone above the high threshold of the window comparator
  • ADC_BELOWTHRESHOLD_INTERRUPT_FLAG - Interrupt flag for when the input signal has gone below the low threshold of the window comparator
  • ADC_INSIDEWINDOW_INTERRUPT_FLAG - Interrupt flag for when the input signal is in between the high and low thresholds of the window comparator
  • ADC_COMPLETED_INTERRUPT_FLAG - Interrupt flag for new conversion data in the memory buffer

Modified bits of ADC10IFG register.

Returns
The current interrupt flag status for the corresponding mask.
uint32_t ADC_getMemoryAddressForDMA ( uint16_t  baseAddress)

Returns the address of the memory buffer for the DMA module.

Parameters
baseAddressis the base address of the ADC module.
Returns
the address of the memory buffer. This can be used in conjunction with the DMA to store the converted data directly to memory.
int16_t ADC_getResults ( uint16_t  baseAddress)

Returns the raw contents of the specified memory buffer.

Returns the raw contents of the specified memory buffer. The format of the content depends on the read-back format of the data: if the data is in signed 2's complement format then the contents in the memory buffer will be left-justified with the least-siginificant bits as 0's, whereas if the data is in unsigned format then the contents in the memory buffer will be right- justified with the most-significant bits as 0's.

Parameters
baseAddressis the base address of the ADC module.
Returns
A Signed Integer of the contents of the specified memory buffer.
void ADC_init ( uint16_t  baseAddress,
uint16_t  sampleHoldSignalSourceSelect,
uint8_t  clockSourceSelect,
uint16_t  clockSourceDivider 
)

Initializes the ADC Module.

This function initializes the ADC module to allow for analog-to-digital conversions. Specifically this function sets up the sample-and-hold signal and clock sources for the ADC core to use for conversions. Upon successful completion of the initialization all of the ADC control registers will be reset, excluding the memory controls and reference module bits, the given parameters will be set, and the ADC core will be turned on (Note, that the ADC core only draws power during conversions and remains off when not converting).Note that sample/hold signal sources are device dependent. Note that if re-initializing the ADC after starting a conversion with the startConversion() function, the disableConversion() must be called BEFORE this function can be called.

Parameters
baseAddressis the base address of the ADC module.
sampleHoldSignalSourceSelectis the signal that will trigger a sample-and-hold for an input signal to be converted. This parameter is device specific and sources should be found in the device's datasheet. Valid values are:
  • ADC_SAMPLEHOLDSOURCE_SC [Default]
  • ADC_SAMPLEHOLDSOURCE_1
  • ADC_SAMPLEHOLDSOURCE_2
  • ADC_SAMPLEHOLDSOURCE_3
    Modified bits are ADCSHSx of ADCCTL1 register.
clockSourceSelectselects the clock that will be used by the ADC core and the sampling timer if a sampling pulse mode is enabled. Valid values are:
  • ADC_CLOCKSOURCE_ADCOSC [Default] - MODOSC 5 MHz oscillator from the clock system
  • ADC_CLOCKSOURCE_ACLK - The Auxilary Clock
  • ADC_CLOCKSOURCE_SMCLK - The Sub-Master Clock
    Modified bits are ADCSSELx of ADCCTL1 register.
clockSourceDividerselects the amount that the clock will be divided. Valid values are:
  • ADC_CLOCKDIVIDER_1 [Default]
  • ADC_CLOCKDIVIDER_2
  • ADC_CLOCKDIVIDER_3
  • ADC_CLOCKDIVIDER_4
  • ADC_CLOCKDIVIDER_5
  • ADC_CLOCKDIVIDER_6
  • ADC_CLOCKDIVIDER_7
  • ADC_CLOCKDIVIDER_8
  • ADC_CLOCKDIVIDER_12
  • ADC_CLOCKDIVIDER_16
  • ADC_CLOCKDIVIDER_20
  • ADC_CLOCKDIVIDER_24
  • ADC_CLOCKDIVIDER_28
  • ADC_CLOCKDIVIDER_32
  • ADC_CLOCKDIVIDER_64
  • ADC_CLOCKDIVIDER_128
  • ADC_CLOCKDIVIDER_192
  • ADC_CLOCKDIVIDER_256
  • ADC_CLOCKDIVIDER_320
  • ADC_CLOCKDIVIDER_384
  • ADC_CLOCKDIVIDER_448
  • ADC_CLOCKDIVIDER_512
    Modified bits are ADCDIVx of ADCCTL1 register; bits ADCPDIVx of ADCCTL2 register.
Returns
None
uint8_t ADC_isBusy ( uint16_t  baseAddress)

Returns the busy status of the ADC core.

Returns the status of the ADC core if there is a conversion currently taking place.

Parameters
baseAddressis the base address of the ADC module.
Returns
ADC_BUSY or ADC_NOTBUSY dependent if there is a conversion currently taking place. Return one of the following:
  • ADC_NOTBUSY
  • ADC_BUSY
void ADC_setDataReadBackFormat ( uint16_t  baseAddress,
uint16_t  readBackFormat 
)

Use to set the read-back format of the converted data.

Sets the format of the converted data: how it will be stored into the memory buffer, and how it should be read back. The format can be set as right-justified (default), which indicates that the number will be unsigned, or left-justified, which indicates that the number will be signed in 2's complement format. This change affects all memory buffers for subsequent conversions.

Parameters
baseAddressis the base address of the ADC module.
readBackFormatis the specified format to store the conversions in the memory buffer. Valid values are:
  • ADC_UNSIGNED_BINARY [Default]
  • ADC_SIGNED_2SCOMPLEMENT
    Modified bits are ADCDF of ADCCTL2 register.
Returns
None
void ADC_setReferenceBufferSamplingRate ( uint16_t  baseAddress,
uint16_t  samplingRateSelect 
)

Use to set the reference buffer's sampling rate.

Sets the reference buffer's sampling rate to the selected sampling rate. The default sampling rate is maximum of 200-ksps, and can be reduced to a maximum of 50-ksps to conserve power.

Parameters
baseAddressis the base address of the ADC module.
samplingRateSelectis the specified maximum sampling rate. Valid values are:
  • ADC_MAXSAMPLINGRATE_200KSPS [Default]
  • ADC_MAXSAMPLINGRATE_50KSPS
    Modified bits are ADCSR of ADCCTL2 register.

Modified bits of ADCCTL2 register.

Returns
None
void ADC_setResolution ( uint16_t  baseAddress,
uint8_t  resolutionSelect 
)

Use to change the resolution of the converted data.

This function can be used to change the resolution of the converted data from the default of 12-bits.

Parameters
baseAddressis the base address of the ADC module.
resolutionSelectdetermines the resolution of the converted data. Valid values are:
  • ADC_RESOLUTION_8BIT
  • ADC_RESOLUTION_10BIT [Default]
    Modified bits are ADCRES of ADCCTL2 register.
Returns
None
void ADC_setSampleHoldSignalInversion ( uint16_t  baseAddress,
uint16_t  invertedSignal 
)

Use to invert or un-invert the sample/hold signal.

This function can be used to invert or un-invert the sample/hold signal. Note that if a conversion has been started with the startConversion() function, then a call to disableConversions() is required before this function may be called.

Parameters
baseAddressis the base address of the ADC module.
invertedSignalset if the sample/hold signal should be inverted Valid values are:
  • ADC_NONINVERTEDSIGNAL [Default] - a sample-and-hold of an input signal for conversion will be started on a rising edge of the sample/hold signal.
  • ADC_INVERTEDSIGNAL - a sample-and-hold of an input signal for conversion will be started on a falling edge of the sample/hold signal.
    Modified bits are ADCISSH of ADCCTL1 register.
Returns
None
void ADC_setupSamplingTimer ( uint16_t  baseAddress,
uint16_t  clockCycleHoldCount,
uint16_t  multipleSamplesEnabled 
)

Sets up and enables the Sampling Timer Pulse Mode.

This function sets up the sampling timer pulse mode which allows the sample/hold signal to trigger a sampling timer to sample-and-hold an input signal for a specified number of clock cycles without having to hold the sample/hold signal for the entire period of sampling. Note that if a conversion has been started with the startConversion() function, then a call to disableConversions() is required before this function may be called.

Parameters
baseAddressis the base address of the ADC module.
clockCycleHoldCountsets the amount of clock cycles to sample-and- hold for the memory buffer. Valid values are:
  • ADC_CYCLEHOLD_4_CYCLES [Default]
  • ADC_CYCLEHOLD_8_CYCLES
  • ADC_CYCLEHOLD_16_CYCLES
  • ADC_CYCLEHOLD_32_CYCLES
  • ADC_CYCLEHOLD_64_CYCLES
  • ADC_CYCLEHOLD_96_CYCLES
  • ADC_CYCLEHOLD_128_CYCLES
  • ADC_CYCLEHOLD_192_CYCLES
  • ADC_CYCLEHOLD_256_CYCLES
  • ADC_CYCLEHOLD_384_CYCLES
  • ADC_CYCLEHOLD_512_CYCLES
  • ADC_CYCLEHOLD_768_CYCLES
  • ADC_CYCLEHOLD_1024_CYCLES
    Modified bits are ADCSHTx of ADCCTL0 register.
multipleSamplesEnabledallows multiple conversions to start without a trigger signal from the sample/hold signal Valid values are:
  • ADC_MULTIPLESAMPLESDISABLE - a timer trigger will be needed to start every ADC conversion.
  • ADC_MULTIPLESAMPLESENABLE - during a sequenced and/or repeated conversion mode, after the first conversion, no sample/hold signal is necessary to start subsequent samples.
    Modified bits are ADCMSC of ADCCTL0 register.
Returns
None
void ADC_setWindowComp ( uint16_t  baseAddress,
uint16_t  highThreshold,
uint16_t  lowThreshold 
)

Sets the high and low threshold for the window comparator feature.

Sets the high and low threshold for the window comparator feature. Use the ADCHIIE, ADCINIE, ADCLOIE interrupts to utilize this feature.

Parameters
baseAddressis the base address of the ADC module.
highThresholdis the upper bound that could trip an interrupt for the window comparator.
lowThresholdis the lower bound that could trip on interrupt for the window comparator.

Modified bits of ADCLO register and bits of ADCHI register.

Returns
None
void ADC_startConversion ( uint16_t  baseAddress,
uint8_t  conversionSequenceModeSelect 
)

Enables/Starts an Analog-to-Digital Conversion.

This function enables/starts the conversion process of the ADC. If the sample/hold signal source chosen during initialization was ADCOSC, then the conversion is started immediately, otherwise the chosen sample/hold signal source starts the conversion by a rising edge of the signal. Keep in mind when selecting conversion modes, that for sequenced and/or repeated modes, to keep the sample/hold-and-convert process continuing without a trigger from the sample/hold signal source, the multiple samples must be enabled using the ADC_setupSamplingTimer() function. Also note that when a sequence conversion mode is selected, the first input channel is the one mapped to the memory buffer, the next input channel selected for conversion is one less than the input channel just converted (i.e. A1 comes after A2), until A0 is reached, and if in repeating mode, then the next input channel will again be the one mapped to the memory buffer. Note that after this function is called, the ADC_stopConversions() has to be called to re-initialize the ADC, reconfigure a memory buffer control, enable/disable the sampling timer, or to change the internal reference voltage.

Parameters
baseAddressis the base address of the ADC module.
conversionSequenceModeSelectdetermines the ADC operating mode. Valid values are:
  • ADC_SINGLECHANNEL [Default] - one-time conversion of a single channel into a single memory buffer
  • ADC_SEQOFCHANNELS - one time conversion of multiple channels into the specified starting memory buffer and each subsequent memory buffer up until the conversion is stored in a memory buffer dedicated as the end-of-sequence by the memory's control register
  • ADC_REPEATED_SINGLECHANNEL - repeated conversions of one channel into a single memory buffer
  • ADC_REPEATED_SEQOFCHANNELS - repeated conversions of multiple channels into the specified starting memory buffer and each subsequent memory buffer up until the conversion is stored in a memory buffer dedicated as the end-of-sequence by the memory's control register
    Modified bits are ADCCONSEQx of ADCCTL1 register.
Returns
None

Copyright 2015, Texas Instruments Incorporated