Component - PSoC4 Low Power Comparator V1.0 Datasheet.pdf

PSoC® Creator™ Component Datasheet
PSoC 4 Low Power Comparator (LPComp)
1.0
Features
 Low input offset
 User controlled offset calibration
 Multiple speed modes
 Low-power mode
 Wake from low power modes
 Multiple interrupt modes
General Description
The Low Power Comparator (LPComp) component provides access to the low power
comparators implemented using the fixed function LP comparator block that is present in
PSoC 4.
When to Use a LPComp
The main purpose of these comparators is to offer fast detection of a voltage change in normal
operating modes and ultra-low power operation in hibernate mode. The two connection options
are described as follows:


Compare two voltages on external pins.
Compare a voltage from an external pin against an internally generated signal.
The comparator output value can be inspected by the CPU. A pulse generated from a selectable
edge trigger can be used to trigger an interrupt, routed to digital logic or sent to a pin. The
selectable edge trigger signal ORed with the edge trigger signal from the other low power
comparator on the device can be used as an interrupt/wakeup source from deep-sleep or
hibernate. This combined signal is available as the output of the global signal reference
component.
Cypress Semiconductor Corporation • 198 Champion Court • San Jose, CA 95134-1709 • 408-943-2600
Document Number: 001-86289 Rev. *B
Revised March 28, 2016
PSoC 4 Low Power Comparator (LPComp)
PSoC® Creator™ Component Datasheet
Input/Output Connections
This section describes the various input and output connections for the LPComp. The symbol for
this component is annotated to denote the selection of hysteresis.
Positive Input – Analog Input
This input is usually connected to the voltage that is being compared. This input can be routed
from a GPIO or from an internal source. When connected to an internal source the GPIO that is
dedicated to this input will be consumed and not available for other uses.
Negative Input – Analog Input
This input is usually connected to the reference voltage. This input can be routed from a GPIO or
from an internal source. When connected to an internal source the GPIO that is dedicated to this
input will be consumed and not available for other uses.
interrupt –output
The edge detected comparison output. A pulse is generated when the selected edge occurs on
the internal comparison signal. The direct result of the comparator is not available as a hardware
signal. This output is normally connected to an interrupt, but can be routed to digital logic or a
GPIO.
Note: This output cannot be used to awake a part from the Low Power Modes. Global Signal
Reference interrupt signal must be used instead.
Please, refer to the Functional Description section for more details of operation in Low Power
Mode.
Page 2 of 13
Document Number: 001-86289 Rev. *B
PSoC® Creator™ Component Datasheet
PSoC 4 Low Power Comparator (LPComp)
Component Parameters
Drag a LPComp onto your design and double click it to open the Configure dialog.
Configure LPComp Dialog – General Tab
The LPComp provides the following parameters.
Hysteresis
This parameter allows you to add approximately 10 mV of hysteresis to the LPComp. This helps
to ensure that slowly moving voltages or slightly noisy voltages will not cause the output of the
LPComp to oscillate when the two input voltages are nearly equal.
Digital Filter
This parameter enables or disables the digital filter of the LPComp.
Document Number: 001-86289 Rev. *B
Page 3 of 13
PSoC® Creator™ Component Datasheet
PSoC 4 Low Power Comparator (LPComp)
Interrupt
This parameter defines the event that will cause a pulse to be generated on the interrupt
terminal. The Interrupt parameter allows you to select interrupt/output mode: Disabled, Rising
edge, Falling edge, or Both edges.
Speed/Power
This parameter provides a way for the user to optimize speed verses power consumption. The
Speed/Power parameter allows you to select the speed/power level: Slow/Ultra low power,
Medium/Medium power, Fast/High power.
Placement
Each comparator is directly connected to specific GPIOs for its inputs. The output connection is
routed to the digital fabric. Refer to the device datasheet for the part being used for the specific
physical pin connections.
Resources
This component uses one of the LP Comparators from the pair of comparators in the LP
Comparator hardware block.
Application Programming Interface
Application Programming Interface (API) routines allow you to configure the component using
software. The following table lists and describes the interface to each function. The subsequent
sections cover each function in more detail.
By default, PSoC Creator assigns the instance name "LPComp_1" to the first instance of a
component in a given design. You can rename it to any unique value that follows the syntactic
rules for identifiers. The instance name becomes the prefix of every global function name,
variable, and constant symbol. For readability, the instance name used in the following table is
"LPComp"
Functions
Function
Description
LPComp_Start()
Performs all of the required initialization for the component and enables power
to the block.
LPComp_Init()
Initializes or restores the component according to the customizer settings.
LPComp_Enable()
Activates the hardware and begins component operation.
LPComp_Stop()
Turns off the LP Comparator block.
Page 4 of 13
Document Number: 001-86289 Rev. *B
PSoC® Creator™ Component Datasheet
PSoC 4 Low Power Comparator (LPComp)
Function
Description
LPComp_GetCompare()
This function returns a nonzero value when the voltage connected to the
positive input is greater than the negative input voltage.
LPComp_SetSpeed()
Sets the power and speed to one of three settings.
LPComp_SetInterruptMode()
Sets the interrupt edge detect mode.
LPComp_GetInterruptSource()
Gets the interrupt requests.
LPComp_ClearInterrupt()
Clears the interrupt request.
LPComp_SetInterrupt()
Sets a software interrupt request.
LPComp_SetHysteresis()
Enables or disables the hysteresis setting.
LPComp_SetFilter()
Enables or disables the digital filter setting.
LPComp_ZeroCal()
Performs custom calibration of the input offset to minimize error for a specific
set of conditions.
LPComp_LoadTrim()
Writes a value into the comparator offset trim register.
Global Variables
Function
LPComp_initVar
Description
Indicates whether the Low Power Comparator has been initialized. The variable is initialized
to 0 and set to 1 the first time LPComp_Start() is called. This allows the component to
restart without reinitialization after the first call to the LPComp_Start() routine.
If reinitialization of the component is required, call LPComp_Init() before calling
LPComp_Start(). Alternatively, the Comparator can be reinitialized by calling the
LPComp_Init() and LPComp_Enable() functions
void LPComp_Start(void)
Description:
Performs all of the required initialization for the component and enables power to the block.
The first time the routine is executed, the component is initialized to the configuration from
the customizer. When called to restart the comparator following a LPComp_Stop() call, the
current component parameter settings are retained.
Parameters:
None
Return Value:
None
Side Effects:
None
Document Number: 001-86289 Rev. *B
Page 5 of 13
PSoC 4 Low Power Comparator (LPComp)
PSoC® Creator™ Component Datasheet
void LPComp_Init(void)
Description:
Initializes or restores the component according to the customizer settings. It is not
necessary to call LPComp_Init() because the LPComp_Start() API calls this function and is
the preferred method to begin component operation.
Parameters:
None
Return Value:
None
Side Effects:
None
void LPComp_Enable(void)
Description:
Activates the hardware and begins component operation. It is not necessary to call
LPComp_Enable() because the LPComp_Start() API calls this function, which is the
preferred method to begin component operation.
Parameters:
None
Return Value:
None
Side Effects:
None
void LPComp_Stop(void)
Description:
Turns off the LP Comparator.
Parameters:
None
Return Value:
None
Side Effects:
The function doesn’t change component power settings.
Page 6 of 13
Document Number: 001-86289 Rev. *B
PSoC® Creator™ Component Datasheet
PSoC 4 Low Power Comparator (LPComp)
uint32 LPComp_GetCompare(void)
Description:
This function returns a nonzero value when the voltage connected to the positive input is
greater than the negative input voltage.
Parameters:
None
Return Value:
Comparator output state. This value is not impacted by the interrupt edge detect setting.
Side Effects:
None
void LPComp_SetSpeed(uint32 speed)
Description:
Sets the power and speed to one of three settings.
Parameters:
speed: Enumerated speed mode value
Name
Description
LPComp_LOWSPEED
Slow speed / Ultra low power
LPComp_MEDSPEED
Medium speed / Medium power
LPComp_HIGHSPEED
High speed / High power
Return Value:
None
Side Effects:
None
void LPComp_SetInterruptMode(uint32 mode)
Description:
Sets the interrupt edge detect mode. This also controls the value provided on the output.
Parameters:
mode: Enumerated edge detect mode value
Name
Description
LPComp_INTR_DISABLE
Disable
LPComp_INTR_RISING
Rising edge detect
LPComp_INTR_FALLING
Falling edge detect
LPComp_INTR_BOTH
Detect both edges
Return Value:
None
Side Effects:
None
Document Number: 001-86289 Rev. *B
Page 7 of 13
PSoC® Creator™ Component Datasheet
PSoC 4 Low Power Comparator (LPComp)
uint32 LPComp_GetInterruptSource(void)
Description:
Gets the interrupt requests. This function is used with the combined interrupt signal from
the global signal reference. This function from either component instance can be used to
determine the interrupt source for both the interrupts combined.
Parameters:
None
Return Value:
Interrupt source. Each component instance has a mask value: LPComp_INTR_MASK.
Side Effects:
None
void LPComp_ClearInterrupt(uint32 interruptMask)
Description:
Clears the interrupt request. This function is used with the combined interrupt signal from
the global signal reference. This function from either component instance can be used to
clear either or both interrupts.
Parameters:
interruptMask: Mask of interrupts to clear. Each component instance has a mask value:
LPComp_INTR_MASK.
Return Value:
None
Side Effects:
None
void LPComp_SetInterrupt(uint32 interruptMask)
Description:
Sets a software interrupt request. This function is used with the combined interrupt signal
from the global signal reference. This function from either component instance can be used
to trigger either or both software interrupts.
Parameters:
interruptMask: Mask of interrupts to set. Each component instance has a mask value:
LPComp_INTR_MASK.
Return Value:
None
Side Effects:
None
void LPComp_SetHysteresis(uint32 hysteresis)
Description:
Enables or disables the hysteresis setting.
Parameters:
hysteresis: Hysteresis enable
Name
LPComp_HYST_ENABLE
Enable hysteresis
LPComp_HYST_DISABLE
Disable hysteresis
Return Value:
None
Side Effects:
None
Page 8 of 13
Description
Document Number: 001-86289 Rev. *B
PSoC® Creator™ Component Datasheet
PSoC 4 Low Power Comparator (LPComp)
void LPComp_SetFilter(uint32 filter)
Description:
Enables or disables the digital filter setting.
Parameters:
filter: filter enable
Name
Description
LPComp_FILT_ENABLE
Enable filter
LPComp_FILT_DISABLE
Disable filter
Return Value:
None
Side Effects:
None
uint32 LPComp_ZeroCal(void)
Description:
Performs custom calibration of the input offset to minimize error for a specific set of
conditions: comparator reference voltage, supply voltage, and operating temperature. A
reference voltage in the range at which the comparator will be used must be applied to the
negative input. The positive input will be disconnected from the external source and
shorted internally to the negative input to perform the offset calibration.
Parameters:
None
Return Value:
The value from the comparator trim register after the offset calibration is complete. This
value has the same format as the input parameter for the LPComp_LoadTrim() API routine.
Side Effects:
During this function the positive input terminal is disconnected. This may impact other
components that are also using this signal.
void LPComp_LoadTrim(uint32 trimVal)
Description:
This function writes a value into the comparator offset trim register.
Parameters:
trimVal: Value to be stored in the comparator offset trim register. This value has the same
format as the parameter returned by the LPComp_ZeroCal() API routine.
Return Value:
None
Side Effects:
None
MISRA Compliance
This section describes the MISRA-C:2004 compliance and deviations for the component. There
are two types of deviations defined:


