MTB CAT1 Peripheral driver library

General Description

This set of functions are for configuring basic usage of the CTDAC.

Functions

__STATIC_INLINE void Cy_CTDAC_SetValue (CTDAC_Type *base, int32_t value)
 Set the CTDAC_VAL register (DAC hardware is updated on the next PeriClk cycle). More...
 
__STATIC_INLINE void Cy_CTDAC_SetValueBuffered (CTDAC_Type *base, int32_t value)
 Set the CTDAC_VAL_NEXT register. More...
 
void Cy_CTDAC_SetSignMode (CTDAC_Type *base, cy_en_ctdac_format_t formatMode)
 Set whether to interpret the DAC value as signed or unsigned. More...
 
void Cy_CTDAC_SetDeepSleepMode (CTDAC_Type *base, cy_en_ctdac_deep_sleep_t deepSleep)
 Enable or disable the DAC hardware operation in Deep Sleep mode. More...
 
void Cy_CTDAC_SetOutputMode (CTDAC_Type *base, cy_en_ctdac_output_mode_t outputMode)
 Set the output mode of the CTDAC: More...
 
void Cy_CTDAC_SetDeglitchMode (CTDAC_Type *base, cy_en_ctdac_deglitch_t deglitchMode)
 Enable deglitching on the unbuffered path, buffered path, both, or disable deglitching. More...
 
void Cy_CTDAC_SetDeglitchCycles (CTDAC_Type *base, uint32_t deglitchCycles)
 Set the number of deglitch cycles (0 to 63) that will be used. More...
 
void Cy_CTDAC_SetRef (CTDAC_Type *base, cy_en_ctdac_ref_source_t refSource)
 Set the CTDAC reference source to Vdda or an external reference. More...
 

Function Documentation

◆ Cy_CTDAC_SetValue()

__STATIC_INLINE void Cy_CTDAC_SetValue ( CTDAC_Type base,
int32_t  value 
)

Set the CTDAC_VAL register (DAC hardware is updated on the next PeriClk cycle).

Only the least significant 12 bits have an effect. Sign extension of negative values is unnecessary and is ignored by the hardware. The way in which the CTDAC interprets the 12-bit data is controlled by Cy_CTDAC_SetSignMode.

Note
Call this function only when the update mode is set to Direct write. Calling this function for any other update mode will not have the intended effect.
Parameters
basePointer to structure describing registers
valueValue to write into the CTDAC_VAL register
Returns
None
Function Usage
/* Scenario: The update mode has been configured for Direct writes.
* To update the DAC value in this mode, Cy_CTDAC_SetValue() must be called. */
/* Output Vref/2 (unsigned mode). */
Cy_CTDAC_SetValue(CTDAC0, 0x800);
/* DAC output is updated on the next PeriClk cycle. */

◆ Cy_CTDAC_SetValueBuffered()

__STATIC_INLINE void Cy_CTDAC_SetValueBuffered ( CTDAC_Type base,
int32_t  value 
)

Set the CTDAC_VAL_NEXT register.

The value is transferred to the CTDAC_VAL register on the next edge of the CTDAC clock. Only the least significant 12 bits have an effect. Sign extension of negative values is unnecessary and is ignored by the hardware. The way in which the CTDAC interprets the 12-bit data is controlled by Cy_CTDAC_SetSignMode.

Note
Calling this function in Direct write mode will not update the DAC output. Call this function for all modes that use buffered values (i.e. uses a clock).
Parameters
basePointer to structure describing registers
valueValue to write into the CTDAC_VAL_NEXT register
Returns
None
Function Usage
/* Scenario: The update mode has been configured for Buffered writes.
* To update the DAC value in this mode, a clock is required and
* Cy_CTDAC_SetValueBuffered() is used. */
/* Output Vref/2 (signed mode). */
Cy_CTDAC_SetValueBuffered(CTDAC0, 0x000);
/* The rising edge of the DAC clock initiates an update to the DAC value.
* Wait for an interrupt to signal that the DAC is ready for a new value. */

◆ Cy_CTDAC_SetSignMode()

void Cy_CTDAC_SetSignMode ( CTDAC_Type base,
cy_en_ctdac_format_t  formatMode 
)

Set whether to interpret the DAC value as signed or unsigned.

