Contenu principal

C28x/C29x CMPSS

R2026b

Compare two input voltages on comparator pins

  • CMPSS block

Libraries:
C2000 Microcontroller Blockset / F280013x
C2000 Microcontroller Blockset / F280015x
C2000 Microcontroller Blockset / F28002x
C2000 Microcontroller Blockset / F28003x
C2000 Microcontroller Blockset / F28004x
C2000 Microcontroller Blockset / F2807x
C2000 Microcontroller Blockset / F2837xD
C2000 Microcontroller Blockset / F2837xS
C2000 Microcontroller Blockset / F2838x / C28x
C2000 Microcontroller Blockset / F28p65x
C2000 Microcontroller Blockset / F28p55x
C2000 Microcontroller Blockset / F29H85x

Description

The Comparator Subsystem consists of two modules, Comparator High (COMPH) and Comparator Low (COMPL). Each module generates a high digital output when the voltage on the first input pin (positive input) is greater than the voltage on the second input pin (negative input). Each module generates a low digital output when the voltage on the first input pin (positive input) is less than the voltage on the second input pin (negative input).

The second input pin can either be the external pin or the DAC module.

Ports

Input

expand all

The port accepts a 12-bit DAC reference value for the second input pin of the comparator.

The DAC range is between 0 and 4095. Any value outside the range is saturated.

Dependencies

The DAC port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to DAC module

  • Specify DAC/RAMP parameter(s) Via is set to Input port

Ramp reference value used by the ramp generator to create a ramp reference voltage for the second input pin of the comparator.

The REF value is in the range 0 to 65535. Any value outside the range is saturated.

Dependencies

The REF port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to RAMP module

  • Specify DAC/RAMP parameter(s) Via is set to Input port

  • This port is available only for the COMPH module.

Ramp decrement value used by the ramp generator to create a ramp reference voltage for the second input pin of the comparator.

The DEC range is between 0 and 65535. Any value outside the range is saturated.

Dependencies

The DEC port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to RAMP module

  • Specify DAC/RAMP parameter(s) Via is set to Input port

  • This port is available only for the COMPH module.

Ramp delay value used by the ramp generator to create a ramp reference voltage for the second input pin of the comparator.

The DLY range is between 0 and 8192. Any value outside the range is saturated.

Dependencies

The DLY port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to RAMP module

  • Specify DAC/RAMP parameter(s) Via is set to Input port

  • This port is available only for the COMPH module.

Signal to clear the comparator latched output. Any value greater than 0 clears the latch output.

Dependencies

The latch clear port appears only when Enable latch clear parameter is selected.

Output

expand all

The port outputs 1 if the voltage on the positive input pin is greater than the voltage on the negative input pin. Otherwise, it outputs 0.

The comparator latch output is the tripped state of the CMPSS comparator after it is digitized and qualified by a digital filter.

The latched value can either be cleared by the software or PWMSYNC.

Dependencies

To enable this port, select the Enable latch output parameter.

Parameters

expand all

Select the comparator module to configure for the comparison result.

Note

The number of available modules varies by processor.

The voltage source of second input pin (negative input pin), specified as either External pin or Internal DAC.

Select the source of the internal DAC to generate voltage for the negative input pin, specified as either DAC module or RAMP module.

Dependencies

This parameter is available only for the COMPH module.

Select whether the DAC or RAMP values are specified via the input port or from the dialog box.

When you select Input port, the block generates input ports for the comparator module.

When you set DAC source select to DAC module, the block generates the DAC port. When you set DAC source select to RAMP module, the block generates the REF, DEC, and DLY ports.

Parameter dependency

This parameter is available only for the COMPH module.

Specify the DAC value for internal DAC to generate the voltage on the negative input.

Specify the DAC initial value for internal DAC to generate the voltage on the negative input.

Dependencies

The DAC port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to DAC module

  • Specify DAC/RAMP parameter(s) Via is set to Input port

The RAMP reference value is in the range 0 to 65535. Any value outside the range is saturated.

The RAMP generator starts to decrement from the reference value.

Dependencies

The REF port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to RAMP module

  • Specify DAC/RAMP parameter(s) Via is set to Dialog

  • This port is available only for the COMPH module.

The RAMP decrement value is in the range 0 to 65535. Any value outside the range is saturated.

The RAMP generator decrements the RAMP reference value in steps of decrement value.

Dependencies

The DEC port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to RAMP module

  • Specify DAC/RAMP parameter(s) Via is set to Dialog

  • This port is available only for the COMPH module.

The RAMP delay value is in the range 0 to 8192. Any value outside the range is saturated.

The RAMP generator waits for the delay value before it starts to decrement the RAMP reference value in steps of RAMP decrement value.

Dependencies

The DLY port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to RAMP module

  • Specify DAC/RAMP parameter(s) via is set to Dialog

  • This port is available only for the COMPH module.

The RAMP initial reference value is in the range 0 to 65535. Any value outside the range is saturated.

The RAMP generator starts to decrement from the reference value.

Dependencies

The REF port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to RAMP module

  • Specify DAC/RAMP parameter(s) Via is set to Input port

  • This port is available only for the COMPH module.

The RAMP initial decrement value is in the range 0 to 65535. Any value outside the range is saturated.

The RAMP generator decrements the RAMP reference value in steps of decrement value.

