ADC Module¶
The analog to digital converter (ADC) API provides a set of functions for programming the digital circuits of the converter, referred to as the ADC wrapper. Functions are provided to configure the conversions, read the data conversion result registers, configure the post-processing blocks (PPB), and set up and handle interrupts and events.
-
group
adc_api
Defines
-
ADC_NUM_INTERRUPTS
4U¶
-
ADC_SOCxCTL_OFFSET_BASE
ADC_O_SOC0CTL¶
-
ADC_RESULTx_OFFSET_BASE
ADC_O_RESULT0¶
-
ADC_INTSELxNy_OFFSET_BASE
ADC_O_INTSEL1N2¶
-
ADC_PPBxRESULT_OFFSET_BASE
ADC_O_PPB1RESULT¶
-
ADC_PPBxCONFIG_STEP
(ADC_O_PPB2CONFIG - ADC_O_PPB1CONFIG)¶
-
ADC_PPBxTRIPHI_STEP
(ADC_O_PPB2TRIPHI - ADC_O_PPB1TRIPHI)¶
-
ADC_PPBxTRIPLO_STEP
(ADC_O_PPB2TRIPLO - ADC_O_PPB1TRIPLO)¶
-
ADC_PPBxSTAMP_STEP
(ADC_O_PPB2STAMP - ADC_O_PPB1STAMP)¶
-
ADC_PPBxOFFCAL_STEP
(ADC_O_PPB2OFFCAL - ADC_O_PPB1OFFCAL)¶
-
ADC_PPBxOFFREF_STEP
(ADC_O_PPB2OFFREF - ADC_O_PPB1OFFREF)¶
-
ADC_PPBTRIP_MASK
((uint32_t)ADC_PPB1TRIPHI_LIMITHI_M| \
(uint32_t)
ADC_PPB1TRIPHI_HSIGN)¶
-
ADC_EXT_REF_TSSLOPE
(*(int16_t *)((uintptr_t)0x701B2))¶
-
ADC_EXT_REF_TSOFFSET
(*(int16_t *)((uintptr_t)0x701B3))¶
-
ADC_EVT_TRIPHI
0x0001U¶ Trip High Event.
-
ADC_EVT_TRIPLO
0x0002U¶ Trip Low Event.
-
ADC_EVT_ZERO
0x0004U¶ Zero Crossing Event.
-
ADC_FORCE_SOC0
0x0001U¶ SW trigger ADC SOC 0.
-
ADC_FORCE_SOC1
0x0002U¶ SW trigger ADC SOC 1.
-
ADC_FORCE_SOC2
0x0004U¶ SW trigger ADC SOC 2.
-
ADC_FORCE_SOC3
0x0008U¶ SW trigger ADC SOC 3.
-
ADC_FORCE_SOC4
0x0010U¶ SW trigger ADC SOC 4.
-
ADC_FORCE_SOC5
0x0020U¶ SW trigger ADC SOC 5.
-
ADC_FORCE_SOC6
0x0040U¶ SW trigger ADC SOC 6.
-
ADC_FORCE_SOC7
0x0080U¶ SW trigger ADC SOC 7.
-
ADC_FORCE_SOC8
0x0100U¶ SW trigger ADC SOC 8.
-
ADC_FORCE_SOC9
0x0200U¶ SW trigger ADC SOC 9.
-
ADC_FORCE_SOC10
0x0400U¶ SW trigger ADC SOC 10.
-
ADC_FORCE_SOC11
0x0800U¶ SW trigger ADC SOC 11.
-
ADC_FORCE_SOC12
0x1000U¶ SW trigger ADC SOC 12.
-
ADC_FORCE_SOC13
0x2000U¶ SW trigger ADC SOC 13.
-
ADC_FORCE_SOC14
0x4000U¶ SW trigger ADC SOC 14.
-
ADC_FORCE_SOC15
0x8000U¶ SW trigger ADC SOC 15.
Enums
-
enum
ADC_ClkPrescale
¶ Values that can be passed to ADC_setPrescaler() as the clkPrescale parameter.
Values:
-
enumerator
ADC_CLK_DIV_1_0
= 0¶ ADCCLK = (input clock) / 1.0.
-
enumerator
ADC_CLK_DIV_2_0
= 2¶ ADCCLK = (input clock) / 2.0.
-
enumerator
ADC_CLK_DIV_3_0
= 4¶ ADCCLK = (input clock) / 3.0.
-
enumerator
ADC_CLK_DIV_4_0
= 6¶ ADCCLK = (input clock) / 4.0.
-
enumerator
ADC_CLK_DIV_5_0
= 8¶ ADCCLK = (input clock) / 5.0.
-
enumerator
ADC_CLK_DIV_6_0
= 10¶ ADCCLK = (input clock) / 6.0.
-
enumerator
ADC_CLK_DIV_7_0
= 12¶ ADCCLK = (input clock) / 7.0.
-
enumerator
ADC_CLK_DIV_8_0
= 14¶ ADCCLK = (input clock) / 8.0.
-
enumerator
-
enum
ADC_Trigger
¶ Values that can be passed to ADC_setupSOC() as the trigger parameter to specify the event that will trigger a conversion to start. It is also used with ADC_setBurstModeConfig().
Values:
-
enumerator
ADC_TRIGGER_SW_ONLY
= 0¶ Software only.
-
enumerator
ADC_TRIGGER_CPU1_TINT0
= 1¶ CPU1 Timer 0, TINT0.
-
enumerator
ADC_TRIGGER_CPU1_TINT1
= 2¶ CPU1 Timer 1, TINT1.
-
enumerator
ADC_TRIGGER_CPU1_TINT2
= 3¶ CPU1 Timer 2, TINT2.
-
enumerator
ADC_TRIGGER_GPIO
= 4¶ GPIO, ADCEXTSOC.
-
enumerator
ADC_TRIGGER_EPWM1_SOCA
= 5¶ ePWM1, ADCSOCA
-
enumerator
ADC_TRIGGER_EPWM1_SOCB
= 6¶ ePWM1, ADCSOCB
-
enumerator
ADC_TRIGGER_EPWM2_SOCA
= 7¶ ePWM2, ADCSOCA
-
enumerator
ADC_TRIGGER_EPWM2_SOCB
= 8¶ ePWM2, ADCSOCB
-
enumerator
ADC_TRIGGER_EPWM3_SOCA
= 9¶ ePWM3, ADCSOCA
-
enumerator
ADC_TRIGGER_EPWM3_SOCB
= 10¶ ePWM3, ADCSOCB
-
enumerator
ADC_TRIGGER_EPWM4_SOCA
= 11¶ ePWM4, ADCSOCA
-
enumerator
ADC_TRIGGER_EPWM4_SOCB
= 12¶ ePWM4, ADCSOCB
-
enumerator
ADC_TRIGGER_EPWM5_SOCA
= 13¶ ePWM5, ADCSOCA
-
enumerator
ADC_TRIGGER_EPWM5_SOCB
= 14¶ ePWM5, ADCSOCB
-
enumerator
ADC_TRIGGER_EPWM6_SOCA
= 15¶ ePWM6, ADCSOCA
-
enumerator
ADC_TRIGGER_EPWM6_SOCB
= 16¶ ePWM6, ADCSOCB
-
enumerator
ADC_TRIGGER_EPWM7_SOCA
= 17¶ ePWM7, ADCSOCA
-
enumerator
ADC_TRIGGER_EPWM7_SOCB
= 18¶ ePWM7, ADCSOCB
-
enumerator
-
enum
ADC_Channel
¶ Values that can be passed to ADC_setupSOC() as the channel parameter. This is the input pin on which the signal to be converted is located.
Values:
-
enumerator
ADC_CH_ADCIN0
¶ ADCIN0 is converted.
-
enumerator
ADC_CH_ADCIN1
¶ ADCIN1 is converted.
-
enumerator
ADC_CH_ADCIN2
¶ ADCIN2 is converted.
-
enumerator
ADC_CH_ADCIN3
¶ ADCIN3 is converted.
-
enumerator
ADC_CH_ADCIN4
¶ ADCIN4 is converted.
-
enumerator
ADC_CH_ADCIN5
¶ ADCIN5 is converted.
-
enumerator
ADC_CH_ADCIN6
¶ ADCIN6 is converted.
-
enumerator
ADC_CH_ADCIN7
¶ ADCIN7 is converted.
-
enumerator
ADC_CH_ADCIN8
¶ ADCIN8 is converted.
-
enumerator
ADC_CH_ADCIN9
¶ ADCIN9 is converted.
-
enumerator
ADC_CH_ADCIN10
¶ ADCIN10 is converted.
-
enumerator
ADC_CH_ADCIN11
¶ ADCIN11 is converted.
-
enumerator
ADC_CH_ADCIN12
¶ ADCIN12 is converted.
-
enumerator
ADC_CH_ADCIN13
¶ ADCIN13 is converted.
-
enumerator
ADC_CH_ADCIN14
¶ ADCIN14 is converted.
-
enumerator
ADC_CH_ADCIN15
¶ ADCIN15 is converted.
-
enumerator
-
enum
ADC_PulseMode
¶ Values that can be passed to ADC_setInterruptPulseMode() as the pulseMode parameter.
Values:
-
enumerator
ADC_PULSE_END_OF_ACQ_WIN
= 0x00¶ Occurs at the end of the acquisition window.
-
enumerator
ADC_PULSE_END_OF_CONV
= 0x04¶ Occurs at the end of the conversion.
-
enumerator
-
enum
ADC_IntNumber
¶ Values that can be passed to ADC_enableInterrupt(), ADC_disableInterrupt(), and ADC_getInterruptStatus() as the adcIntNum parameter.
Values:
-
enumerator
ADC_INT_NUMBER1
¶ ADCINT1 Interrupt.
-
enumerator
ADC_INT_NUMBER2
¶ ADCINT2 Interrupt.
-
enumerator
ADC_INT_NUMBER3
¶ ADCINT3 Interrupt.
-
enumerator
ADC_INT_NUMBER4
¶ ADCINT4 Interrupt.
-
enumerator
-
enum
ADC_PPBNumber
¶ Values that can be passed in as the ppbNumber parameter for several functions.
Values:
-
enumerator
ADC_PPB_NUMBER1
¶ Post-processing block 1.
-
enumerator
ADC_PPB_NUMBER2
¶ Post-processing block 2.
-
enumerator
ADC_PPB_NUMBER3
¶ Post-processing block 3.
-
enumerator
ADC_PPB_NUMBER4
¶ Post-processing block 4.
-
enumerator
-
enum
ADC_SOCNumber
¶ Values that can be passed in as the socNumber parameter for several functions. This value identifies the start-of-conversion (SOC) that a function is configuring or accessing. Note that in some cases (for example, ADC_setInterruptSource()) socNumber is used to refer to the corresponding end-of-conversion (EOC).
Values:
-
enumerator
ADC_SOC_NUMBER0
¶ SOC/EOC number 0.
-
enumerator
ADC_SOC_NUMBER1
¶ SOC/EOC number 1.
-
enumerator
ADC_SOC_NUMBER2
¶ SOC/EOC number 2.
-
enumerator
ADC_SOC_NUMBER3
¶ SOC/EOC number 3.
-
enumerator
ADC_SOC_NUMBER4
¶ SOC/EOC number 4.
-
enumerator
ADC_SOC_NUMBER5
¶ SOC/EOC number 5.
-
enumerator
ADC_SOC_NUMBER6
¶ SOC/EOC number 6.
-
enumerator
ADC_SOC_NUMBER7
¶ SOC/EOC number 7.
-
enumerator
ADC_SOC_NUMBER8
¶ SOC/EOC number 8.
-
enumerator
ADC_SOC_NUMBER9
¶ SOC/EOC number 9.
-
enumerator
ADC_SOC_NUMBER10
¶ SOC/EOC number 10.
-
enumerator
ADC_SOC_NUMBER11
¶ SOC/EOC number 11.
-
enumerator
ADC_SOC_NUMBER12
¶ SOC/EOC number 12.
-
enumerator
ADC_SOC_NUMBER13
¶ SOC/EOC number 13.
-
enumerator
ADC_SOC_NUMBER14
¶ SOC/EOC number 14.
-
enumerator
ADC_SOC_NUMBER15
¶ SOC/EOC number 15.
-
enumerator
-
enum
ADC_IntSOCTrigger
¶ Values that can be passed in as the trigger parameter for the ADC_setInterruptSOCTrigger() function.
Values:
-
enumerator
ADC_INT_SOC_TRIGGER_NONE
¶ No ADCINT will trigger the SOC.
-
enumerator
ADC_INT_SOC_TRIGGER_ADCINT1
¶ ADCINT1 will trigger the SOC.
-
enumerator
ADC_INT_SOC_TRIGGER_ADCINT2
¶ ADCINT2 will trigger the SOC.
-
enumerator
-
enum
ADC_PriorityMode
¶ Values that can be passed to ADC_setSOCPriority() as the priMode parameter.
Values:
-
enumerator
ADC_PRI_ALL_ROUND_ROBIN
¶ Round robin mode is used for all.
-
enumerator
ADC_PRI_SOC0_HIPRI
¶ SOC 0 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC1_HIPRI
¶ SOC 0-1 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC2_HIPRI
¶ SOC 0-2 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC3_HIPRI
¶ SOC 0-3 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC4_HIPRI
¶ SOC 0-4 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC5_HIPRI
¶ SOC 0-5 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC6_HIPRI
¶ SOC 0-6 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC7_HIPRI
¶ SOC 0-7 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC8_HIPRI
¶ SOC 0-8 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC9_HIPRI
¶ SOC 0-9 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC10_HIPRI
¶ SOC 0-10 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC11_HIPRI
¶ SOC 0-11 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC12_HIPRI
¶ SOC 0-12 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC13_HIPRI
¶ SOC 0-13 hi pri, others in round robin.
-
enumerator
ADC_PRI_THRU_SOC14_HIPRI
¶ SOC 0-14 hi pri, SOC15 in round robin.
-
enumerator
ADC_PRI_ALL_HIPRI
¶ All priorities based on SOC number.
-
enumerator
-
enum
ADC_ReferenceMode
¶ Values that can be passed to ADC_getTemperatureC(), ADC_getTemperatureK(), and ADC_setVREF() as the refMode parameter.
Values:
-
enumerator
ADC_REFERENCE_INTERNAL
¶
-
enumerator
ADC_REFERENCE_EXTERNAL
¶
-
enumerator
-
enum
ADC_ReferenceVoltage
¶ Values that can be passed to ADC_setVREF() as the refVoltage parameter.
Values:
-
enumerator
ADC_REFERENCE_3_3V
¶
-
enumerator
ADC_REFERENCE_2_5V
¶
-
enumerator
-
enum
ADC_OSDetectMode
¶ Values that can be passed to ADC_configOSDetectMode() as the modeVal parameter.
Values:
-
enumerator
ADC_OSDETECT_MODE_DISABLED
= 0x0¶ Open/Shorts detection cir- cuit(O/S DC) is disabled
-
enumerator
ADC_OSDETECT_MODE_VSSA
= 0x1¶ O/S DC is enabled at zero scale
-
enumerator
ADC_OSDETECT_MODE_VDDA
= 0x2¶ O/S DC is enabled at full scale
-
enumerator
ADC_OSDETECT_MODE_5BY12_VDDA
= 0x3¶ O/S DC is enabled at 5/12 scale
-
enumerator
ADC_OSDETECT_MODE_7BY12_VDDA
= 0x4¶ O/S DC is enabled at 7/12 scale
-
enumerator
ADC_OSDETECT_MODE_5K_PULLDOWN_TO_VSSA
= 0x5¶ O/S DC is enabled at 5K pulldown to VSSA
-
enumerator
ADC_OSDETECT_MODE_5K_PULLUP_TO_VDDA
= 0x6¶ O/S DC is enabled at 5K pullup to VDDA
-
enumerator
ADC_OSDETECT_MODE_7K_PULLDOWN_TO_VSSA
= 0x7¶ O/S DC is enabled at 7K pulldown to VSSA
-
enumerator
Functions
-
void
ADC_setPrescaler
(uint32_t base, ADC_ClkPrescale clkPrescale)¶ Configures the analog-to-digital converter module prescaler.
This function configures the ADC module’s ADCCLK.
- Parameters
base
: is the base address of the ADC module.clkPrescale
: is the ADC clock prescaler.
The clkPrescale parameter specifies the value by which the input clock is divided to make the ADCCLK. The clkPrescale value can be specified with any of the following enum values: ADC_CLK_DIV_1_0, ADC_CLK_DIV_2_0, ADC_CLK_DIV_3_0, …, ADC_CLK_DIV_6_0, ADC_CLK_DIV_7_0, or ADC_CLK_DIV_8_0.
- Return
None.
-
void
ADC_setupSOC
(uint32_t base, ADC_SOCNumber socNumber, ADC_Trigger trigger, ADC_Channel channel, uint32_t sampleWindow)¶ Configures a start-of-conversion (SOC) in the ADC.
This function configures the a start-of-conversion (SOC) in the ADC module.
- Parameters
base
: is the base address of the ADC module.socNumber
: is the number of the start-of-conversion.trigger
: the source that will cause the SOC.channel
: is the number associated with the input signal.sampleWindow
: is the acquisition window duration.
The socNumber number is a value ADC_SOC_NUMBERX where X is a number from 0 to 15 specifying which SOC is to be configured on the ADC module specified by base.
The trigger specifies the event that causes the SOC such as software, a timer interrupt, an ePWM event, or an ADC interrupt. It should be a value in the format of ADC_TRIGGER_XXXX where XXXX is the event such as ADC_TRIGGER_SW_ONLY, ADC_TRIGGER_CPU1_TINT0, ADC_TRIGGER_GPIO, ADC_TRIGGER_EPWM1_SOCA, and so on.
The channel parameter specifies the channel to be converted. In single-ended mode this is a single pin given by ADC_CH_ADCINx where x is the number identifying the pin between 0 and 15 inclusive.
The sampleWindow parameter is the acquisition window duration in SYSCLK cycles. It should be a value between 1 and 512 cycles inclusive. The selected duration must be at least as long as one ADCCLK cycle. Also, the datasheet will specify a minimum window duration requirement in nanoseconds.
- Return
None.
-
void
ADC_setInterruptSOCTrigger
(uint32_t base, ADC_SOCNumber socNumber, ADC_IntSOCTrigger trigger)¶ Configures the interrupt SOC trigger of an SOC.
This function configures the interrupt start-of-conversion trigger in the ADC module.
- Parameters
base
: is the base address of the ADC module.socNumber
: is the number of the start-of-conversion.trigger
: the interrupt source that will cause the SOC.
The socNumber number is a value ADC_SOC_NUMBERX where X is a number from 0 to 15 specifying which SOC is to be configured on the ADC module specified by base.
The trigger specifies the interrupt that causes a start of conversion or none. It should be one of the following values.
ADC_INT_SOC_TRIGGER_NONE
ADC_INT_SOC_TRIGGER_ADCINT1
ADC_INT_SOC_TRIGGER_ADCINT2
This functionality is useful for creating continuous conversions.
- Return
None.
-
void
ADC_setInterruptPulseMode
(uint32_t base, ADC_PulseMode pulseMode)¶ Sets the timing of the end-of-conversion pulse
This function configures the end-of-conversion (EOC) pulse generated by ADC. This pulse will be generated either at the end of the acquisition window plus a number of SYSCLK cycles configured by
ADC_setInterruptCycleOffset() (pass ADC_PULSE_END_OF_ACQ_WIN into pulseMode) or at the end of the voltage conversion, one cycle prior to the ADC result latching into it’s result register (pass ADC_PULSE_END_OF_CONV into pulseMode).- Parameters
base
: is the base address of the ADC module.pulseMode
: is the generation mode of the EOC pulse.
- Return
None.
-
void
ADC_setInterruptCycleOffset
(uint32_t base, uint16_t cycleOffset)¶ Sets the timing of early interrupt generation.
This function configures cycle offset between the negative edge of a sample pulse and an early interrupt pulse being generated. This number of cycles is specified with the
cycleOffset parameter.- Parameters
base
: is the base address of the ADC module.cycleOffset
: is the cycles from an SOC falling edge to an early interrupt pulse.
This function only applies when early interrupt generation is enabled. That means the ADC_setInterruptPulseMode() function pulseMode parameter is configured as ADC_PULSE_END_OF_ACQ_WIN.
- Return
None.
-
void
ADC_enableConverter
(uint32_t base)¶ Powers up the analog-to-digital converter core.
This function powers up the analog circuitry inside the analog core.
- Parameters
base
: is the base address of the ADC module.
- Note
Allow at least a 500us delay before sampling after calling this API. If you enable multiple ADCs, you can delay after they all have begun powering up.
- Return
None.
-
void
ADC_disableConverter
(uint32_t base)¶ Powers down the analog-to-digital converter module.
This function powers down the analog circuitry inside the analog core.
- Parameters
base
: is the base address of the ADC module.
- Return
None.
-
void
ADC_forceSOC
(uint32_t base, ADC_SOCNumber socNumber)¶ Forces a SOC flag to a 1 in the analog-to-digital converter.
This function forces the SOC flag associated with the SOC specified by
socNumber. This initiates a conversion once that SOC is given priority. This software trigger can be used whether or not the SOC has been configured to accept some other specific trigger.- Parameters
base
: is the base address of the ADC module.socNumber
: is the number of the start-of-conversion.
- Return
None.
-
void
ADC_forceMultipleSOC
(uint32_t base, uint16_t socMask)¶ Forces multiple SOC flags to 1 in the analog-to-digital converter.
This function forces the SOCFRC1 flags associated with the SOCs specified by
socMask. This initiates a conversion once the desired SOCs are given priority. This software trigger can be used whether or not the SOC has been configured to accept some other specific trigger. Valid values for socMask parameter can be any of the individual ADC_FORCE_SOCx values or any of their OR’d combination to trigger multiple SOCs.- Parameters
base
: is the base address of the ADC module.socMask
: is the SOCs to be forced through software
- Note
To trigger SOC0, SOC1 and SOC2, value (ADC_FORCE_SOC0 | ADC_FORCE_SOC1 | ADC_FORCE_SOC2) should be passed as socMask.
- Return
None.
-
bool
ADC_getInterruptStatus
(uint32_t base, ADC_IntNumber adcIntNum)¶ Gets the current ADC interrupt status.
This function returns the interrupt status for the analog-to-digital converter.
- Parameters
base
: is the base address of the ADC module.adcIntNum
: is interrupt number within the ADC wrapper.
adcIntNum takes a one of the values ADC_INT_NUMBER1, ADC_INT_NUMBER2, ADC_INT_NUMBER3, or ADC_INT_NUMBER4 to express which of the four interrupts of the ADC module should be cleared.
- Return
true if the interrupt flag for the specified interrupt number is set and false if it is not.
-
void
ADC_clearInterruptStatus
(uint32_t base, ADC_IntNumber adcIntNum)¶ Clears ADC interrupt sources.
This function clears the specified ADC interrupt sources so that they no longer assert. If not in continuous mode, this function must be called before any further interrupt pulses may occur.
- Parameters
base
: is the base address of the ADC module.adcIntNum
: is interrupt number within the ADC wrapper.
adcIntNum takes a one of the values ADC_INT_NUMBER1, ADC_INT_NUMBER2, ADC_INT_NUMBER3, or ADC_INT_NUMBER4 to express which of the four interrupts of the ADC module should be cleared.
- Return
None.
-
bool
ADC_getInterruptOverflowStatus
(uint32_t base, ADC_IntNumber adcIntNum)¶ Gets the current ADC interrupt overflow status.
This function returns the interrupt overflow status for the analog-to-digital converter. An overflow condition is generated irrespective of the continuous mode.
- Parameters
base
: is the base address of the ADC module.adcIntNum
: is interrupt number within the ADC wrapper.
adcIntNum takes a one of the values ADC_INT_NUMBER1, ADC_INT_NUMBER2, ADC_INT_NUMBER3, or ADC_INT_NUMBER4 to express which of the four interrupts of the ADC module should be cleared.
- Return
true if the interrupt overflow flag for the specified interrupt number is set and false if it is not.
-
void
ADC_clearInterruptOverflowStatus
(uint32_t base, ADC_IntNumber adcIntNum)¶ Clears ADC interrupt overflow sources.
This function clears the specified ADC interrupt overflow sources so that they no longer assert. If software tries to clear the overflow in the same cycle that hardware tries to set the overflow, then hardware has priority.
- Parameters
base
: is the base address of the ADC module.adcIntNum
: is interrupt number within the ADC wrapper.
adcIntNum takes a one of the values ADC_INT_NUMBER1, ADC_INT_NUMBER2, ADC_INT_NUMBER3, or ADC_INT_NUMBER4 to express which of the four interrupts of the ADC module should be cleared.
- Return
None.
-
uint16_t
ADC_readResult
(uint32_t resultBase, ADC_SOCNumber socNumber)¶ Reads the conversion result.
This function returns the conversion result that corresponds to the base address passed into
resultBase and the SOC passed into socNumber.- Parameters
resultBase
: is the base address of the ADC results.socNumber
: is the number of the start-of-conversion.
The socNumber number is a value ADC_SOC_NUMBERX where X is a number from 0 to 15 specifying which SOC’s result is to be read.
- Note
Take care that you are using a base address for the result registers (ADCxRESULT_BASE) and not a base address for the control registers.
- Return
Returns the conversion result.
-
bool
ADC_isBusy
(uint32_t base)¶ Determines whether the ADC is busy or not.
This function allows the caller to determine whether or not the ADC is busy and can sample another channel.
- Parameters
base
: is the base address of the ADC.
- Return
Returns true if the ADC is sampling or false if all samples are complete.
-
void
ADC_setBurstModeConfig
(uint32_t base, ADC_Trigger trigger, uint16_t burstSize)¶ Set SOC burst mode.
This function configures the burst trigger and burstSize of an ADC module. Burst mode allows a single trigger to walk through the round-robin SOCs one or more at a time. When burst mode is enabled, the trigger selected by the
ADC_setupSOC() API will no longer have an effect on the SOCs in round-robin mode. Instead, the source specified through the trigger parameter will cause a burst of burstSize conversions to occur.- Parameters
base
: is the base address of the ADC.trigger
: the source that will cause the burst conversion sequence.burstSize
: is the number of SOCs converted during a burst sequence.
The trigger parameter takes the same values as the ADC_setupSOC() API The burstSize parameter should be a value between 1 and 16 inclusive.
- Return
None.
-
void
ADC_enableBurstMode
(uint32_t base)¶ Enables SOC burst mode.
This function enables SOC burst mode operation of the ADC. Burst mode allows a single trigger to walk through the round-robin SOCs one or more at a time. When burst mode is enabled, the trigger selected by the
ADC_setupSOC() API will no longer have an effect on the SOCs in round-robin mode. Use ADC_setBurstMode() to configure the burst trigger and size.- Parameters
base
: is the base address of the ADC.
- Return
None.
-
void
ADC_disableBurstMode
(uint32_t base)¶ Disables SOC burst mode.
This function disables SOC burst mode operation of the ADC. SOCs in round-robin mode will be triggered by the trigger configured using the
ADC_setupSOC() API.- Parameters
base
: is the base address of the ADC.
- Return
None.
-
void
ADC_setSOCPriority
(uint32_t base, ADC_PriorityMode priMode)¶ Sets the priority mode of the SOCs.
This function sets the priority mode of the SOCs. There are three main modes that can be passed in the
priMode parameter- Parameters
base
: is the base address of the ADC.priMode
: is the priority mode of the SOCs.
All SOCs are in round-robin mode. This means no SOC has an inherent higher priority over another. This is selected by passing in the value ADC_PRI_ALL_ROUND_ROBIN.
All priorities are in high priority mode. This means that the priority of the SOC is determined by its SOC number. This option is selected by passing in the value ADC_PRI_ALL_HIPRI.
A range of SOCs are assigned high priority, with all others in round robin mode. High priority mode means that an SOC with high priority will interrupt the round robin wheel and insert itself as the next conversion. Passing in the value ADC_PRI_SOC0_HIPRI will make SOC0 highest priority, ADC_PRI_THRU_SOC1_HIPRI will put SOC0 and SOC 1 in high priority, and so on up to ADC_PRI_THRU_SOC14_HIPRI where SOCs 0 through 14 are in high priority.
- Return
None.
-
void
ADC_configOSDetectMode
(uint32_t base, ADC_OSDetectMode modeVal)¶ Configures Open/Shorts Detection Circuit Mode.
This function configures the open/shorts detection circuit mode of the ADC.
- Parameters
base
: is the base address of the ADC.modeVal
: is the desired open/shorts detection circuit mode.
- Return
None.
-
void
ADC_setupPPB
(uint32_t base, ADC_PPBNumber ppbNumber, ADC_SOCNumber socNumber)¶ Configures a post-processing block (PPB) in the ADC.
This function associates a post-processing block with a SOC.
- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.socNumber
: is the number of the start-of-conversion.
The ppbNumber is a value ADC_PPB_NUMBERX where X is a value from 1 to 4 inclusive that identifies a PPB to be configured. The socNumber number is a value ADC_SOC_NUMBERX where X is a number from 0 to 15 specifying which SOC is to be configured on the ADC module specified by base.
- Note
You can have more that one PPB associated with the same SOC, but a PPB can only be configured to correspond to one SOC at a time. Also note that when you have multiple PPBs for the same SOC, the calibration offset that actually gets applied will be that of the PPB with the highest number. Since SOC0 is the default for all PPBs, look out for unintentional overwriting of a lower numbered PPB’s offset.
- Return
None.
-
void
ADC_enablePPBEvent
(uint32_t base, ADC_PPBNumber ppbNumber, uint16_t evtFlags)¶ Enables individual ADC PPB event sources.
This function enables the indicated ADC PPB event sources. This will allow the specified events to propagate through the X-BAR to a pin or to an ePWM module. The
evtFlags parameter can be any of the ADC_EVT_TRIPHI, ADC_EVT_TRIPLO, or ADC_EVT_ZERO values.- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.evtFlags
: is a bit mask of the event sources to be enabled.
- Return
None.
-
void
ADC_disablePPBEvent
(uint32_t base, ADC_PPBNumber ppbNumber, uint16_t evtFlags)¶ Disables individual ADC PPB event sources.
This function disables the indicated ADC PPB event sources. This will stop the specified events from propagating through the X-BAR to other modules. The
evtFlags parameter can be any of the ADC_EVT_TRIPHI, ADC_EVT_TRIPLO, or ADC_EVT_ZERO values.- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.evtFlags
: is a bit mask of the event sources to be enabled.
- Return
None.
-
void
ADC_enablePPBEventInterrupt
(uint32_t base, ADC_PPBNumber ppbNumber, uint16_t intFlags)¶ Enables individual ADC PPB event interrupt sources.
This function enables the indicated ADC PPB interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt. Disabled sources have no effect on the processor. The
intFlags parameter can be any of the ADC_EVT_TRIPHI, ADC_EVT_TRIPLO, or ADC_EVT_ZERO values.- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.intFlags
: is a bit mask of the interrupt sources to be enabled.
- Return
None.
-
void
ADC_disablePPBEventInterrupt
(uint32_t base, ADC_PPBNumber ppbNumber, uint16_t intFlags)¶ Disables individual ADC PPB event interrupt sources.
This function disables the indicated ADC PPB interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt. Disabled sources have no effect on the processor. The
intFlags parameter can be any of the ADC_EVT_TRIPHI, ADC_EVT_TRIPLO, or ADC_EVT_ZERO values.- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.intFlags
: is a bit mask of the interrupt source to be disabled.
- Return
None.
-
uint16_t
ADC_getPPBEventStatus
(uint32_t base, ADC_PPBNumber ppbNumber)¶ Gets the current ADC event status.
This function returns the event status for the analog-to-digital converter.
- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.
- Return
Returns the current event status, enumerated as a bit field of ADC_EVT_TRIPHI, ADC_EVT_TRIPLO, and ADC_EVT_ZERO.
-
void
ADC_clearPPBEventStatus
(uint32_t base, ADC_PPBNumber ppbNumber, uint16_t evtFlags)¶ Clears ADC event flags.
This function clears the indicated ADC PPB event flags. After an event occurs this function must be called to allow additional events to be produced. The
evtFlags parameter can be any of the ADC_EVT_TRIPHI, ADC_EVT_TRIPLO, or ADC_EVT_ZERO values.- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.evtFlags
: is a bit mask of the event source to be cleared.
- Return
None.
-
void
ADC_enablePPBEventCBCClear
(uint32_t base, ADC_PPBNumber ppbNumber)¶ Enables cycle-by-cycle clear of ADC PPB event flags.
This function enables the automatic cycle-by-cycle clear of ADC PPB event flags. When enabled, the desired PPB event flags are automatically cleared on the next PPBxRESULT load, unless a set condition is also occurring at the same time, in which case the set takes precedence.
- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.
- Return
None.
-
void
ADC_disablePPBEventCBCClear
(uint32_t base, ADC_PPBNumber ppbNumber)¶ Disables cycle-by-cycle clear of ADC PPB event flags.
This function disables the cycle-by-cycle clear of ADC PPB event flags. When disabled, the desired PPB event flags are to be cleared explicitly in software inorder to generate next set of interrupts/events.
- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.
- Return
None.
-
int32_t
ADC_readPPBResult
(uint32_t resultBase, ADC_PPBNumber ppbNumber)¶ Reads the processed conversion result from the PPB.
This function returns the processed conversion result that corresponds to the base address passed into
resultBase and the PPB passed into ppbNumber.- Parameters
resultBase
: is the base address of the ADC results.ppbNumber
: is the number of the post-processing block.
- Note
Take care that you are using a base address for the result registers (ADCxRESULT_BASE) and not a base address for the control registers.
- Return
Returns the signed 32-bit conversion result.
-
uint16_t
ADC_getPPBDelayTimeStamp
(uint32_t base, ADC_PPBNumber ppbNumber)¶ Reads sample delay time stamp from a PPB.
This function returns the sample delay time stamp. This delay is the number of system clock cycles between the SOC being triggered and when it began converting.
- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.
- Return
Returns the delay time stamp.
-
void
ADC_setPPBCalibrationOffset
(uint32_t base, ADC_PPBNumber ppbNumber, int16_t offset)¶ Sets the post processing block offset correction.
This function sets the PPB offset correction value. This value can be used to digitally remove any system-level offset inherent in the ADCIN circuit before it is stored in the appropriate result register. The
offset parameter is subtracted from the ADC output and is a signed value from -512 to 511 inclusive. For example, when offset = 1, ADCRESULT = ADC output - 1. When offset = -512, ADCRESULT = ADC output - (-512) or ADC output + 512.- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.offset
: is the 10-bit signed value subtracted from ADC the output.
Passing a zero in to the offset parameter will effectively disable the calculation, allowing the raw ADC result to be passed unchanged into the result register.
- Note
If multiple PPBs are applied to the same SOC, the offset that will be applied will be that of the PPB with the highest number.
- Return
None
-
void
ADC_setPPBReferenceOffset
(uint32_t base, ADC_PPBNumber ppbNumber, uint16_t offset)¶ Sets the post processing block reference offset.
This function sets the PPB reference offset value. This can be used to either calculate the feedback error or convert a unipolar signal to bipolar by subtracting a reference value. The result will be stored in the appropriate PPB result register which can be read using
ADC_readPPBResult().- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.offset
: is the 16-bit unsigned value subtracted from ADC the output.
Passing a zero in to the offset parameter will effectively disable the calculation and will pass the ADC result to the PPB result register unchanged.
- Note
If in 12-bit mode, you may only pass a 12-bit value into the offset parameter.
- Return
None
-
void
ADC_enablePPBTwosComplement
(uint32_t base, ADC_PPBNumber ppbNumber)¶ Enables two’s complement capability in the PPB.
This function enables two’s complement in the post-processing block specified by the
ppbNumber parameter. When enabled, a two’s complement will be performed on the output of the offset subtraction before it is stored in the appropriate PPB result register. In other words, the PPB result will be the reference offset value minus the the ADC result value (ADCPPBxRESULT = ADCSOCxOFFREF - ADCRESULTx).- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.
- Return
None
-
void
ADC_disablePPBTwosComplement
(uint32_t base, ADC_PPBNumber ppbNumber)¶ Disables two’s complement capability in the PPB.
This function disables two’s complement in the post-processing block specified by the
ppbNumber parameter. When disabled, a two’s complement will NOT be performed on the output of the offset subtraction before it is stored in the appropriate PPB result register. In other words, the PPB result will be the ADC result value minus the reference offset value (ADCPPBxRESULT = ADCRESULTx - ADCSOCxOFFREF).- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.
- Return
None
-
void
ADC_enableInterrupt
(uint32_t base, ADC_IntNumber adcIntNum)¶ Enables an ADC interrupt source.
This function enables the indicated ADC interrupt source. Only the sources that are enabled can be reflected to the processor interrupt. Disabled sources have no effect on the processor.
- Parameters
base
: is the base address of the ADC module.adcIntNum
: is interrupt number within the ADC wrapper.
adcIntNum can take the value ADC_INT_NUMBER1, ADC_INT_NUMBER2, ADC_INT_NUMBER3, or ADC_INT_NUMBER4 to express which of the four interrupts of the ADC module should be enabled.
- Return
None.
-
void
ADC_disableInterrupt
(uint32_t base, ADC_IntNumber adcIntNum)¶ Disables an ADC interrupt source.
This function disables the indicated ADC interrupt source. Only the sources that are enabled can be reflected to the processor interrupt. Disabled sources have no effect on the processor.
- Parameters
base
: is the base address of the ADC module.adcIntNum
: is interrupt number within the ADC wrapper.
adcIntNum can take the value ADC_INT_NUMBER1, ADC_INT_NUMBER2, ADC_INT_NUMBER3, or ADC_INT_NUMBER4 to express which of the four interrupts of the ADC module should be disabled.
- Return
None.
-
void
ADC_setInterruptSource
(uint32_t base, ADC_IntNumber adcIntNum, ADC_SOCNumber socNumber)¶ Sets the source EOC for an analog-to-digital converter interrupt.
This function sets which conversion is the source of an ADC interrupt.
- Parameters
base
: is the base address of the ADC module.adcIntNum
: is interrupt number within the ADC wrapper.socNumber
: is the number of the start-of-conversion.
The socNumber number is a value ADC_SOC_NUMBERX where X is a number from 0 to 15 specifying which EOC is to be configured on the ADC module specified by base.
adcIntNum can take the value ADC_INT_NUMBER1, ADC_INT_NUMBER2, ADC_INT_NUMBER3, or ADC_INT_NUMBER4 to express which of the four interrupts of the ADC module is being configured.
- Return
None.
-
void
ADC_enableContinuousMode
(uint32_t base, ADC_IntNumber adcIntNum)¶ Enables continuous mode for an ADC interrupt.
This function enables continuous mode for the ADC interrupt passed into
adcIntNum. This means that pulses will be generated for the specified ADC interrupt whenever an EOC pulse is generated irrespective of whether or not the flag bit is set.- Parameters
base
: is the base address of the ADC.adcIntNum
: is interrupt number within the ADC wrapper.
adcIntNum can take the value ADC_INT_NUMBER1, ADC_INT_NUMBER2, ADC_INT_NUMBER3, or ADC_INT_NUMBER4 to express which of the four interrupts of the ADC module is being configured.
- Return
None.
-
void
ADC_disableContinuousMode
(uint32_t base, ADC_IntNumber adcIntNum)¶ Disables continuous mode for an ADC interrupt.
This function disables continuous mode for the ADC interrupt passed into
adcIntNum. This means that pulses will not be generated for the specified ADC interrupt until the corresponding interrupt flag for the previous interrupt occurrence has been cleared using ADC_clearInterruptStatus().- Parameters
base
: is the base address of the ADC.adcIntNum
: is interrupt number within the ADC wrapper.
adcIntNum can take the value ADC_INT_NUMBER1, ADC_INT_NUMBER2, ADC_INT_NUMBER3, or ADC_INT_NUMBER4 to express which of the four interrupts of the ADC module is being configured.
- Return
None.
-
int16_t
ADC_getTemperatureC
(uint16_t tempResult, float32_t vref)¶ Converts temperature from sensor reading to degrees C
This function converts temperature from temp sensor reading to degrees C. Temp sensor values in production test are derived with 2.5V reference. The
vref argument in the function is used to scale the temp sensor reading accordingly if temp sensor value is read at a different VREF setting.- Parameters
tempResult
: is the raw ADC A conversion result from the temp sensor.vref
: is the reference voltage being used (for example 3.3 for 3.3V).
- Note
Only external reference mode is supported for the temperature sensor. This function does not set the reference mode. Reference mode can be set using ADC_setVREF().
- Return
Returns the temperature sensor reading converted to degrees C.
-
int16_t
ADC_getTemperatureK
(uint16_t tempResult, float32_t vref)¶ Converts temperature from sensor reading to degrees K
This function converts temperature from temp sensor reading to degrees K. Temp sensor values in production test are derived with 2.5V reference. The
vref argument in the function is used to scale the temp sensor reading accordingly if temp sensor value is read at a different VREF setting.- Parameters
tempResult
: is the raw ADC A conversion result from the temp sensor.vref
: is the reference voltage being used (for example 3.3 for 3.3V).
- Note
Only external reference mode is supported for the temperature sensor. This function does not set the reference mode. Reference mode can be set using ADC_setVREF().
- Return
Returns the temperature sensor reading converted to degrees K.
-
void
ADC_setVREF
(uint32_t base, ADC_ReferenceMode refMode, ADC_ReferenceVoltage refVoltage)¶ Configures the ADC module’s reference mode and offset trim
This function configures the ADC module’s reference mode and loads the corresponding offset trims.
- Parameters
base
: is the base address of the ADC module.refMode
: is the reference mode being used (ADC_REFERENCE_INTERNAL or ADC_REFERENCE_EXTERNAL).refVoltage
: is the reference voltage being used (ADC_REFERENCE_2_5V or ADC_REFERENCE_3_3V). This is ignored when the reference mode is external.
- Note
In this device, the bandgaps are common for all the ADC instances, hence common Vref configuration needs to be done for all the ADCs. This API configures same Vref configuration for all the supported ADCs in the device.
- Note
When the refMode parameter is ADC_REFERENCE_EXTERNAL, the value of the refVoltage parameter has no effect on the operation of the ADC.
- Return
None.
-
void
ADC_setPPBTripLimits
(uint32_t base, ADC_PPBNumber ppbNumber, int32_t tripHiLimit, int32_t tripLoLimit)¶ Sets the windowed trip limits for a PPB.
This function sets the windowed trip limits for a PPB. These values set the digital comparator so that when one of the values is exceeded, either a high or low trip event will occur.
- Parameters
base
: is the base address of the ADC module.ppbNumber
: is the number of the post-processing block.tripHiLimit
: is the value is the digital comparator trip high limit.tripLoLimit
: is the value is the digital comparator trip low limit.
The ppbNumber is a value ADC_PPB_NUMBERX where X is a value from 1 to 4 inclusive that identifies a PPB to be configured.
If using 16-bit mode, you may pass a 17-bit number into the tripHiLimit and tripLoLimit parameters where the 17th bit is the sign bit (that is a value from -65536 and 65535). In 12-bit mode, only bits 12:0 will be compared against bits 12:0 of the PPB result.
- Return
None.
-
The code for this module is contained in driverlib/adc.c, with driverlib/adc.h containing the API declarations for use by applications.