This module contains APIs to program and use the CMPSS module.
|
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) |
|
static void CMPSS_configHighComparator |
( |
uint32_t |
base, |
|
|
uint16_t |
config |
|
) |
| |
|
inlinestatic |
Sets the configuration for the high comparator.
- Parameters
-
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_INSRC_DAC - The internal DAC.
- CMPSS_INSRC_PIN - External 'INL' pin. This is not applicable for CMPSSBx
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.
- Returns
- None.
static void CMPSS_configLowComparator |
( |
uint32_t |
base, |
|
|
uint16_t |
config |
|
) |
| |
|
inlinestatic |
Sets the configuration for the low comparator.
- Parameters
-
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_INSRC_PIN_INL - External 'INL' pin.
- CMPSS_INSRC_PIN_INH - External 'INH' pin. This is not applicable for CMPSSBx
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.
- Returns
- None.
static void CMPSS_configOutputsHigh |
( |
uint32_t |
base, |
|
|
uint16_t |
config |
|
) |
| |
|
inlinestatic |
Sets the output signal configuration for the high comparator.
- Parameters
-
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:
- CMPSS_TRIPOUT_ASYNC_COMP - The asynchronous comparator output.
- CMPSS_TRIPOUT_SYNC_COMP - The synchronous comparator output.
- CMPSS_TRIPOUT_FILTER - The output of the digital filter.
- CMPSS_TRIPOUT_LATCH - The latched output of the digital filter.
The CMPSS_TRIP_xxx term can take on the following values to specify which signal drives CTRIPH:
- CMPSS_TRIP_ASYNC_COMP - The asynchronous comparator output.
- CMPSS_TRIP_SYNC_COMP - The synchronous comparator output.
- CMPSS_TRIP_FILTER - The output of the digital filter.
- CMPSS_TRIP_LATCH - The latched output of the digital filter.
- Returns
- None.
static void CMPSS_configOutputsLow |
( |
uint32_t |
base, |
|
|
uint16_t |
config |
|
) |
| |
|
inlinestatic |
Sets the output signal configuration for the low comparator.
- Parameters
-
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:
- CMPSS_TRIPOUT_ASYNC_COMP - The asynchronous comparator output.
- CMPSS_TRIPOUT_SYNC_COMP - The synchronous comparator output.
- CMPSS_TRIPOUT_FILTER - The output of the digital filter.
- CMPSS_TRIPOUT_LATCH - The latched output of the digital filter.
The CMPSS_TRIP_xxx term can take on the following values to specify which signal drives CTRIPL:
- CMPSS_TRIP_ASYNC_COMP - The asynchronous comparator output.
- CMPSS_TRIP_SYNC_COMP - The synchronous comparator output.
- CMPSS_TRIP_FILTER - The output of the digital filter.
- CMPSS_TRIP_LATCH - The latched output of the digital filter.
- Returns
- None.
static void CMPSS_configDAC |
( |
uint32_t |
base, |
|
|
uint16_t |
config |
|
) |
| |
|
inlinestatic |
Sets the configuration for the internal comparator DACs.
- Parameters
-
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:
- CMPSS_DACVAL_SYSCLK - Value register updated on system clock.
- CMPSS_DACVAL_PWMSYNC - Value register updated on PWM sync.
The CMPSS_DACREF_xxx term can take on the following values to specify which voltage supply is used as reference for the DACs:
- CMPSS_DACREF_VDDA - VDDA is the voltage reference for the DAC.
- CMPSS_DACREF_VDAC - VDAC is the voltage reference for the DAC.
The CMPSS_DACSRC_xxx term can take on the following values to specify the DAC value source for the high comparator's internal DAC:
- CMPSS_DACSRC_SHDW - The user-programmed DACVALS register.
- CMPSS_DACSRC_RAMP - The ramp generator RAMPSTS register
- Note
- The CMPSS_DACVAL_xxx and CMPSS_DACREF_xxx terms apply to both the high and low comparators. CMPSS_DACSRC_xxx will only affect the high comparator's internal DAC.
- Returns
- None.
static void CMPSS_configBlanking |
( |
uint32_t |
base, |
|
|
uint16_t |
pwmBlankSrc |
|
) |
| |
|
inlinestatic |
Sets the ePWM module blanking signal that holds trip in reset.
- Parameters
-
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.
- Returns
- None.
void CMPSS_configFilterHigh |
( |
uint32_t |
base, |
|
|
uint16_t |
samplePrescale, |
|
|
uint16_t |
sampleWindow, |
|
|
uint16_t |
threshold |
|
) |
| |
Configures the digital filter of the high comparator.
- Parameters
-
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:
- Configure and enable the comparator using CMPSS_configHighComparator() and CMPSS_enableModule()
- Configure the digital filter using CMPSS_configFilterHigh()
- Initialize the sample values using CMPSS_initFilterHigh()
- Configure the module output signals CTRIP and CTRIPOUT using CMPSS_configOutputsHigh()
- Returns
- None.
void CMPSS_configFilterLow |
( |
uint32_t |
base, |
|
|
uint16_t |
samplePrescale, |
|
|
uint16_t |
sampleWindow, |
|
|
uint16_t |
threshold |
|
) |
| |
Configures the digital filter of the low comparator.
- Parameters
-
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:
- Configure and enable the comparator using CMPSS_configLowComparator() and CMPSS_enableModule()
- Configure the digital filter using CMPSS_configFilterLow()
- Initialize the sample values using CMPSS_initFilterLow()
- Configure the module output signals CTRIP and CTRIPOUT using CMPSS_configOutputsLow()
- Returns
- None.
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.
- Parameters
-
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.
- Returns
- None.