Dependencies

The DEC port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to RAMP module

  • Specify DAC/RAMP parameter(s) Via is set to Input port

  • This port is available only for the COMPH module.

The RAMP initial delay value is in the range 0 to 8192. Any value outside the range is saturated.

The RAMP generator waits for the delay value before it starts to decrement the RAMP reference value in steps of RAMP decrement value.

Dependencies

The DLY port appears only when parameter:

  • Second input is set to Internal DAC

  • DAC source select is set to RAMP module

  • Specify DAC/RAMP parameter(s) via is set to Input port

  • This port is available only for the COMPH module.

The latched value of the digital filter output of the comparator.

To enable the LTH port, select this parameter.

Latch clear signals to clear the comparator latch status signal. Any value greater than 0 clears the latch signal.

To enable the LCLR port, select this parameter.

Specify the time interval between samples. To inherit sample time from an upstream block, set this parameter to -1.

Configuration of GPIO as Analog Pins

For TI F280013x and TI F280015x processors, the following table provides the mapping of GPIO pins that can be used as the analog pins for ADC and CMPSS blocks.

GPIOADCCMPSS
ModuleChannelModuleInput
GPIO12A20
C20
GPIO13A19
C19
GPIO20A17
C17
GPIO21A18
C18
GPIO28A16
C16
GPIO224A21Positive
C9
GPIO226C63Positive
GPIO227A92Positive
C84Positive
GPIO228A61Positive
GPIO230A102Negative
C10
GPIO242A33Negative
C5

For TI F28P65x processors, the following table provides the mapping of GPIO pins that can be used as the analog pins for ADC and CMPSS blocks.

GPIOADCCMPSS 
ModuleChannelModuleInput
GPIO198B3111Positive
C7
GPIO199B246Positive
C06Negative
GPIO200B256Positive
C1
GPIO201C911Positive
GPIO202C810Positive
GPIO203B3010Positive
C6
GPIO204B252Positive
C95Negative
GPIO205B285Positive
C410Negative
GPIO206B273Positive
C36Negative
GPIO207A307Positive
B67Negative
GPIO208A313Negative
B77Positive
GPIO209A67Positive
GPIO210 4 and 9Positive
A77Negative
GPIO211A88Positive
C24
GPIO212A95Positive
C258Negative
GPIO213A108Positive
C268Negative
GPIO214A118Positive
C27
GPIO215A285Positive
B45Negative
GPIO216A255Positive
B5
GPIO217B82Positive
C2810Negative
GPIO218B92Positive
C299Negative
GPIO219B104Positive
C304Negative

These pins are configured as analog pins if ADC or CMPSS blocks use them. Do not use a GPIO pin as both a digital and an analog pin. For example, GPIO12 cannot be used in a digital input or digital output block and simultaneously as ADCA input channel 20.

F29H85x CMPSS Input Mux Options

For TI F29H85x processors, the following image shows all available input mux options for CMPSS modules 1–12. The mux index (HP0–HP6, HN0–HN1, LP0–LP6, LN0–LN1) selects which analog pin is connected to the corresponding comparator input. By default, the 0th mux value is selected for all modules. The pins highlighted in green and red are the ones available on the F29H85x HSEC controlCARD.

CMPSS Input Mux Options for F29H85x with controlCARD pin availability highlighted

C28x/C29x Pin MUX Configuration

For processors starting with F28004x, F28P65x, and F29H85x, the positive and negative pin connections for COMPH and COMPL can be configured directly in the Configuration Parameters dialog box under the CMPSS settings. Use the COMPHP pin, COMPHN pin, COMPLP pin, and COMPLN pin drop-downs to select the appropriate analog input pin for each comparator module.

CMPSS Configuration Parameters showing COMPHP, COMPHN, COMPLP, and COMPLN pin drop-downs

By default, the analog pins are set to the 0th mux value for all CMPSS modules. If the default pin mapping is suitable for your hardware connections, no additional configuration is required. To use a different pin, select the desired pin from the corresponding dropdown in the Configuration Parameters.

Legacy Method

In previous releases, for using pins other than the default ones, the pin mux selection for CMPSS blocks was done by configuring the AnalogSubsysRegs registers (CMPHPMXSEL, CMPHNMXSEL, CMPLPMXSEL, CMPLNMXSEL; AGPIOCTRLx in GpioCtrlRegs) using a Register ReadWrite block in the Initialize Function subsystem or using custom code blocks. This method is no longer required because the blockset inserts the necessary code when you choose the option in the Configuration Parameters.

Multi-CPU Usage

On secondary CPUs (such as F28P65x CPU2 and F29H85x CPU2/CPU3), even though the secondary CPU has access to CMPSS peripheral registers to configure the comparator, the AnalogSubsysRegs registers that control the analog pin MUX selection (CMPHPMXSEL, CMPHNMXSEL, CMPLPMXSEL, CMPLNMXSEL; AGPIOCTRLx in GpioCtrlRegs) are not writable from CPU2 or CPU3 — only CPU1 has write access to these registers. This applies whenever specific analog pins that are AGPIO or AIO are used. If the pin mux option is selected for a secondary CPU, the CPU2 code uses IPC to ask CPU1 to configure these registers for the chosen analog pin mux options in the configuration parameters.

Version History

Introduced in R2020a

expand all

See Also