Functions
adc10.c File Reference
#include "driverlib/5xx_6xx/adc10.h"
#include "inc/hw_types.h"
#include "deprecated/CCS/msp430xgeneric.h"
#include "driverlib/5xx_6xx/debug.h"

Functions

unsigned short ADC10_init (unsigned int baseAddress, unsigned int sampleHoldSignalSourceSelect, unsigned char clockSourceSelect, unsigned int clockSourceDivider)
void ADC10_enable (unsigned int baseAddress)
void ADC10_disable (unsigned int baseAddress)
void ADC10_setupSamplingTimer (unsigned int baseAddress, unsigned int clockCycleHoldCount, unsigned short multipleSamplesEnabled)
void ADC10_disableSamplingTimer (unsigned int baseAddress)
void ADC10_memoryConfigure (unsigned int baseAddress, unsigned char inputSourceSelect, unsigned char positiveRefVoltageSourceSelect, unsigned char negativeRefVoltageSourceSelect)
void ADC10_enableInterrupt (unsigned int baseAddress, unsigned char interruptMask)
void ADC10_disableInterrupt (unsigned int baseAddress, unsigned char interruptMask)
void ADC10_clearInterrupt (unsigned int baseAddress, unsigned char interruptFlagMask)
unsigned char ADC10_getInterruptStatus (unsigned int baseAddress, unsigned char interruptFlagMask)
void ADC10_startConversion (unsigned int baseAddress, unsigned char conversionSequenceModeSelect)
void ADC10_disableConversions (unsigned int baseAddress, unsigned short preempt)
int ADC10_getResults (unsigned int baseAddress)
void ADC10_setResolution (unsigned int baseAddress, unsigned char resolutionSelect)
void ADC10_setSampleHoldSignalInversion (unsigned int baseAddress, unsigned int invertedSignal)
void ADC10_setDataReadBackFormat (unsigned int baseAddress, unsigned short readBackFormat)
void ADC10_enableReferenceBurst (unsigned int baseAddress)
void ADC10_disableReferenceBurst (unsigned int baseAddress)
void ADC10_setReferenceBufferSamplingRate (unsigned int baseAddress, unsigned short samplingRateSelect)
void ADC10_setWindowComp (unsigned int baseAddress, unsigned int highThreshold, unsigned int lowThreshold)
unsigned long ADC10_getMemoryAddressForDMA (unsigned int baseAddress)
unsigned short ADC10_isBusy (unsigned int baseAddress)

Function Documentation

unsigned short ADC10_init ( unsigned int  baseAddress,
unsigned int  sampleHoldSignalSourceSelect,
unsigned char  clockSourceSelect,
unsigned int  clockSourceDivider 
)

Initializes the ADC10 Module.

Parameters:
baseAddressis the base address of the ADC10 module.
sampleHoldSignalSourceSelectis the signal that will trigger a sample-and-hold for an input signal to be converted. Valid values are ADC10_SAMPLEHOLDSOURCE_SC ADC10_SAMPLEHOLDSOURCE_1 ADC10_SAMPLEHOLDSOURCE_2 ADC10_SAMPLEHOLDSOURCE_3 This parameter is device specific and sources should be found in the device's datasheet. Modified bits are ADC10SHSx of ADC10CTL1 register.
clockSourceSelectselects the clock that will be used by the ADC10 core and the sampling timer if a sampling pulse mode is enabled. Valid values are ADC10_CLOCKSOURCE_ADC10OSC - MODOSC 5 MHz oscillator from the UCS [Default] ADC10_CLOCKSOURCE_ACLK - The Auxilary Clock ADC10_CLOCKSOURCE_MCLK - The Master Clock ADC10_CLOCKSOURCE_SMCLK - The Sub-Master Clock Modified bits are ADC10SSELx of ADC10CTL1 register.
clockSourceDividerselects the amount that the clock will be divided. Valid values are ADC10_CLOCKDIVIDER_1 [Default] ADC10_CLOCKDIVIDER_2 ADC10_CLOCKDIVIDER_3 ADC10_CLOCKDIVIDER_4 ADC10_CLOCKDIVIDER_5 ADC10_CLOCKDIVIDER_6 ADC10_CLOCKDIVIDER_7 ADC10_CLOCKDIVIDER_8 ADC10_CLOCKDIVIDER_12 ADC10_CLOCKDIVIDER_16 ADC10_CLOCKDIVIDER_20 ADC10_CLOCKDIVIDER_24 ADC10_CLOCKDIVIDER_28 ADC10_CLOCKDIVIDER_32 ADC10_CLOCKDIVIDER_64 ADC10_CLOCKDIVIDER_128 ADC10_CLOCKDIVIDER_192 ADC10_CLOCKDIVIDER_256 ADC10_CLOCKDIVIDER_320 ADC10_CLOCKDIVIDER_384 ADC10_CLOCKDIVIDER_448 ADC10_CLOCKDIVIDER_512 Modified bits are ADC10DIVx of ADC10CTL1 register and ADC10PDIVx of ADC10CTL2 register.

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.

