dac14  2.1.0.0
Main Page

DAC 14 click

DAC 14 Click is a compact add-on board providing highly accurate digital-to-analog conversion. This board features the DAC53202, a 10-bit dual-channel programmable voltage/current-output DAC from Texas Instruments. The DAC53202 supports high-speed I2C and SPI serial interface alongside Hi-Z Power-Down mode and Hi-Z output during Power-OFF conditions. It has a programmable comparator mode for both DAC channels and one general-purpose I/O pin configurable as multiple functions allowing this smart DAC for processor-less applications.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Dec 2022.
  • Type : I2C/SPI type

Software Support

We provide a library for the DAC 14 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 14 Click driver.

Standard key functions :

Example key functions :

  • dac14_set_dac_data This function sets the raw DAC data for the selected DAC channel.
    err_t dac14_set_dac_data ( dac14_t *ctx, uint8_t dac, uint16_t dac_data );
  • dac14_start_function_gen This function starts the function generator for the selected DAC channel.
    err_t dac14_start_function_gen ( dac14_t *ctx, uint8_t dac );
  • dac14_config_function_gen This function configures the function generator for the selected DAC channel.
    err_t dac14_config_function_gen ( dac14_t *ctx, uint8_t dac, uint8_t waveform, uint8_t code_step, uint8_t slew_rate );

Example Description

This example demonstrates the use of DAC 14 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;
dac14_cfg_t dac14_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
dac14_cfg_setup( &dac14_cfg );
DAC14_MAP_MIKROBUS( dac14_cfg, MIKROBUS_1 );
err_t init_flag = dac14_init( &dac14, &dac14_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( DAC14_ERROR == dac14_default_cfg ( &dac14 ) )
{
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 both outputs will be displayed on the USB UART.

void application_task ( void )
{
static uint16_t dac = 0;
static uint8_t waveform = DAC14_WAVEFORM_TRIANGULAR;
if ( DAC14_OK == dac14_set_dac_data ( &dac14, DAC14_SEL_DAC_0, dac ) )
{
log_printf( &logger, "\r\n OUT0: %u -> %.2f V\r\n",
dac, ( float ) dac * DAC14_VDD_3V3 / DAC14_DAC_DATA_MAX );
dac += 100;
if ( dac > DAC14_DAC_DATA_MAX )
{
}
}
err_t error_flag = dac14_stop_function_gen ( &dac14, DAC14_SEL_DAC_1 );
error_flag |= dac14_config_function_gen ( &dac14, DAC14_SEL_DAC_1, waveform,
error_flag |= dac14_start_function_gen ( &dac14, DAC14_SEL_DAC_1 );
if ( DAC14_OK == error_flag )
{
log_printf( &logger, " OUT1: " );
switch ( waveform )
{
{
log_printf( &logger, "triangular wave at about 4kHz\r\n" );
break;
}
{
log_printf( &logger, "sawtooth wave at about 7.8kHz\r\n" );
break;
}
{
log_printf( &logger, "inverse sawtooth wave at about 7.8kHz\r\n" );
waveform = DAC14_WAVEFORM_SINE;
break;
}
{
log_printf( &logger, "sine wave at about 10.7kHz\r\n" );
break;
}
{
log_printf( &logger, "function generator disabled\r\n" );
break;
}
default:
{
log_printf( &logger, "unknown state\r\n" );
break;
}
}
}
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.DAC14

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.


dac14_stop_function_gen
err_t dac14_stop_function_gen(dac14_t *ctx, uint8_t dac)
DAC 14 stop function gen function.
dac14_s
DAC 14 Click context object.
Definition: dac14.h:391
dac14_cfg_t
DAC 14 Click configuration object.
Definition: dac14.h:411
DAC14_WAVEFORM_SAWTOOTH
#define DAC14_WAVEFORM_SAWTOOTH
Definition: dac14.h:263
DAC14_ERROR
@ DAC14_ERROR
Definition: dac14.h:438
dac14_init
err_t dac14_init(dac14_t *ctx, dac14_cfg_t *cfg)
DAC 14 initialization function.
DAC14_DAC_DATA_MAX
#define DAC14_DAC_DATA_MAX
DAC 14 DAC setting.
Definition: dac14.h:232
DAC14_MAP_MIKROBUS
#define DAC14_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: dac14.h:357
DAC14_WAVEFORM_DISABLE
#define DAC14_WAVEFORM_DISABLE
Definition: dac14.h:266
DAC14_WAVEFORM_INV_SAWTOOTH
#define DAC14_WAVEFORM_INV_SAWTOOTH
Definition: dac14.h:264
application_task
void application_task(void)
Definition: main.c:67
DAC14_VDD_3V3
#define DAC14_VDD_3V3
DAC 14 DAC VDD setting.
Definition: dac14.h:317
DAC14_CODE_STEP_32_LSB
#define DAC14_CODE_STEP_32_LSB
Definition: dac14.h:279
dac14_cfg_setup
void dac14_cfg_setup(dac14_cfg_t *cfg)
DAC 14 configuration object setup function.
DAC14_WAVEFORM_TRIANGULAR
#define DAC14_WAVEFORM_TRIANGULAR
DAC 14 DAC waveform setting.
Definition: dac14.h:262
DAC14_SEL_DAC_1
#define DAC14_SEL_DAC_1
Definition: dac14.h:247
DAC14_OK
@ DAC14_OK
Definition: dac14.h:437
dac14_default_cfg
err_t dac14_default_cfg(dac14_t *ctx)
DAC 14 default configuration function.
DAC14_SEL_DAC_0
#define DAC14_SEL_DAC_0
DAC 14 DAC selection setting.
Definition: dac14.h:246
dac14_start_function_gen
err_t dac14_start_function_gen(dac14_t *ctx, uint8_t dac)
DAC 14 start function gen function.
DAC14_WAVEFORM_SINE
#define DAC14_WAVEFORM_SINE
Definition: dac14.h:265
dac14_set_dac_data
err_t dac14_set_dac_data(dac14_t *ctx, uint8_t dac, uint16_t dac_data)
DAC 14 set dac data function.
application_init
void application_init(void)
Definition: main.c:30
DAC14_SLEW_RATE_4_US
#define DAC14_SLEW_RATE_4_US
Definition: dac14.h:286
dac14_config_function_gen
err_t dac14_config_function_gen(dac14_t *ctx, uint8_t dac, uint8_t waveform, uint8_t code_step, uint8_t slew_rate)
DAC 14 config function gen function.
DAC14_DAC_DATA_MIN
#define DAC14_DAC_DATA_MIN
Definition: dac14.h:233