Component - 1.2 Volt Comparator (CSD Comp) v1.0

®
PSoC Creator™ Component Datasheet
1.2 Volt Comparator (CSD Comp)
1.0
Features
 Two speed modes
 Any pin in Port 0, Port 1 and Port 2 can be connected to the noninverting input

The inverting input is connected to a 1.2 V reference
General Description
The 1.2 Volt Comparator (CSD_Comp) component provides a hardware solution to compare one
input voltage with the internal 1.2 V reference (Vref) of the PSoC 4000 family of devices. The
CSD_Comp component makes use of the comparator that is present in the Capacitive Sensing
Delta-Sigma Modulator (CapSense® CSD) block. This comparator functionality is only present on
the PSoC 4000 family of devices and only available when not using the CapSense CSD block for
Capacitive Sensing. You can sample the output in software or route it to a GPIO. There are two
speed levels to allow you to optimize for response time or power consumption.
Although the CSD_Comp operates from a fixed Vref, it can be made to trigger at different voltage
levels using external/internal components. With the help of an additional GPIO, the CSD_Comp
can be used to generate interrupts. The CSD_Comp can also be operated with multiplexed
inputs. Refer to the Functional Description section for more information.
When to Use the CSD_Comp
The CSD_Comp can be used in many applications to monitor external voltages and analog
signals from transducers. Such applications include a thermal printer, a battery monitor, and an
on-off controller.
Note This CSD_Comp component uses resources from the PSoC 4 CapSense CSD block.
Therefore, the CSD_Comp cannot be used in applications that also require capacitive sensing.
Cypress Semiconductor Corporation • 198 Champion Court • San Jose, CA 95134-1709 • 408-943-2600
Document Number: 001-90677 Rev. **
Revised March 23, 2014
1.2 Volt Comparator (CSD Comp)
®
PSoC Creator™ Component Datasheet
Input/Output Connections
This section describes the various input and output connections for the CSD_Comp.
Non-inverting Input – Analog Input
This input is usually connected to the voltage that is being compared. This input can be routed
from any GPIO in Port 0, Port 1 and Port 2.
Comparator Out – output
This is the digital comparison output. This output goes high when the non-inverting input voltage
is greater than the Vref. The CSD_Comp output is always asynchronous.
Note The output can be routed only to three dedicated pins: P0[1], P0[4] or P1[6].
Component Parameters
Drag a CSD_Comp onto your design and double-click it to open the Configure dialog.
Configure Tab
Speed/Power
This parameter provides a way to optimize speed versus power consumption. The Speed/Power
parameter provides two levels: Slow/Low and Fast/High. The High Power mode gives better
response time.
Page 2 of 11
Document Number: 001-90677 Rev. **
®
PSoC Creator™ Component Datasheet
1.2 Volt Comparator (CSD Comp)
Placement
The CSD_Comp is placed as a Fixed Function block and all placement information is provided to
the API through the cyfitter.h file.
Resources
The CSD_Comp uses the AMUXBUS-A and Sense Comparator from the CSD fixed-function
block.
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.
Configuration
PSoC 4000 (GCC)
Flash Bytes
SRAM Bytes
332
2
Default
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 “CSD_Comp_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
“CSD_Comp”.
Function
Description
CSD_Comp_Start()
Performs all of the required initialization for the component, enables power to the
CSD block and enables the comparator.
CSD_Comp_Stop()
Turns off the Comparator block.
CSD_Comp_Init()
Initializes or restores the component according to the customizer Configure dialog
settings.
Document Number: 001-90677 Rev. **
Page 3 of 11
®
1.2 Volt Comparator (CSD Comp)
PSoC Creator™ Component Datasheet
Function
Description
CSD_Comp_Enable()
Activates the hardware and begins component operation.
CSD_Comp_GetCompare()
Returns compare result.
CSD_Comp_SetSpeed()
Sets the power and speed to one of two settings: SLOW_SPEED or FAST_SPEED.
CSD_Comp_Sleep()
Prepare the component for sleep.
CSD_Comp_Wakeup()
Restore the component to the state when Comp_Sleep() was called.
Global Variables
Knowledge of these variables is not required for normal operations.
Function
CSD_Comp_initVar
Description
Indicates whether or not the Comparator has been initialized. The variable is initialized to
0 and set to 1 the first time Comp_Start() is called. This allows the component to restart
without reinitialization after the first call to the Comp_Start() routine.
If reinitialization of the component is required, call Comp_Init() before calling
Comp_Start(). Alternatively, the Comparator can be reinitialized by calling the Comp_Init()
and Comp_Enable() functions
void CSD_Comp_Start(void)
Description:
Performs all of the required initialization for the component, enables power to the CSD
block and enables the comparator. The first time the routine is executed the power level is
set. When called to restart the comparator following a Stop() call, the current component
parameter settings are retained.
Parameters:
None
Return Value:
None
Side Effects:
None
void CSD_Comp_Stop(void)
Description:
Disable the comparator. Power to the CSD block remains enabled. All other comparator
settings remain unchanged and will continue to be the settings used when the comparator
becomes active again by calling Start().
Parameters:
None
Return Value:
None
Side Effects:
None
Page 4 of 11
Document Number: 001-90677 Rev. **
®
PSoC Creator™ Component Datasheet
1.2 Volt Comparator (CSD Comp)
void CSD_Comp_Init(void)
Description:
Initializes or restores the component according to the customizer Configure dialog settings.
It is not necessary to call Init() because the Start() API calls this function and is the
preferred method to begin component operation.
Parameters:
None
Return Value:
None
Side Effects:
None
void CSD_Comp_Enable(void)
Description:
Activates the hardware and begins component operation. It is not necessary to call
Enable() because the Start() API calls this function, which is the preferred method to begin
component operation.
Parameters:
None
Return Value:
None
Side Effects:
None
uint32 CSD_Comp_GetCompare(void)
Description:
This function returns a nonzero value when the voltage connected to the non-inverting
input is greater than the Vref.
Parameters:
None
Return Value:
uint32: Comparator output state. Nonzero value when the non-inverting input voltage is
greater than the Vref; otherwise, the return value is zero.
Side Effects:
None
void CSD_Comp_SetSpeed(uint32 speed)
Description:
Parameters:
Sets the speed to one of two settings: slow or fast.
(uint32) speed: Comparator response time parameter. See table below.
Value
Description
CSD_Comp_SLOW_SPEED
Use this setting for very low power applications
CSD_Comp_FAST_SPEED
Use this setting for fastest response time (50 nsec)
Return Value:
None
Side Effects:
None
Document Number: 001-90677 Rev. **
Page 5 of 11
®
1.2 Volt Comparator (CSD Comp)
PSoC Creator™ Component Datasheet
void CSD_Comp_Sleep(void)
Description:
Prepare the component for sleep. Call the Sleep() function before calling the
CySysPmDeepSleep() functions.
Parameters:
None
Return Value:
None
Side Effects:
None
void CSD_Comp_Wakeup(void)
Description:
Restore the component to the state when Sleep() was called. If the component was
enabled before the Sleep() function was called, the Wakeup() function will also re-enable
the component.
Parameters:
None
Return Value:
None
Side Effects:
Calling the Wakeup() function without first calling the Sleep() function may produce
unexpected behavior.
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
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 Comparator component has the following specific deviations:
MISRA-C:
2004 Rule
19.7
Rule
1
Class
A
Rule Description
A function should be used in
preference to a function-like macro.
Description of Deviation(s)
Deviated since function-like macros are used to
allow more efficient code.
This component has the following embedded component: Clock. Refer to the corresponding
component datasheet for information on its MISRA compliance and specific deviations.
1
Required / Advisory
Page 6 of 11
Document Number: 001-90677 Rev. **
®
PSoC Creator™ Component Datasheet
1.2 Volt Comparator (CSD Comp)
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
This component uses the sense comparator in the CSD fixed-function block of the PSoC 4000
family of devices. The inverting input of this comparator is connected to a fixed reference of
1.2 V. The non-inverting input can be connected to any pins in Port 0, Port 1 and Port 2 using
AMUXBUS-A. The output can be routed to any of the three dedicated pins P0[1], P0[4] or P1[6].
When the input voltage at the non-inverting input is above the Vref, the comparator output
(comp_out) will be at a logic HIGH state. When the input voltage is below the reference, the
output will be at a logic LOW state.
The component uses the CSD_CONFIG register to enable, disable and select the speed of the
comparator. The CSD_STATUS register could be used for polling via the GetCompare() API. A
high-level block diagram is shown below. Refer to the appropriate device Technical Reference
Manual (TRM) for a detailed description of each register.
Document Number: 001-90677 Rev. **
Page 7 of 11
1.2 Volt Comparator (CSD Comp)
®
PSoC Creator™ Component Datasheet
Interrupt generation
There are no Interrupts available with the Comparator component. But with the help of an
additional GPIO, the comparator can be used to generate interrupts. For this the comparator
output pin should be externally connected to another GPIO as shown in the image below.
Multiplexed operation
By using an Analog Multiplexer component (AMuxbus_A), the input of the comparator can be
multiplexed to all available GPIOs in Ports 0, 1 and 2.
Page 8 of 11
Document Number: 001-90677 Rev. **
®
PSoC Creator™ Component Datasheet
1.2 Volt Comparator (CSD Comp)
Operating at a voltage level above 1.2 V
By using an external resistive divider, the comparator can be used to detect voltages above
1.2 V. The output transition happens when Vin goes above/below 1.2*(1 + R1/R2) volts. The R1
and R2 must have high values to reduce errors due to source resistance.
Operating at a voltage level below 1.2 V
By using an IDAC and an external resistive divider, the comparator can be used to detect
voltages below 1.2 V. The output transition happens when Vin goes above/below 1.2*(1 +
R1/R2) − (R1*IDAC) volts.
Document Number: 001-90677 Rev. **
Page 9 of 11
®
1.2 Volt Comparator (CSD Comp)
PSoC Creator™ Component Datasheet
Wakeup from Deep-Sleep Mode
This component operates in Active power mode only. The following is the correct Deep-Sleep
mode entry procedure:
/* Prepares Comparator to wake up from Sleep mode */
Comp_Sleep();
/* Switches to the Deep-Sleep mode */
CySysPmDeepSleep();
/* Prepares Comparator to work in Active mode */
Comp_Wakeup();
Registers
See the device Technical Reference Manual for more information about registers.
Component Debug Window
The Comparator component supports the PSoC Creator component debug window. Refer to the
appropriate device Technical Reference Manual for a detailed description of each register. The
following registers are displayed in the Comparator component debug window:


CONFIG – Configuration register
STATUS – Status register
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.
DC Specifications
Parameter
Description
Min
Typ
Max
Units
ICMP1
Block current, High
Bandwidth mode
–
–
120
μA
ICMP2
Block current, Low Power
mode
–
–
90
μA
VOFFSET1
Offset voltage, High
Bandwidth mode
–
10
30
mV
VOFFSET2
Offset voltage, Low Power
mode
–
10
30
mV
Page 10 of 11
Conditions
Document Number: 001-90677 Rev. **
®
PSoC Creator™ Component Datasheet
Parameter
Description
1.2 Volt Comparator (CSD Comp)
Min
Typ
Max
Units
ZCMP
DC input impedance of
comparator
35
-
-
MΩ
VINP_COMP
Comparator input range
0
-
3.6
V
Min
Typ
Max
Units
Conditions
Max input voltage is lower of 3.6 V or
VDD
AC Specifications
Parameter
Description
TCOMP1
Response Time High
Bandwidth mode, 50-mV
overdrive
–
–
50
ns
TCOMP2
Response Time Low
Power mode, 50-mV
overdrive
–
–
100
ns
Conditions
Component Changes
This section lists the major changes in the component from the previous version.
Version
1.0
Description of Changes
First component version.
Reason for Changes / Impact
First component version.
© Cypress Semiconductor Corporation, 2014. 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 lifesupport 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-90677 Rev. **
Page 11 of 11
Similar pages