Returns:
STATUS_SUCCESS or STATUS_FAILURE of the initialization process.

References ADC10_CLOCKDIVIDER_512, ADC10_CLOCKSOURCE_SMCLK, ADC10_SAMPLEHOLDSOURCE_3, ASSERT, HWREG, and STATUS_SUCCESS.

void ADC10_enable ( unsigned int  baseAddress)

Enables the ADC10 block.

Parameters:
baseAddressis the base address of the ADC10 module.

This will enable operation of the ADC10 block. Modified bits are ADC10ON of ADC10CTL0 register.

Returns:
None.

References HWREG.

void ADC10_disable ( unsigned int  baseAddress)

Disables the ADC10 block.

Parameters:
baseAddressis the base address of the ADC10 module.

This will disable operation of the ADC10 block. Modified bits are ADC10ON of ADC10CTL0 register.

Returns:
None.

References HWREG.

void ADC10_setupSamplingTimer ( unsigned int  baseAddress,
unsigned int  clockCycleHoldCount,
unsigned short  multipleSamplesEnabled 
)

Sets up and enables the Sampling Timer Pulse Mode.

Parameters:
baseAddressis the base address of the ADC10 module.
clockCycleHoldCountsets the amount of clock cycles to sample-and-hold for the memory buffer. Valid values are ADC10_CYCLEHOLD_4_CYCLES [Default] ADC10_CYCLEHOLD_8_CYCLES ADC10_CYCLEHOLD_16_CYCLES ADC10_CYCLEHOLD_32_CYCLES ADC10_CYCLEHOLD_64_CYCLES ADC10_CYCLEHOLD_96_CYCLES ADC10_CYCLEHOLD_128_CYCLES ADC10_CYCLEHOLD_192_CYCLES ADC10_CYCLEHOLD_256_CYCLES ADC10_CYCLEHOLD_384_CYCLES ADC1 0_CYCLEHOLD_512_CYCLES ADC10_CYCLEHOLD_768_CYCLES ADC10_CYCLEHOLD_1024_CYCLES Modified bits are ADC10SHTx of ADC10CTL0 register.
multipleSamplesEnabledallows multiple conversions to start without a trigger signal from the sample/hold signal Valid values are ADC10_MULTIPLESAMPLESDISABLE - a timer trigger will be needed to start every ADC conversion. ADC10_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 ADC10MSC of ADC10CTL0 register.

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.

Returns:
None

References ADC10_CYCLEHOLD_1024_CYCLES, ASSERT, and HWREG.

void ADC10_disableSamplingTimer ( unsigned int  baseAddress)

Disables Sampling Timer Pulse Mode.

Parameters:
baseAddressis the base address of the ADC10 module.

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.

Returns:
None

References ASSERT, and HWREG.

void ADC10_memoryConfigure ( unsigned int  baseAddress,
unsigned char  inputSourceSelect,
unsigned char  positiveRefVoltageSourceSelect,
unsigned char  negativeRefVoltageSourceSelect 
)

Configures the controls of the selected memory buffer.

Parameters:
baseAddressis the base address of the ADC10 module.
inputSourceSelectis the input that will store the converted data into the specified memory buffer. Valid values are ADC10_INPUT_A0 [Default] ADC10_INPUT_A1 ADC10_INPUT_A2 ADC10_INPUT_A3 ADC10_INPUT_A4 ADC10_INPUT_A5 ADC10_INPUT_A6 ADC10_INPUT_A7 ADC10_INPUT_A8 ADC10_INPUT_A9 ADC10_INPUT_TEMPSENSOR ADC10_INPUT_BATTERYMONITOR ADC10_INPUT_A12 ADC10_INPUT_A13 ADC10_INPUT_A14 ADC10_INPUT_A15 Modified bits are ADC10INCHx of ADC10MCTL0 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 ADC10_VREFPOS_AVCC [Default] ADC10_VREFPOS_EXT ADC10_VREFPOS_INT Modified bits are ADC10SREF of ADC10MCTL0 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 ADC10_VREFPOS_AVSS [Default] ADC10_VREFPOS_EXT Modified bits are ADC10SREF of ADC10CTL0 register.

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.

Returns:
None