In unsigned mode, the DAC value register is used without any decoding. In signed mode, the MSB is inverted by adding 0x800 to the DAC value. This converts the lowest signed number, 0x800, to the lowest unsigned number, 0x000.

Parameters
basePointer to structure describing registers
formatModeMode can be signed or unsigned. See cy_en_ctdac_format_t for values.
Returns
None
Function Usage
/* Set the format of the DAC value register to be signed. */

◆ Cy_CTDAC_SetDeepSleepMode()

void Cy_CTDAC_SetDeepSleepMode ( CTDAC_Type base,
cy_en_ctdac_deep_sleep_t  deepSleep 
)

Enable or disable the DAC hardware operation in Deep Sleep mode.

Parameters
basePointer to structure describing registers
deepSleepEnable or disable Deep Sleep operation. Select value from cy_en_ctdac_deep_sleep_t.
Returns
None
Function Usage
/* Scenario: The CTDAC is used as the reference voltage for a comparator
* to wake up the device from Deep Sleep mode. The comparator has been configured
* to operate in Deep Sleep mode. */
/* Keep the CTDAC on in Deep Sleep mode. */

◆ Cy_CTDAC_SetOutputMode()

void Cy_CTDAC_SetOutputMode ( CTDAC_Type base,
cy_en_ctdac_output_mode_t  outputMode 
)

Set the output mode of the CTDAC:

Parameters
basePointer to structure describing registers
outputModeSelect a value from cy_en_ctdac_output_mode_t.
Returns
None
Function Usage
/* Scenario: The Sample and Hold (S/H) capacitor in the CTB block is used to
* maintain the DAC output voltage for a duration of time so that
* the DAC output can be turned off to save power. */
/* Turn off DAC output. */
/* The DAC output will need to turn on and sampled periodically to maintain
* an acceptable voltage level across the S/H capacitor. */

◆ Cy_CTDAC_SetDeglitchMode()

void Cy_CTDAC_SetDeglitchMode ( CTDAC_Type base,
cy_en_ctdac_deglitch_t  deglitchMode 
)

Enable deglitching on the unbuffered path, buffered path, both, or disable deglitching.

The deglitch mode should match the configured output path.

Parameters
basePointer to structure describing registers
deglitchModeDeglitching mode selection. See cy_en_ctdac_deglitch_t for values.
Returns
None
Function Usage
/* Scenario: The CTDAC is configured to stay on in Deep Sleep mode.
* Before entering Deep Sleep mode, the deglitch switches must be
* turned off so that switches along the output path are guaranteed to be closed. */

◆ Cy_CTDAC_SetDeglitchCycles()

void Cy_CTDAC_SetDeglitchCycles ( CTDAC_Type base,
uint32_t  deglitchCycles 
)

Set the number of deglitch cycles (0 to 63) that will be used.

To calculate the deglitch time:

  (DEGLITCH_CNT + 1) / PERI_CLOCK_FREQ

The optimal deglitch time is 700 ns.

Parameters
basePointer to structure describing registers
deglitchCyclesNumber of cycles to deglitch
Returns
None
Function Usage
/* Scenario: The PeriClk frequency has been changed during run-time.
* Update the deglitch cycles so that the optimal deglitch time of 700 ns
* can be maintained. */
#define PERICLK_FREQ_MHZ (50)
#define DEGLITCH_TARGET_TIME_NS (700uL)
#define FACTOR_NANO_TO_MICRO (1000uL)
uint32_t deglitchCycles = ((PERICLK_FREQ_MHZ * DEGLITCH_TARGET_TIME_NS) / FACTOR_NANO_TO_MICRO) - 1uL;
Cy_CTDAC_SetDeglitchCycles(CTDAC0, deglitchCycles);

◆ Cy_CTDAC_SetRef()

void Cy_CTDAC_SetRef ( CTDAC_Type base,
cy_en_ctdac_ref_source_t  refSource 
)

Set the CTDAC reference source to Vdda or an external reference.

The external reference must come from Opamp1 of the CTB.

Parameters
basePointer to structure describing registers
refSourceThe reference source. Select a value from cy_en_ctdac_ref_source_t.
Returns
None
Function Usage
/* Scenario: Change the reference source of the CTDAC to be VDDA
* so that no buffers from the CTB are needed. */