Sample and Hold Functions

group group_ctb_functions_sample_hold

This function enables sample and hold of the CTDAC output.

Functions

void Cy_CTB_DACSampleAndHold(CTBM_Type *base, cy_en_ctb_sample_hold_mode_t mode)

Perform sampling and holding of the CTDAC output.

To perform a sample or a hold, a preparation step must first be executed to open the required switches. Because of this, each sample or hold requires three function calls:

  1. Call this function to prepare for a sample or hold

  2. Enable or disable the CTDAC output

  3. Call this function again to perform a sample or hold

It takes 10 us to perform a sample of the CTDAC output to provide time for the capacitor to settle to the new value.

    /* Scenario: Opamp0 has been configured as a buffer for the CTDAC output
     * with the sample and hold (S/H) capacitor connected.
     * This code samples the CTDAC output once. */
    
    /* Prepare for sample. */
    Cy_CTB_DACSampleAndHold(CTBM0, CY_CTB_SH_PREPARE_SAMPLE);
    
    /* Turn on DAC output. */
    Cy_CTDAC_SetOutputMode(CTDAC0, CY_CTDAC_OUTPUT_VALUE);
    
    /* Sample DAC output. */
    Cy_CTB_DACSampleAndHold(CTBM0, CY_CTB_SH_SAMPLE);
    
    /* Allow time for voltage to settle across the hold capacitor. */
    Cy_SysLib_DelayUs(10);
    /* Scenario: Turn off the CTDAC output to save power and
     * hold the output voltage across the S/H capcitor. 
     * The DAC output needs to be turned on and sampled periodically.
     * See the device datasheet for the hold duration. */
    
    /* Prepare for hold. */
    Cy_CTB_DACSampleAndHold(CTBM0, CY_CTB_SH_PREPARE_HOLD);
    
    /* Turn off DAC output. */
    Cy_CTDAC_SetOutputMode(CTDAC0, CY_CTDAC_OUTPUT_HIGHZ);
    
    /* Hold voltage. */
    Cy_CTB_DACSampleAndHold(CTBM0, CY_CTB_SH_HOLD);
        
Return

None

Function Usage

Function Usage

Parameters
  • base: Pointer to structure describing registers

  • mode: Mode to prepare or perform a sample or hold, or disable the ability