References ADC10_INPUT_A15, ADC10_VREFNEG_EXT, ADC10_VREFPOS_INT, ASSERT, HWREG, and HWREGB.

void ADC10_enableInterrupt ( unsigned int  baseAddress,
unsigned char  interruptMask 
)

Enables selected ADC10 interrupt sources.

Parameters:
baseAddressis the base address of the ADC10 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 ADC10OVIE - Interrupts when a new conversion is about to overwrite the previous one ADC10TOVIE - Interrupts when a new conversion is starting befor the previous one has finished ADC10HIIE - Interrups when the input signal has gone above the high threshold of the window comparator ADC10LOIE - Interrupts when the input signal has gone below the low threshold of the low window comparator ADC10INIE - Interrupts when the input signal is in between the high and low thresholds of the window comparator ADC10IE0 - Interrupt for new conversion data in the memory buffer

Enables the indicated ADC10 interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor. Modified registers are ADC10IFG and ADC10IE.

Returns:
None

References HWREG.

void ADC10_disableInterrupt ( unsigned int  baseAddress,
unsigned char  interruptMask 
)

Disables selected ADC10 interrupt sources.

Parameters:
baseAddressis the base address of the ADC10 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 ADC10OVIE - Interrupts when a new conversion is about to overwrite the previous one ADC10TOVIE - Interrupts when a new conversion is starting befor the previous one has finished ADC10HIIE - Interrups when the input signal has gone above the high threshold of the window comparator ADC10LOIE - Interrupts when the input signal has gone below the low threshold of the low window comparator ADC10INIE - Interrupts when the input signal is in between the high and low thresholds of the window comparator ADC10IE0 - Interrupt for new conversion data in the memory buffer

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

Returns:
None

References HWREG.

void ADC10_clearInterrupt ( unsigned int  baseAddress,
unsigned char  interruptFlagMask 
)

Clears ADC10 selected interrupt flags.

Parameters:
baseAddressis the base address of the ADC10 module.
interruptFlagMaskis a bit mask of the interrupt flags to be cleared. Mask Value is the logical OR of any of the following ADC10OVIFG - Interrupt flag for when a new conversion is about to overwrite the previous one ADC10TOVIFG - Interrupt flag for when a new conversion is starting before the previous one has finished ADC10HIIFG - Interrup flag for when the input signal has gone above the high threshold of the window comparator ADC10LOIFG - Interrupt flag for when the input signal has gone below the low threshold of the window comparator ADC10INIFG - Interrupt flag for when the input signal is in between the high and low thresholds of the window comparator ADC10IFG0 - Interrupt flag for new conversion data in the memory buffer

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

Returns:
None

References HWREG.

unsigned char ADC10_getInterruptStatus ( unsigned int  baseAddress,
unsigned char  interruptFlagMask 
)

Returns the status of the selected memory interrupt flags.

Parameters:
baseAddressis the base address of the ADC10 module.
interruptFlagMaskis a bit mask of the interrupt flags status to be returned. Mask Value is the logical OR of any of the following ADC10OVIFG - Interrupt flag for when a new conversion is about to overwrite the previous one ADC10TOVIFG - Interrupt flag for when a new conversion is starting before the previous one has finished ADC10HIIFG - Interrup flag for when the input signal has gone above the high threshold of the window comparator ADC10LOIFG - Interrupt flag for when the input signal has gone below the low threshold of the window comparator ADC10INIFG - Interrupt flag for when the input signal is in between the high and low thresholds of the window comparator ADC10IFG0 - Interrupt flag for new conversion data in the memory buffer

Returns the status of the selected interrupt flags.

Returns:
The current interrupt flag status for the corresponding mask.

References HWREG.

void ADC10_startConversion ( unsigned int  baseAddress,
unsigned char  conversionSequenceModeSelect 
)

Enables/Starts an Analog-to-Digital Conversion.

Parameters:
baseAddressis the base address of the ADC10 module.
conversionSequenceModeSelectdetermines the ADC operating mode. Valid values are ADC10_SINGLECHANNEL - one-time conversion of a single channel into a single memory buffer [Default] ADC10_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 ADC10_REPEATED_SINGLECHANNEL - repeated conversions of one channel into a single memory buffer ADC10_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 ADC10CONSEQx of ADC10CTL1 register.

This function enables/starts the conversion process of the ADC. If the sample/hold signal source chosen during initialization was ADC10OSC, 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 ADC10_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 ADC10_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.

Returns:
None

References ADC10_REPEATED_SEQOFCHANNELS, ASSERT, and HWREG.

void ADC10_disableConversions ( unsigned int  baseAddress,
unsigned short  preempt 
)

