MSP430 DriverLib for MSP430FR57xx Devices  2.91.13.01
comp_d

Functions

bool Comp_D_init (uint16_t baseAddress, Comp_D_initParam *param)
 Initializes the Comp_D Module. More...
 
void Comp_D_setReferenceVoltage (uint16_t baseAddress, uint16_t supplyVoltageReferenceBase, uint16_t lowerLimitSupplyVoltageFractionOf32, uint16_t upperLimitSupplyVoltageFractionOf32)
 Generates a Reference Voltage to the terminal selected during initialization. More...
 
void Comp_D_setReferenceAccuracy (uint16_t baseAddress, uint16_t referenceAccuracy)
 Sets the reference accuracy. More...
 
void Comp_D_enableInterrupt (uint16_t baseAddress, uint16_t interruptMask)
 Enables selected Comparator interrupt sources. More...
 
void Comp_D_disableInterrupt (uint16_t baseAddress, uint16_t interruptMask)
 Disables selected Comparator interrupt sources. More...
 
void Comp_D_clearInterrupt (uint16_t baseAddress, uint16_t interruptFlagMask)
 Clears Comparator interrupt flags. More...
 
uint8_t Comp_D_getInterruptStatus (uint16_t baseAddress, uint16_t interruptFlagMask)
 Gets the current Comparator interrupt status. More...
 
void Comp_D_setInterruptEdgeDirection (uint16_t baseAddress, uint16_t edgeDirection)
 Explicitly sets the edge direction that would trigger an interrupt. More...
 
void Comp_D_toggleInterruptEdgeDirection (uint16_t baseAddress)
 Toggles the edge direction that would trigger an interrupt. More...
 
void Comp_D_enable (uint16_t baseAddress)
 Turns on the Comparator module. More...
 
void Comp_D_disable (uint16_t baseAddress)
 Turns off the Comparator module. More...
 
void Comp_D_shortInputs (uint16_t baseAddress)
 Shorts the two input pins chosen during initialization. More...
 
void Comp_D_unshortInputs (uint16_t baseAddress)
 Disables the short of the two input pins chosen during initialization. More...
 
void Comp_D_disableInputBuffer (uint16_t baseAddress, uint8_t inputPort)
 Disables the input buffer of the selected input port to effectively allow for analog signals. More...
 
void Comp_D_enableInputBuffer (uint16_t baseAddress, uint8_t inputPort)
 Enables the input buffer of the selected input port to allow for digital signals. More...
 
void Comp_D_swapIO (uint16_t baseAddress)
 Toggles the bit that swaps which terminals the inputs go to, while also inverting the output of the comparator. More...
 
uint16_t Comp_D_outputValue (uint16_t baseAddress)
 Returns the output value of the Comp_D module. More...
 

Detailed Description

Function Documentation

§ Comp_D_clearInterrupt()

void Comp_D_clearInterrupt ( uint16_t  baseAddress,
uint16_t  interruptFlagMask 
)

Clears Comparator interrupt flags.

The Comparator interrupt source is cleared, so that it no longer asserts.The highest interrupt flag is automatically cleared when an interrupt vector generator is used.

Parameters
baseAddressis the base address of the COMP_D module.
interruptFlagMaskMask value is the logical OR of any of the following:
  • COMP_D_INTERRUPT_FLAG - Output interrupt flag
  • COMP_D_INTERRUPT_FLAG_INVERTED_POLARITY - Output interrupt flag inverted polarity

§ Comp_D_disable()

void Comp_D_disable ( uint16_t  baseAddress)

Turns off the Comparator module.

This function clears the CDON bit disabling the operation of the Comparator module, saving from excess power consumption.

Parameters
baseAddressis the base address of the COMP_D module.
Returns
None

§ Comp_D_disableInputBuffer()

void Comp_D_disableInputBuffer ( uint16_t  baseAddress,
uint8_t  inputPort 
)

Disables the input buffer of the selected input port to effectively allow for analog signals.

This function sets the bit to disable the buffer for the specified input port to allow for analog signals from any of the comparator input pins. This bit is automatically set when the input is initialized to be used with the comparator module. This function should be used whenever an analog input is connected to one of these pins to prevent parasitic voltage from causing unexpected results.

Parameters
baseAddressis the base address of the COMP_D module.
inputPortis the port in which the input buffer will be disabled. Valid values are:
  • COMP_D_INPUT0 [Default]
  • COMP_D_INPUT1
  • COMP_D_INPUT2
  • COMP_D_INPUT3
  • COMP_D_INPUT4
  • COMP_D_INPUT5
  • COMP_D_INPUT6
  • COMP_D_INPUT7
  • COMP_D_INPUT8
  • COMP_D_INPUT9
  • COMP_D_INPUT10
  • COMP_D_INPUT11
  • COMP_D_INPUT12
  • COMP_D_INPUT13
  • COMP_D_INPUT14
  • COMP_D_INPUT15
  • COMP_D_VREF
    Modified bits are CDPDx of CDCTL3 register.
