TOP Contributors

  1. MIKROE (2751 codes)
  2. Alcides Ramos (372 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139059 times)
  2. FAT32 Library (71589 times)
  3. Network Ethernet Library (56988 times)
  4. USB Device Library (47330 times)
  5. Network WiFi Library (43006 times)
  6. FT800 Library (42297 times)
  7. GSM click (29774 times)
  8. mikroSDK (27874 times)
  9. PID Library (26858 times)
  10. microSD click (26129 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

DAC 16 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.2

mikroSDK Library: 2.0.0.0

Category: DAC

Downloaded: 22 times

Not followed.

License: MIT license  

DAC 16 Click is a compact add-on board, a digital-to-analog converter (DAC) designed for precise voltage and current output applications. This board features the DAC63204-Q1, an automotive-qualified 12-bit DAC from Texas Instruments. This Click board™ features four output channels with flexible configuration options, including adjustable voltage gains and selectable current ranges from ±25μA to ±250μA. It also supports both internal and external voltage references and offers a Hi-Z power-down mode for enhanced protection. Communication with the host MCU is enabled through either a 4-wire SPI or I2C interface, with configurable I2C addresses and a general-purpose I/O pin for additional functionality.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "DAC 16 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "DAC 16 Click" changes.

Do you want to report abuse regarding "DAC 16 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


DAC 16 Click

DAC 16 Click is a compact add-on board, a digital-to-analog converter (DAC) designed for precise voltage and current output applications. This board features the DAC63204-Q1, an automotive-qualified 12-bit DAC from Texas Instruments. This Click board™ features four output channels with flexible configuration options, including adjustable voltage gains and selectable current ranges from ±25μA to ±250μA. It also supports both internal and external voltage references and offers a Hi-Z power-down mode for enhanced protection. Communication with the host MCU is enabled through either a 4-wire SPI or I2C interface, with configurable I2C addresses and a general-purpose I/O pin for additional functionality.

dac16_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Apr 2024.
  • Type : I2C/SPI type

Software Support

We provide a library for the DAC 16 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for DAC 16 Click driver.

Standard key functions :

  • dac16_cfg_setup Config Object Initialization function.

    void dac16_cfg_setup ( dac16_cfg_t *cfg );
  • dac16_init Initialization function.

    err_t dac16_init ( dac16_t *ctx, dac16_cfg_t *cfg );
  • dac16_default_cfg Click Default Configuration function.

    err_t dac16_default_cfg ( dac16_t *ctx );

Example key functions :

  • dac16_set_dac_data This function sets the raw DAC data for the selected DAC channel.

    err_t dac16_set_dac_data ( dac16_t *ctx, uint8_t dac, uint16_t dac_data );
  • dac16_start_function_gen This function starts the function generator for the selected DAC channel.

    err_t dac16_start_function_gen ( dac16_t *ctx, uint8_t dac );
  • dac16_stop_function_gen This function stops the function generator for the selected DAC channel.

    err_t dac16_stop_function_gen ( dac16_t *ctx, uint8_t dac );

Example Description

This example demonstrates the use of DAC 16 Click board by changing the voltage level on the OUT0 as well as the waveform signals from a function generator on the OUT1.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    dac16_cfg_t dac16_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    dac16_cfg_setup( &dac16_cfg );
    DAC16_MAP_MIKROBUS( dac16_cfg, MIKROBUS_1 );
    err_t init_flag = dac16_init( &dac16, &dac16_cfg );
    if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( DAC16_ERROR == dac16_default_cfg ( &dac16 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

Application Task

Changes the voltage level on the OUT0 as well as the waveform signals from a function generator on the OUT1 every 3 seconds. The state of all outputs will be displayed on the USB UART.

void application_task ( void )
{
    static uint16_t dac = 0;
    static uint8_t waveform = DAC16_WAVEFORM_TRIANGULAR;
    if ( DAC16_OK == dac16_set_dac_data ( &dac16, DAC16_SEL_DAC_0, dac ) )
    {
        log_printf( &logger, "\r\n OUT0: %u -> %.2f V\r\n", 
                    dac, ( float ) dac * DAC16_VDD_3V3 / DAC16_DAC_DATA_MAX );
        dac += 100;
        if ( dac > DAC16_DAC_DATA_MAX )
        {
            dac = DAC16_DAC_DATA_MIN;
        }
    }
    err_t error_flag = dac16_stop_function_gen ( &dac16, DAC16_SEL_DAC_1 );
    error_flag |= dac16_config_function_gen ( &dac16, DAC16_SEL_DAC_1, waveform,
                                              DAC16_CODE_STEP_32_LSB, DAC16_SLEW_RATE_4_US );
    error_flag |= dac16_start_function_gen ( &dac16, DAC16_SEL_DAC_1 );
    if ( DAC16_OK == error_flag )
    {
        log_printf( &logger, " OUT1: " );
        switch ( waveform )
        {
            case DAC16_WAVEFORM_TRIANGULAR:
            {
                log_printf( &logger, "triangular wave at about 1kHz\r\n" );
                waveform = DAC16_WAVEFORM_SAWTOOTH;
                break;
            }
            case DAC16_WAVEFORM_SAWTOOTH:
            {
                log_printf( &logger, "sawtooth wave at about 2kHz\r\n" );
                waveform = DAC16_WAVEFORM_INV_SAWTOOTH;
                break;
            }
            case DAC16_WAVEFORM_INV_SAWTOOTH:
            {
                log_printf( &logger, "inverse sawtooth wave at about 2kHz\r\n" );
                waveform = DAC16_WAVEFORM_SINE;
                break;
            }
            case DAC16_WAVEFORM_SINE:
            {
                log_printf( &logger, "sine wave at about 10.5kHz\r\n" );
                waveform = DAC16_WAVEFORM_DISABLE;
                break;
            }
            case DAC16_WAVEFORM_DISABLE:
            {
                log_printf( &logger, "function generator disabled\r\n" );
                waveform = DAC16_WAVEFORM_TRIANGULAR;
                break;
            }
            default:
            {
                log_printf( &logger, "unknown state\r\n" );
                break;
            }
        }
        // OUT2 and OUT3 are set in dac16_default_cfg
        log_printf( &logger, " OUT2: sine wave at about 10.5kHz\r\n" );
        log_printf( &logger, " OUT3: sawtooth wave at about 2kHz\r\n" );
    }
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.DAC16

Additional notes and informations

Depending on the development board you are using, you may need USB UART Click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


ALSO FROM THIS AUTHOR

Stepper 4 click

0

Stepper 4 click carries a TB67S269FTG - a two-phase bipolar stepping motor driver using a PWM chopper, with a clock in decoder built in. Rating is 50 V/2.0 A. Microstepping resolution is externally manipulated, as well as output current scaling.

[Learn More]

Angle 3 click

6

Angle 3 click carries the AK7451, a magnetic rotational angle sensor. The click is designed to run on a 5V power supply. It communicates with the target microcontroller over SPI interface.

[Learn More]

AudioAmp 6 click

5

Audio Amp 6 click is a mono/subwoofer audio amplifier, capable of delivering up to 18.5W per channel with the 4Ω load. It is based on the TPA3138D2, a class-D integrated amplifier, which utilizes a highly efficient switching scheme.

[Learn More]