dac12  2.0.0.0
Main Page

DAC 12 click

DAC 12 Click is a compact add-on board that contains a highly accurate digital-to-analog converter. This board features the DAC60508, a general-purpose octal 12-bit analog voltage-output DAC from Texas Instruments. It includes a 2.5V, 5ppm/°C internal reference, eliminating the need for an external precision reference in most applications, and supports the SPI serial interface, which operates at clock rates up to 40MHz. A user interface-selectable gain configuration provides full-scale output voltages of 1.25V, 2.5V, or 5 V. This Click board™ represents an excellent choice for digital gain and offset adjustment applications, programmable voltage, and current sources, programmable reference, and many more.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Feb 2022.
  • Type : SPI type

Software Support

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

Standard key functions :

Example key functions :

  • dac12_soft_reset This function executes the software reset command.
    err_t dac12_soft_reset ( dac12_t *ctx );
  • dac12_set_channel_value This function sets the raw DAC value to the specific channels output.
    err_t dac12_set_channel_value ( dac12_t *ctx, uint8_t channel, uint16_t dac_value );
  • dac12_set_channel_voltage This function sets the output voltage of the specific channels.
    err_t dac12_set_channel_voltage ( dac12_t *ctx, uint8_t channel, float voltage );

Example Description

This example demonstrates the use of DAC 12 click board by changing the outputs voltage level every 2 seconds.

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;
dac12_cfg_t dac12_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
dac12_cfg_setup( &dac12_cfg );
DAC12_MAP_MIKROBUS( dac12_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == dac12_init( &dac12, &dac12_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( DAC12_ERROR == dac12_default_cfg ( &dac12 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Changes the output voltage of all channels every 2 seconds and logs the voltage value on the USB UART.

It will go through the entire voltage range taking into account the number of steps which is defined below.

void application_task ( void )
{
float output_voltage = step;
for ( uint8_t cnt = 0; cnt < NUMBER_OF_STEPS; cnt++ )
{
if ( DAC12_OK == dac12_set_channel_voltage ( &dac12, DAC12_SELECT_CHANNEL_ALL, output_voltage ) )
{
log_printf( &logger, " All channels output voltage set to %.3f V\r\n", output_voltage );
output_voltage += step;
Delay_ms( 2000 );
}
}
}

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.DAC12

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.


dac12_cfg_t
DAC 12 Click configuration object.
Definition: dac12.h:208
dac12_set_channel_value
err_t dac12_set_channel_value(dac12_t *ctx, uint8_t channel, uint16_t dac_value)
DAC 12 set channel value function.
DAC12_SET_DATA_SAMPLE_EDGE
#define DAC12_SET_DATA_SAMPLE_EDGE
Data sample selection.
Definition: dac12.h:160
application_task
void application_task(void)
Definition: main.c:68
dac12_set_channel_voltage
err_t dac12_set_channel_voltage(dac12_t *ctx, uint8_t channel, float voltage)
DAC 12 set channel voltage function.
dac12_default_cfg
err_t dac12_default_cfg(dac12_t *ctx)
DAC 12 default configuration function.
DAC12_INTERNAL_VREF
#define DAC12_INTERNAL_VREF
DAC 12 vref values.
Definition: dac12.h:131
NUMBER_OF_STEPS
#define NUMBER_OF_STEPS
Definition: main.c:26
DAC12_OK
@ DAC12_OK
Definition: dac12.h:228
DAC12_SELECT_CHANNEL_ALL
#define DAC12_SELECT_CHANNEL_ALL
Definition: dac12.h:112
dac12_t
DAC 12 Click context object.
Definition: dac12.h:193
application_init
void application_init(void)
Definition: main.c:31
DAC12_ERROR
@ DAC12_ERROR
Definition: dac12.h:229
dac12_init
err_t dac12_init(dac12_t *ctx, dac12_cfg_t *cfg)
DAC 12 initialization function.
DAC12_MAP_MIKROBUS
#define DAC12_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: dac12.h:179
dac12_cfg_setup
void dac12_cfg_setup(dac12_cfg_t *cfg)
DAC 12 configuration object setup function.
dac12_soft_reset
err_t dac12_soft_reset(dac12_t *ctx)
DAC 12 soft reset function.