Returns
None

§ Comp_D_disableInterrupt()

void Comp_D_disableInterrupt ( uint16_t  baseAddress,
uint16_t  interruptMask 
)

Disables selected Comparator interrupt sources.

Disables the indicated Comparator 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 COMP_D module.
interruptMaskMask value is the logical OR of any of the following:
  • COMP_D_INTERRUPT - Output interrupt
  • COMP_D_INTERRUPT_INVERTED_POLARITY - Output interrupt inverted polarity

§ Comp_D_enable()

void Comp_D_enable ( uint16_t  baseAddress)

Turns on the Comparator module.

This function sets the bit that enables the operation of the Comparator module.

Parameters
baseAddressis the base address of the COMP_D module.
Returns
None

§ Comp_D_enableInputBuffer()

void Comp_D_enableInputBuffer ( uint16_t  baseAddress,
uint8_t  inputPort 
)

Enables the input buffer of the selected input port to allow for digital signals.

This function clears the bit to enable the buffer for the specified input port to allow for digital signals from any of the comparator input pins. This should not be reset if there is an analog signal connected to the specified input pin to prevent from unexpected results.

Parameters
baseAddressis the base address of the COMP_D module.
inputPortis the port in which the input buffer will be enabled. Valid values are:
  • COMP_D_INPUT0 [Default]
  • COMP_D_INPUT1
  • COMP_D_INPUT2
  • COMP_D_INPUT3
  • COMP_D_INPUT4
  • COMP_D_INPUT5
  • COMP_D_INPUT6
  • COMP_D_INPUT7
  • COMP_D_INPUT8
  • COMP_D_INPUT9
  • COMP_D_INPUT10
  • COMP_D_INPUT11
  • COMP_D_INPUT12
  • COMP_D_INPUT13
  • COMP_D_INPUT14
  • COMP_D_INPUT15
  • COMP_D_VREF
    Modified bits are CDPDx of CDCTL3 register.
Returns
None

§ Comp_D_enableInterrupt()

void Comp_D_enableInterrupt ( uint16_t  baseAddress,
uint16_t  interruptMask 
)

Enables selected Comparator interrupt sources.

Enables the indicated Comparator 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 COMP_D module.
interruptMaskMask value is the logical OR of any of the following:
  • COMP_D_INTERRUPT - Output interrupt
  • COMP_D_INTERRUPT_INVERTED_POLARITY - Output interrupt inverted polarity

§ Comp_D_getInterruptStatus()

uint8_t Comp_D_getInterruptStatus ( uint16_t  baseAddress,
uint16_t  interruptFlagMask 
)

Gets the current Comparator interrupt status.

This returns the interrupt status for the Comparator module based on which flag is passed.

Parameters
baseAddressis the base address of the COMP_D module.
interruptFlagMaskMask value is the logical OR of any of the following:
  • COMP_D_INTERRUPT_FLAG - Output interrupt flag
  • COMP_D_INTERRUPT_FLAG_INVERTED_POLARITY - Output interrupt flag inverted polarity

§ Comp_D_init()

bool Comp_D_init ( uint16_t  baseAddress,
Comp_D_initParam param 
)

Initializes the Comp_D Module.

Upon successful initialization of the Comp_D module, this function will have reset all necessary register bits and set the given options in the registers. To actually use the Comp_D module, the Comp_D_enable() function must be explicitly called before use. If a Reference Voltage is set to a terminal, the Voltage should be set using the setReferenceVoltage() function.

Parameters
baseAddressis the base address of the COMP_D module.
paramis the pointer to struct for initialization.
Returns
STATUS_SUCCESS or STATUS_FAILURE of the initialization process

References Comp_D_initParam::invertedOutputPolarity, Comp_D_initParam::negativeTerminalInput, Comp_D_initParam::outputFilterEnableAndDelayLevel, and Comp_D_initParam::positiveTerminalInput.

§ Comp_D_outputValue()

uint16_t Comp_D_outputValue ( uint16_t  baseAddress)

Returns the output value of the Comp_D module.

Returns the output value of the Comp_D module.

Parameters
baseAddressis the base address of the COMP_D module.
Returns
Comp_D_HIGH or Comp_D_LOW as the output value of the Comparator module. Return one of the following:
  • COMP_D_HIGH
  • COMP_D_LOW
    indicates the output should be normal

§ Comp_D_setInterruptEdgeDirection()

void Comp_D_setInterruptEdgeDirection ( uint16_t  baseAddress,
uint16_t  edgeDirection 
)