project deviations – deviations that are applicable for all PSoC Creator components
specific deviations – deviations that are applicable only for this component
Document Number: 001-86289 Rev. *B
Page 9 of 13
PSoC 4 Low Power Comparator (LPComp)
PSoC® Creator™ Component Datasheet
This section provides information on component-specific deviations. Project deviations are
described in the MISRA Compliance section of the System Reference Guide along with
information on the MISRA compliance verification environment.
The Low Power Comparator does not have any specific deviations.
Sample Firmware Source Code
PSoC Creator provides numerous example projects that include schematics and example code
in the Find Example Project dialog. For component-specific examples, open the dialog from the
Component Catalog or an instance of the component in a schematic. For general examples,
open the dialog from the Start Page or File menu. As needed, use the Filter Options in the
dialog to narrow the list of projects available to select.
Refer to the "Find Example Project" topic in the PSoC Creator Help for more information.
Functional Description
The Low Power Comparator is intended to be operational in all power modes, including
Hibernate/Deep Sleep. The main purpose of this component is to offer fast detection capability in
normal operating modes and ultra-low power operation in hibernate mode.
LPComp can be offset calibrated. However, even without trim, the offset is around 10 mV, and
thus it is not recommended to trim it.
Operation in Low Power Mode
Low Power Comparator operates in Deep Sleep/Hibernate Mode only if Speed/Power option is
set to Slow/Ultra Low. The component input pins must be assigned to dedicated inputs only
(P0[0], P0[1] for LPCOMP0, and P0[2], P0[3] for LPCOMP1):
Page 10 of 13
Document Number: 001-86289 Rev. *B
PSoC® Creator™ Component Datasheet
PSoC 4 Low Power Comparator (LPComp)
This component can be used along with the Global Signal component as a wakeup source from
Deep Sleep/Hibernate mode as shown below:
The option “Combined low power comparator interrupt (LPCompInt)” should be selected as a
source for an interrupt in the Global Signal Reference component. This component triggers the
output each time any of the enabled low power comparators generates an interrupt. The ISR
should normally clear an interrupt using LPComp_ClearInterrupt(LPComp_INTR_MASK).
Block Diagram and Configuration
This component uses cy_psoc4_lpcomp primitive.
Registers
See the chip Technical Reference Manual (TRM) for more information about registers.
API Memory Usage
The component memory usage varies significantly, depending on the compiler, device, number
of APIs used and component configuration. The following table provides the memory usage for
all APIs available in the given component configuration.
The measurements have been done with the associated compiler configured in Release mode
with optimization set for Size. For a specific design, the map file generated by the compiler can
be analyzed to determine the memory usage.
Document Number: 001-86289 Rev. *B
Page 11 of 13
PSoC® Creator™ Component Datasheet
PSoC 4 Low Power Comparator (LPComp)
PSoC 4 (GCC)
Configuration
Default
Flash
SRAM
Bytes
Bytes
484
4
DC and AC Electrical Characteristics
Specifications are valid for –40 °C ≤ TA ≤ 85 °C and TJ ≤ 100 °C, except where noted.
Specifications are valid for 1.71 V to 5.5 V, except where noted.
LPComp DC Specifications
Parameter
Description
Min
Typ
Max
Units
Conditions
VOFFSET2
Input offset voltage, custom trim
–
–
±4
mV
VHYST
Hysteresis when enabled
–
10
35
mV
VICM1
Input common mode voltage in
normal mode
0
–
VDDD – 0.1
V
VICM2
Input common mode voltage in low
power mode
0
–
VDDD
V
VICM2
Input common mode voltage in ultra
low power mode
0
–
VDDD – 1.15
V
CMRR
Common mode rejection ratio
50
–
–
dB
VDDD ≥ 2.7V
CMRR
Common mode rejection ratio
42
–
–
dB
VDDD < 2.7V
ICMP1
Block current, normal mode
–
–
280
µA
ICMP2
Block current, low power mode
–
–
50
µA
ICMP3
Block current, ultra low power mode
–
–
6
µA
ZCMP
DC input impedance of comparator
35
–
–
MΩ
Min
Typ
Max
Units
Modes 1 and 2
LPComp AC Specifications
Parameter
Description
Conditions
TRESP1
Response time, normal mode
–
–
38
ns
50 mV overdrive
TRESP2
Response time, low power mode
–
–
70
ns
50 mV overdrive
TRESP3
Response time, ultra low power
mode
–
–
2.3
µs
200 mV overdrive
Page 12 of 13
Document Number: 001-86289 Rev. *B
PSoC® Creator™ Component Datasheet
PSoC 4 Low Power Comparator (LPComp)
Component Changes
This section lists the major changes in the component from the previous version.
Version
Description of Changes
1.0.b
Minor datasheet edit.
1.0.a
Updated datasheet.
Reason for Changes / Impact
Removed the VOFFSET1 spec.
Updated description of the Interrupt output.
1.0
New Component
© Cypress Semiconductor Corporation, 2013-2016. The information contained herein is subject to change without notice. Cypress Semiconductor Corporation assumes no responsibility for the
use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any license under patent or other rights. Cypress products are not warranted nor intended to
be used for medical, life support, life saving, critical control, or safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its
products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress
products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
PSoC® is a registered trademark, and PSoC Creator™ and Programmable System-on-Chip™ are trademarks of Cypress Semiconductor Corp. All other trademarks or registered trademarks
referenced herein are property of the respective corporations.
Any Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide patent protection (United States and
foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use, modify, create
derivative works of, and compile the Cypress Source Code and derivative works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in
conjunction with a Cypress integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source Code except as
specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described herein.
Cypress does not assume any liability arising out of the application or use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in lifesupport systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems application
implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
Document Number: 001-86289 Rev. *B
Page 13 of 13