Disables the ADC from converting any more signals.

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

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 ADC10_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 ADC10_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. Modified registers are ADC10CTL1 and ADC10CTL0

Returns:
None

References ADC10_PREEMPTCONVERSION, and HWREG.

int ADC10_getResults ( unsigned int  baseAddress)

Returns the raw contents of the specified memory buffer.

Parameters:
baseAddressis the base address of the ADC10 module.

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.

Returns:
A Signed Integer of the contents of the specified memory buffer.

References HWREG.

void ADC10_setResolution ( unsigned int  baseAddress,
unsigned char  resolutionSelect 
)

Use to change the resolution of the converted data.

Parameters:
baseAddressis the base address of the ADC10 module.
resolutionSelectdetermines the resolution of the converted data. Valid values are ADC10_RESOLUTION_8BIT ADC10_RESOLUTION_10BIT [Default] Modified bits are ADC10RES of ADC10CTL2 register.

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

Returns:
None

References ADC10_RESOLUTION_10BIT, ASSERT, and HWREG.

void ADC10_setSampleHoldSignalInversion ( unsigned int  baseAddress,
unsigned int  invertedSignal 
)

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

Parameters:
baseAddressis the base address of the ADC10 module.
invertedSignalset if the sample/hold signal should be inverted Valid values are ADC10_NONINVERTEDSIGNAL - a sample-and-hold of an input signal for conversion will be started on a rising edge of the sample/hold signal. [Default] ADC10_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 ADC10ISSH of ADC10CTL1 register.

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.

Returns:
None

References ASSERT, and HWREG.

void ADC10_setDataReadBackFormat ( unsigned int  baseAddress,
unsigned short  readBackFormat 
)

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

Parameters:
baseAddressis the base address of the ADC10 module.
readBackFormatis the specified format to store the conversions in the memory buffer. Valid values are ADC10_UNSIGNED_BINARY [Default] ADC10_SIGNED_2SCOMPLEMENT Modified bits are ADC10DF of ADC10CTL2 register.

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.

Returns:
None

References ADC10_SIGNED_2SCOMPLEMENT, ASSERT, and HWREG.

void ADC10_enableReferenceBurst ( unsigned int  baseAddress)

Enables the reference buffer's burst ability.

Parameters:
baseAddressis the base address of the ADC10 module.

Enables the reference buffer's burst ability, allowing the reference buffer to turn off while the ADC is not converting, and automatically turning on when the ADC needs the generated reference voltage for a conversion.

Modified bits are ADC10REFBURST of ADC10CTL2 register.

Returns:
None

References HWREG.

void ADC10_disableReferenceBurst ( unsigned int  baseAddress)

Disables the reference buffer's burst ability.

Parameters:
baseAddressis the base address of the ADC10 module.

Disables the reference buffer's burst ability, forcing the reference buffer to remain on continuously.

Modified bits are ADC10REFBURST of ADC10CTL2 register.

Returns:
NONE

References HWREG.

void ADC10_setReferenceBufferSamplingRate ( unsigned int  baseAddress,
unsigned short  samplingRateSelect 
)

Use to set the reference buffer's sampling rate.

Parameters:
baseAddressis the base address of the ADC10 module.
samplingRateSelectis the specified maximum sampling rate. Valid values are ADC10_MAXSAMPLINGRATE_200KSPS [Default] ADC10_MAXSAMPLINGRATE_50KSPS Modified bits are ADC10SR of ADC10CTL2 register.

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.

Modified regsiters are ADC10CTL2.

Returns:
None

References ADC10_MAXSAMPLINGRATE_50KSPS, ASSERT, and HWREG.

void ADC10_setWindowComp ( unsigned int  baseAddress,
unsigned int  highThreshold,
unsigned int  lowThreshold 
)

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

Parameters:
baseAddressis the base address of the ADC10 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.

Sets the high and low threshold for the window comparator feature. Use the ADC10HIIE, ADC10INIE, ADC10LOIE interrupts to utilize this feature.

Modified regsiters are ADC10HI and ADC10LO.

Returns:
None

References HWREG.

unsigned long ADC10_getMemoryAddressForDMA ( unsigned int  baseAddress)

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

Parameters:
baseAddressis the base address of the ADC10 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.

Returns:
None
unsigned short ADC10_isBusy ( unsigned int  baseAddress)

Returns the busy status of the ADC10 core.

Parameters:
baseAddressis the base address of the ADC10 module.

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

Returns:
ADC10_BUSY or ADC10_NOTBUSY dependent if there is a conversion currently taking place.

References ADC10_BUSY, ADC10_NOTBUSY, and HWREG.


Copyright 2012, Texas Instruments Incorporated