Explicitly sets the edge direction that would trigger an interrupt.

This function will set which direction the output will have to go, whether rising or falling, to generate an interrupt based on a non-inverted interrupt.

Parameters
baseAddressis the base address of the COMP_D module.
edgeDirectiondetermines which direction the edge would have to go to generate an interrupt based on the non-inverted interrupt flag. Valid values are:
  • COMP_D_FALLINGEDGE [Default] - sets the bit to generate an interrupt when the output of the comparator falls from HIGH to LOW if the normal interrupt bit is set(and LOW to HIGH if the inverted interrupt enable bit is set).
  • COMP_D_RISINGEDGE - sets the bit to generate an interrupt when the output of the comparator rises from LOW to HIGH if the normal interrupt bit is set(and HIGH to LOW if the inverted interrupt enable bit is set).
    Modified bits are CDIES of CDCTL1 register.
Returns
None

§ Comp_D_setReferenceAccuracy()

void Comp_D_setReferenceAccuracy ( uint16_t  baseAddress,
uint16_t  referenceAccuracy 
)

Sets the reference accuracy.

The reference accuracy is set to the desired setting. Clocked is better for low power operations but has a lower accuracy.

Parameters
baseAddressis the base address of the COMP_D module.
referenceAccuracyis the reference accuracy setting of the comparator. Clocked is for low power/low accuracy. Valid values are:
  • COMP_D_ACCURACY_STATIC
  • COMP_D_ACCURACY_CLOCKED
    Modified bits are CDREFACC of CDCTL2 register.
Returns
None

§ Comp_D_setReferenceVoltage()

void Comp_D_setReferenceVoltage ( uint16_t  baseAddress,
uint16_t  supplyVoltageReferenceBase,
uint16_t  lowerLimitSupplyVoltageFractionOf32,
uint16_t  upperLimitSupplyVoltageFractionOf32 
)

Generates a Reference Voltage to the terminal selected during initialization.

Use this function to generate a voltage to serve as a reference to the terminal selected at initialization. The voltage is determined by the equation: Vbase * (Numerator / 32). If the upper and lower limit voltage numerators are equal, then a static reference is defined, whereas they are different then a hysteresis effect is generated. Note that the "limit" voltage is the voltage triggers a change in COMP_D value.

Parameters
baseAddressis the base address of the COMP_D module.
supplyVoltageReferenceBasedecides the source and max amount of Voltage that can be used as a reference. Valid values are:
  • COMP_D_REFERENCE_AMPLIFIER_DISABLED
  • COMP_D_VREFBASE1_5V
  • COMP_D_VREFBASE2_0V
  • COMP_D_VREFBASE2_5V
    Modified bits are CDREFL of CDCTL2 register.
lowerLimitSupplyVoltageFractionOf32is the numerator of the equation to generate the reference voltage for the lower limit reference voltage.
Modified bits are CDREF0 of CDCTL2 register.
upperLimitSupplyVoltageFractionOf32is the numerator of the equation to generate the reference voltage for the upper limit reference voltage.
Modified bits are CDREF1 of CDCTL2 register.
Returns
None

§ Comp_D_shortInputs()

void Comp_D_shortInputs ( uint16_t  baseAddress)

Shorts the two input pins chosen during initialization.

This function sets the bit that shorts the devices attached to the input pins chosen from the initialization of the comparator.

Parameters
baseAddressis the base address of the COMP_D module.
Returns
None

§ Comp_D_swapIO()

void Comp_D_swapIO ( uint16_t  baseAddress)

Toggles the bit that swaps which terminals the inputs go to, while also inverting the output of the comparator.

This function toggles the bit that controls which input goes to which terminal. After initialization, this bit is set to 0, after toggling it once the inputs are routed to the opposite terminal and the output is inverted.

Parameters
baseAddressis the base address of the COMP_D module.
Returns
None

§ Comp_D_toggleInterruptEdgeDirection()

void Comp_D_toggleInterruptEdgeDirection ( uint16_t  baseAddress)

Toggles the edge direction that would trigger an interrupt.

This function will toggle which direction the output will have to go, whether rising or falling, to generate an interrupt based on a non-inverted interrupt. If the direction was rising, it is now falling, if it was falling, it is now rising.

Parameters
baseAddressis the base address of the COMP_D module.
Returns
None

§ Comp_D_unshortInputs()

void Comp_D_unshortInputs ( uint16_t  baseAddress)

Disables the short of the two input pins chosen during initialization.

This function clears the bit that shorts the devices attached to the input pins chosen from the initialization of the comparator.

Parameters
baseAddressis the base address of the COMP_D module.
Returns
None

Copyright 2020, Texas Instruments Incorporated