This module contains APIs to program and use the CMPSS module.
Functions | |
static void | CMPSS_enableModule (uint32_t base) |
static void | CMPSS_disableModule (uint32_t base) |
static void | CMPSS_configHighComparator (uint32_t base, uint16_t config) |
static void | CMPSS_configLowComparator (uint32_t base, uint16_t config) |
static void | CMPSS_configOutputsHigh (uint32_t base, uint16_t config) |
static void | CMPSS_configOutputsLow (uint32_t base, uint16_t config) |
static uint16_t | CMPSS_getStatus (uint32_t base) |
static void | CMPSS_configDAC (uint32_t base, uint16_t config) |
static void | CMPSS_setDACValueHigh (uint32_t base, uint16_t value) |
static void | CMPSS_setDACValueLow (uint32_t base, uint16_t value) |
static void | CMPSS_initFilterHigh (uint32_t base) |
static void | CMPSS_initFilterLow (uint32_t base) |
static uint16_t | CMPSS_getDACValueHigh (uint32_t base) |
static uint16_t | CMPSS_getDACValueLow (uint32_t base) |
static void | CMPSS_clearFilterLatchHigh (uint32_t base) |
static void | CMPSS_clearFilterLatchLow (uint32_t base) |
static void | CMPSS_setMaxRampValue (uint32_t base, uint16_t value) |
static uint16_t | CMPSS_getMaxRampValue (uint32_t base) |
static void | CMPSS_setRampDecValue (uint32_t base, uint16_t value) |
static uint16_t | CMPSS_getRampDecValue (uint32_t base) |
static void | CMPSS_setRampDelayValue (uint32_t base, uint16_t value) |
static uint16_t | CMPSS_getRampDelayValue (uint32_t base) |
static void | CMPSS_configBlanking (uint32_t base, uint16_t pwmBlankSrc) |
static void | CMPSS_enableBlanking (uint32_t base) |
static void | CMPSS_disableBlanking (uint32_t base) |
static void | CMPSS_enableDEmode (uint32_t base) |
static void | CMPSS_disableDEmode (uint32_t base) |
static void | CMPSS_selectDEACTIVESource (uint32_t base, uint8_t deactivesel) |
static void | CMPSS_configHighDACShadowValue2 (uint32_t base, uint16_t dacval) |
static void | CMPSS_configLowDACShadowValue2 (uint32_t base, uint16_t dacval) |
static void | CMPSS_setComparatorHighHysteresis (uint32_t base, uint16_t value) |
static void | CMPSS_setComparatorLowHysteresis (uint32_t base, uint16_t value) |
void | CMPSS_configFilterHigh (uint32_t base, uint16_t samplePrescale, uint16_t sampleWindow, uint16_t threshold) |
void | CMPSS_configFilterLow (uint32_t base, uint16_t samplePrescale, uint16_t sampleWindow, uint16_t threshold) |
void | CMPSS_configLatchOnPWMSYNC (uint32_t base, bool highEnable, bool lowEnable) |
void | CMPSS_configRamp (uint32_t base, uint16_t maxRampVal, uint16_t decrementVal, uint16_t delayVal, uint16_t pwmSyncSrc, bool useRampValShdw) |
Macros | |
#define | CMPSS_HICMP_CTL_M |
Header Files. More... | |
#define | CMPSS_LOCMP_CTL_M |
#define | CMPSS_INSRC_DAC (0x0000U) |
Input driven by internal DAC. More... | |
#define | CMPSS_INSRC_PIN (0x0001U) |
Input driven by external 'INL' pin. More... | |
#define | CMPSS_INSRC_PIN_INL (0x0000U) |
Input driven by external 'INL' pin. More... | |
#define | CMPSS_INSRC_PIN_INH (0x0001U) |
Input driven by external 'INH' pin. More... | |
#define | CMPSS_INV_INVERTED (0x0002U) |
Comparator output is inverted. More... | |
#define | CMPSS_OR_ASYNC_OUT_W_FILT (0x0040U) |
Asynch comparator output feeds into OR with latched digital filter output. More... | |
#define | CMPSS_TRIPOUT_ASYNC_COMP (0x0000U) |
Asynchronous comparator output drives CTRIPOUT. More... | |
#define | CMPSS_TRIPOUT_SYNC_COMP (0x0010U) |
Synchronous comparator output drives CTRIPOUT. More... | |
#define | CMPSS_TRIPOUT_FILTER (0x0020U) |
Filter output drives CTRIPOUT. More... | |
#define | CMPSS_TRIPOUT_LATCH (0x0030U) |
Latched filter output drives CTRIPOUT. More... | |
#define | CMPSS_TRIP_ASYNC_COMP (0x0000U) |
Asynchronous comparator output drives CTRIP. More... | |
#define | CMPSS_TRIP_SYNC_COMP (0x0004U) |
Synchronous comparator output drives CTRIP. More... | |
#define | CMPSS_TRIP_FILTER (0x0008U) |
Filter output drives CTRIP. More... | |
#define | CMPSS_TRIP_LATCH (0x000CU) |
Latched filter output drives CTRIP. More... | |
#define | CMPSS_STS_HI_FILTOUT (0x0001U) |
High digital filter output. More... | |
#define | CMPSS_STS_HI_LATCHFILTOUT (0x0002U) |
Latched value of high digital filter output. More... | |
#define | CMPSS_STS_LO_FILTOUT (0x0100U) |
Low digital filter output. More... | |
#define | CMPSS_STS_LO_LATCHFILTOUT (0x0200U) |
Latched value of low digital filter output. More... | |
#define | CMPSS_DACVAL_SYSCLK (0x0000U) |
DAC value updated from SYSCLK. More... | |
#define | CMPSS_DACVAL_PWMSYNC (0x0080U) |
DAC value updated from PWMSYNC. More... | |
#define | CMPSS_DACREF_VDDA (0x0000U) |
VDDA is the voltage reference. More... | |
#define | CMPSS_DACREF_VDAC (0x0020U) |
VDAC is the voltage reference. More... | |
#define | CMPSS_DACSRC_SHDW (0x0000U) |
DAC value updated from shadow register. More... | |
#define | CMPSS_DACSRC_RAMP (0x0001U) |
DAC value is updated from the ramp register. More... | |
#define CMPSS_HICMP_CTL_M |
Header Files.
#define CMPSS_LOCMP_CTL_M |
#define CMPSS_INSRC_DAC (0x0000U) |
Input driven by internal DAC.
#define CMPSS_INSRC_PIN (0x0001U) |
Input driven by external 'INL' pin.
#define CMPSS_INSRC_PIN_INL (0x0000U) |
Input driven by external 'INL' pin.
#define CMPSS_INSRC_PIN_INH (0x0001U) |
Input driven by external 'INH' pin.
#define CMPSS_INV_INVERTED (0x0002U) |
Comparator output is inverted.
#define CMPSS_OR_ASYNC_OUT_W_FILT (0x0040U) |
Asynch comparator output feeds into OR with latched digital filter output.
#define CMPSS_TRIPOUT_ASYNC_COMP (0x0000U) |
Asynchronous comparator output drives CTRIPOUT.
#define CMPSS_TRIPOUT_SYNC_COMP (0x0010U) |
Synchronous comparator output drives CTRIPOUT.
#define CMPSS_TRIPOUT_FILTER (0x0020U) |
Filter output drives CTRIPOUT.
#define CMPSS_TRIPOUT_LATCH (0x0030U) |
Latched filter output drives CTRIPOUT.
#define CMPSS_TRIP_ASYNC_COMP (0x0000U) |
Asynchronous comparator output drives CTRIP.
#define CMPSS_TRIP_SYNC_COMP (0x0004U) |
Synchronous comparator output drives CTRIP.
#define CMPSS_TRIP_FILTER (0x0008U) |
Filter output drives CTRIP.
#define CMPSS_TRIP_LATCH (0x000CU) |
Latched filter output drives CTRIP.
#define CMPSS_STS_HI_FILTOUT (0x0001U) |
High digital filter output.
#define CMPSS_STS_HI_LATCHFILTOUT (0x0002U) |
Latched value of high digital filter output.
#define CMPSS_STS_LO_FILTOUT (0x0100U) |
Low digital filter output.
#define CMPSS_STS_LO_LATCHFILTOUT (0x0200U) |
Latched value of low digital filter output.
#define CMPSS_DACVAL_SYSCLK (0x0000U) |
DAC value updated from SYSCLK.
#define CMPSS_DACVAL_PWMSYNC (0x0080U) |
DAC value updated from PWMSYNC.
#define CMPSS_DACREF_VDDA (0x0000U) |
VDDA is the voltage reference.
#define CMPSS_DACREF_VDAC (0x0020U) |
VDAC is the voltage reference.
#define CMPSS_DACSRC_SHDW (0x0000U) |
DAC value updated from shadow register.
#define CMPSS_DACSRC_RAMP (0x0001U) |
DAC value is updated from the ramp register.
|
inlinestatic |
Enables the CMPSS module.
base | is the base address of the CMPSS module. |
This function enables the CMPSS module passed into the base parameter.
|
inlinestatic |
Disables the CMPSS module.
base | is the base address of the CMPSS module. |
This function disables the CMPSS module passed into the base parameter.
|
inlinestatic |
Sets the configuration for the high comparator.
base | is the base address of the CMPSS module. |
config | is the configuration of the high comparator. |
This function configures a comparator. The config parameter is the result of a logical OR operation between a CMPSS_INSRC_xxx value and if desired, CMPSS_INV_INVERTED and CMPSS_OR_ASYNC_OUT_W_FILT values.
The CMPSS_INSRC_xxx term can take on the following values to specify the high comparator negative input source:
CMPSS_INV_INVERTED may be ORed into config if the comparator output should be inverted.
CMPSS_OR_ASYNC_OUT_W_FILT may be ORed into config if the asynchronous comparator output should be fed into an OR gate with the latched digital filter output before it is made available for CTRIPH or CTRIPOUTH.
|
inlinestatic |
Sets the configuration for the low comparator.
base | is the base address of the CMPSS module. |
config | is the configuration of the low comparator. |
This function configures a comparator. The config parameter is the result of a logical OR operation between a CMPSS_INSRC_xxx value and if desired, CMPSS_INV_INVERTED and CMPSS_OR_ASYNC_OUT_W_FILT values.
The CMPSS_INSRC_xxx term can take on the following values to specify the low comparator negative input source:
CMPSS_INV_INVERTED may be ORed into config if the comparator output should be inverted.
CMPSS_OR_ASYNC_OUT_W_FILT may be ORed into config if the asynchronous comparator output should be fed into an OR gate with the latched digital filter output before it is made available for CTRIPL or CTRIPOUTL.
|
inlinestatic |
Sets the output signal configuration for the high comparator.
base | is the base address of the CMPSS module. |
config | is the configuration of the high comparator output signals. |
This function configures a comparator's output signals CTRIP and CTRIPOUT. The config parameter is the result of a logical OR operation between the CMPSS_TRIPOUT_xxx and CMPSS_TRIP_xxx values.
The CMPSS_TRIPOUT_xxx term can take on the following values to specify which signal drives CTRIPOUTH:
The CMPSS_TRIP_xxx term can take on the following values to specify which signal drives CTRIPH:
|
inlinestatic |
Sets the output signal configuration for the low comparator.
base | is the base address of the CMPSS module. |
config | is the configuration of the low comparator output signals. |
This function configures a comparator's output signals CTRIP and CTRIPOUT. The config parameter is the result of a logical OR operation between the CMPSS_TRIPOUT_xxx and CMPSS_TRIP_xxx values.
The CMPSS_TRIPOUT_xxx term can take on the following values to specify which signal drives CTRIPOUTL:
The CMPSS_TRIP_xxx term can take on the following values to specify which signal drives CTRIPL:
|
inlinestatic |
Gets the current comparator status.
base | is the base address of the comparator module. |
This function returns the current status for the comparator, specifically the digital filter output and latched digital filter output.
|
inlinestatic |
Sets the configuration for the internal comparator DACs.
base | is the base address of the CMPSS module. |
config | is the configuration of the internal DAC. |
This function configures the comparator's internal DAC. The config parameter is the result of a logical OR operation between the CMPSS_DACVAL_xxx, CMPSS_DACREF_xxx, and CMPSS_DACSRC_xxx.
The CMPSS_DACVAL_xxx term can take on the following values to specify when the DAC value is loaded from its shadow register:
The CMPSS_DACREF_xxx term can take on the following values to specify which voltage supply is used as reference for the DACs:
The CMPSS_DACSRC_xxx term can take on the following values to specify the DAC value source for the high comparator's internal DAC:
|
inlinestatic |
Sets the value of the internal DAC of the high comparator.
base | is the base address of the comparator module. |
value | is the value actively driven by the DAC. |
This function sets the 12-bit value driven by the internal DAC of the high comparator. This function will load the value into the shadow register from which the actual DAC value register will be loaded. To configure which event causes this shadow load to take place, use CMPSS_configDAC().
|
inlinestatic |
Sets the value of the internal DAC of the low comparator.
base | is the base address of the comparator module. |
value | is the value actively driven by the DAC. |
This function sets the 12-bit value driven by the internal DAC of the low comparator. This function will load the value into the shadow register from which the actual DAC value register will be loaded. To configure which event causes this shadow load to take place, use CMPSS_configDAC().
|
inlinestatic |
Initializes the digital filter of the high comparator.
base | is the base address of the comparator module. |
This function initializes all the samples in the high comparator digital filter to the filter input value.
|
inlinestatic |
Initializes the digital filter of the low comparator.
base | is the base address of the comparator module. |
This function initializes all the samples in the low comparator digital filter to the filter input value.
|
inlinestatic |
Gets the value of the internal DAC of the high comparator.
base | is the base address of the comparator module. |
This function gets the value of the internal DAC of the high comparator. The value is read from the active register–not the shadow register to which CMPSS_setDACValueHigh() writes.
|
inlinestatic |
Gets the value of the internal DAC of the low comparator.
base | is the base address of the comparator module. |
This function gets the value of the internal DAC of the low comparator. The value is read from the active register–not the shadow register to which CMPSS_setDACValueLow() writes.
|
inlinestatic |
Causes a software reset of the high comparator digital filter output latch.
base | is the base address of the comparator module. |
This function causes a software reset of the high comparator digital filter output latch. It will generate a single pulse of the latch reset signal.
|
inlinestatic |
Causes a software reset of the low comparator digital filter output latch.
base | is the base address of the comparator module. |
This function causes a software reset of the low comparator digital filter output latch. It will generate a single pulse of the latch reset signal.
|
inlinestatic |
Sets the ramp generator maximum reference value.
base | is the base address of the comparator module. |
value | the ramp maximum reference value. |
This function sets the ramp maximum reference value that will be loaded into the ramp generator.
|
inlinestatic |
Gets the ramp generator maximum reference value.
base | is the base address of the comparator module. |
|
inlinestatic |
Sets the ramp generator decrement value.
base | is the base address of the comparator module. |
value | is the ramp decrement value. |
This function sets the value that is subtracted from the ramp value on every system clock cycle.
|
inlinestatic |
Gets the ramp generator decrement value.
base | is the base address of the comparator module. |
|
inlinestatic |
Sets the ramp generator delay value.
base | is the base address of the comparator module. |
value | is the 13-bit ramp delay value. |
This function sets the value that configures the number of system clock cycles to delay the start of the ramp generator decrementer after a PWMSYNC event is received. Delay value can be no greater than 8191.
|
inlinestatic |
Gets the ramp generator delay value.
base | is the base address of the comparator module. |
|
inlinestatic |
Sets the ePWM module blanking signal that holds trip in reset.
base | is the base address of the comparator module. |
pwmBlankSrc | is the number of the PWMBLANK source. |
This function configures which PWMBLANK signal from the ePWM module will hold trip in reset when blanking is enabled.
The number of the PWMBLANK signal to be used to reset the ramp generator should be specified by passing it into the pwmBlankSrc parameter. For instance, passing a 2 into pwmBlankSrc will select PWMBLANK2.
|
inlinestatic |
Enables an ePWM blanking signal to hold trip in reset.
base | is the base address of the comparator module. |
This function enables a selected ePWM blanking signal to hold trip in reset.
|
inlinestatic |
Disables an ePWM blanking signal from holding trip in reset.
base | is the base address of the comparator module. |
This function disables a selected ePWM blanking signal from holding trip in reset.
|
inlinestatic |
Enables the CMPSS diode emulation mode
base | is the base address of the comparator module. |
This function enables the CMPSS diode emulation mode
|
inlinestatic |
Disables the CMPSS diode emulation mode
base | is the base address of the comparator module. |
This function disables the CMPSS diode emulation mode
|
inlinestatic |
Select the CMPSS diode emulation mode DEACTIVE source
base | is the base address of the comparator module. |
deactivesel | is the DEACTIVE source select |
This function selects the CMPSS diode emulation mode DEACTIVE source
|
inlinestatic |
Sets the shadow value 2 (used in DE mode) of the internal DAC of the high comparator.
base | is the base address of the comparator module. |
dacval | is the value actively driven by the DAC. |
This function sets the 12-bit value driven by the internal DAC of the high comparator. This function will load the value into the shadow register 2 from which the actual DAC value register will be loaded in DE mode.
|
inlinestatic |
Sets the shadow value 2 (used in DE mode) of the internal DAC of the low comparator.
base | is the base address of the comparator module. |
dacval | is the value actively driven by the DAC. |
This function sets the 12-bit value driven by the internal DAC of the low comparator. This function will load the value into the shadow register 2 from which the actual DAC value register will be loaded in DE mode.
|
inlinestatic |
Sets the hysteresis value of the high comparator.
base | is the base address of the comparator module. |
value | is the hysteresis value. bit[15:4]: unused. bit[3] : reserved. bit[2] : control which comparator output value the hysteresis is applied to 0 comparator hysteresis is applied when the comparator output is 1'b1 1 comparator hysteresis is applied when the comparator output is 1'b0 bit[1:0] : 00 ==> 0 LSB ==> 0mV, 01 ==> 17.5 LSB ==> 14mV, 10 ==> 35 LSB ==> 28mV, 11 ==> 52.5 LSB ==> 42mV. |
This function sets the hysteresis value of the high comparator.
|
inlinestatic |
Sets the hysteresis value of the low comparator.
base | is the base address of the comparator module. |
value | is the hysteresis value. bit[15:4]: unused. bit[3] : reserved. bit[2] : control which comparator output value the hysteresis is applied to 0 comparator hysteresis is applied when the comparator output is 1'b1 1 comparator hysteresis is applied when the comparator output is 1'b0 bit[1:0] : 00 ==> 0 LSB ==> 0mV, 01 ==> 17.5 LSB ==> 14mV, 10 ==> 35 LSB ==> 28mV, 11 ==> 52.5 LSB ==> 42mV. |
This function sets the hysteresis value of the low comparator.
void CMPSS_configFilterHigh | ( | uint32_t | base, |
uint16_t | samplePrescale, | ||
uint16_t | sampleWindow, | ||
uint16_t | threshold | ||
) |
Configures the digital filter of the high comparator.
base | is the base address of the comparator module. |
samplePrescale | is the number of system clock cycles between samples. |
sampleWindow | is the number of FIFO samples to monitor. |
threshold | is the majority threshold of samples to change state. |
This function configures the operation of the digital filter of the high comparator.
The samplePrescale parameter specifies the number of system clock cycles between samples. It is a 10-bit value so a number higher than 1023 should not be passed as this parameter. The prescale used by digital filter is 1 more than samplePrescale value. So, the input provided should be 1 less than the expected prescale.
The sampleWindow parameter configures the size of the window of FIFO samples taken from the input that will be monitored to determine when to change the filter output. This sample window may be no larger than 32 samples.
The threshold parameter configures the threshold value to be used by the digital filter.
The filter output resolves to the majority value of the sample window where majority is defined by the value passed into the threshold parameter. For proper operation, the value of threshold must be greater than sampleWindow / 2.
To ensure proper operation of the filter, the following is the recommended function call sequence for initialization:
void CMPSS_configFilterLow | ( | uint32_t | base, |
uint16_t | samplePrescale, | ||
uint16_t | sampleWindow, | ||
uint16_t | threshold | ||
) |
Configures the digital filter of the low comparator.
base | is the base address of the comparator module. |
samplePrescale | is the number of system clock cycles between samples. |
sampleWindow | is the number of FIFO samples to monitor. |
threshold | is the majority threshold of samples to change state. |
This function configures the operation of the digital filter of the low comparator.
The samplePrescale parameter specifies the number of system clock cycles between samples. It is a 10-bit value so a number higher than 1023 should not be passed as this parameter. The prescale used by digital filter is 1 more than samplePrescale value. So, the input provided should be 1 less than the expected prescale.
The sampleWindow parameter configures the size of the window of FIFO samples taken from the input that will be monitored to determine when to change the filter output. This sample window may be no larger than 32 samples.
The threshold parameter configures the threshold value to be used by the digital filter.
The filter output resolves to the majority value of the sample window where majority is defined by the value passed into the threshold parameter. For proper operation, the value of threshold must be greater than sampleWindow / 2.
To ensure proper operation of the filter, the following is the recommended function call sequence for initialization:
void CMPSS_configLatchOnPWMSYNC | ( | uint32_t | base, |
bool | highEnable, | ||
bool | lowEnable | ||
) |
Configures whether or not the digital filter latches are reset by PWMSYNC
base | is the base address of the comparator module. |
highEnable | indicates filter latch settings in the high comparator. |
lowEnable | indicates filter latch settings in the low comparator. |
This function configures whether or not the digital filter latches in both the high and low comparators should be reset by PWMSYNC. If the highEnable parameter is true, the PWMSYNC will be allowed to reset the high comparator's digital filter latch. If it is false, the ability of the PWMSYNC to reset the latch will be disabled. The lowEnable parameter has the same effect on the low comparator's digital filter latch.
void CMPSS_configRamp | ( | uint32_t | base, |
uint16_t | maxRampVal, | ||
uint16_t | decrementVal, | ||
uint16_t | delayVal, | ||
uint16_t | pwmSyncSrc, | ||
bool | useRampValShdw | ||
) |
Configures the comparator subsystem's ramp generator.
base | is the base address of the comparator module. |
maxRampVal | is the ramp maximum reference value. |
decrementVal | value is the ramp decrement value. |
delayVal | is the ramp delay value. |
pwmSyncSrc | is the number of the PWMSYNC source. |
useRampValShdw | indicates if the max ramp shadow should be used. |
This function configures many of the main settings of the comparator subsystem's ramp generator. The maxRampVal parameter should be passed the ramp maximum reference value that will be loaded into the ramp generator. The decrementVal parameter should be passed the decrement value that will be subtracted from the ramp generator on each system clock cycle. The delayVal parameter should be passed the 13-bit number of system clock cycles the ramp generator should delay before beginning to decrement the ramp generator after a PWMSYNC signal is received.
These three values may be be set individually using the CMPSS_setMaxRampValue(), CMPSS_setRampDecValue(), and CMPSS_setRampDelayValue() APIs.
The number of the PWMSYNC signal to be used to reset the ramp generator should be specified by passing it into the pwmSyncSrc parameter. For instance, passing a 2 into pwmSyncSrc will select PWMSYNC2.
To indicate whether the ramp generator should reset with the value from the ramp max reference value shadow register or with the latched ramp max reference value, use the useRampValShdw parameter. Passing it true will result in the latched value being bypassed. The ramp generator will be loaded right from the shadow register. A value of false will load the ramp generator from the latched value.