PSoC 6 Peripheral Driver Library
LVD (Low-Voltage-Detect)

General Description

The LVD driver provides an API to manage the Low Voltage Detection block.

The functions and other declarations used in this driver are in cy_lvd.h. You can include cy_pdl.h to get access to all functions and declarations in the PDL.

The LVD block provides a status of currently observed VDDD voltage and triggers an interrupt when the observed voltage crosses an adjusted threshold.

Configuration Considerations

To set up an LVD, configure the voltage threshold by the Cy_LVD_SetThreshold function, ensure that the LVD block itself and LVD interrupt are disabled (by the Cy_LVD_Disable and Cy_LVD_ClearInterruptMask functions correspondingly) before changing the threshold to prevent propagating a false interrupt. Then configure interrupts by the Cy_LVD_SetInterruptConfig function, do not forget to initialize an interrupt handler (the interrupt source number is srss_interrupt_IRQn). Then enable LVD by the Cy_LVD_Enable function, then wait for at least 20us to get the circuit stabilized and clear the possible false interrupts by the Cy_LVD_ClearInterrupt, and finally the LVD interrupt can be enabled by the Cy_LVD_SetInterruptMask function.

For example:

Note that the LVD circuit is available only in Low Power and Ultra Low Power modes. If an LVD is required in Deep Sleep mode, then the device should be configured to periodically wake up from Deep Sleep using a Deep Sleep wakeup source. This makes sure a LVD check is performed during Low Power or Ultra Low Power modes.

More Information

See the LVD chapter of the device technical reference manual (TRM).

MISRA-C Compliance

The LVD driver has the following specific deviations:

MISRA Rule Rule Class (Required/Advisory) Rule Description Description of Deviation(s)
10.3 R A composite expression of 'essentially unsigned' type (%1s) is being cast to a different type category, '%2s'. The value got from the bitfield physically can't exceed the enumeration that describes this bitfield. So the code is safety by design.
16.7 A The object addressed by the pointer parameter 's' is not modified and so the pointer could be of type 'pointer to const'. The pointer parameter is not used or modified, as there is no need to do any actions with it. However, such parameter is required to be presented in the function, because the Cy_LVD_DeepSleepCallback is a callback of cy_en_syspm_status_t type. The SysPM driver callback function type requires implementing the function with the next parameters and return value:
cy_en_syspm_status_t (*Cy_SysPmCallback) (cy_stc_syspm_callback_params_t *callbackParams);


VersionChangesReason of Change
1.20 Updated the following functions for the PSoC 64 devices: Cy_LVD_Enable, Cy_LVD_Disable, Cy_LVD_SetThreshold, Cy_LVD_ClearInterrupt, Cy_LVD_SetInterrupt, Cy_LVD_SetInterruptMask, Cy_LVD_ClearInterruptMask, and Cy_LVD_SetInterruptConfig. Added PSoC 64 device support.
1.10 Flattened the organization of the driver source code into the single source directory and the single include directory. Driver library directory-structure simplification.
Added register access layer. Use register access macros instead of direct register access using dereferenced pointers. Makes register access device-independent, so that the PDL does not need to be recompiled for each supported part number.
1.0.1 Added Low Power Callback section Documentation update and clarification
1.0 Initial Version

API Reference

 Enumerated Types