dac17 2.1.0.0
Main Page

DAC 17 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Ilic
  • Date : Dec 2023.
  • Type : SPI type

Software Support

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

Standard key functions :

  • dac17_cfg_setup Config Object Initialization function.
    void dac17_cfg_setup(dac17_cfg_t *cfg)
    DAC 17 configuration object setup function.
    DAC 17 Click configuration object.
    Definition: dac17.h:191
  • dac17_init Initialization function.
    err_t dac17_init ( dac17_t *ctx, dac17_cfg_t *cfg );
    err_t dac17_init(dac17_t *ctx, dac17_cfg_t *cfg)
    DAC 17 initialization function.
    DAC 17 Click context object.
    Definition: dac17.h:174
  • dac17_default_cfg Click Default Configuration function.
    err_t dac17_default_cfg ( dac17_t *ctx );
    err_t dac17_default_cfg(dac17_t *ctx)
    DAC 17 default configuration function.

Example key functions :

  • dac17_send_command This function is used to send specific command of the DAC 17 click board.
    err_t dac17_send_command ( dac17_t *ctx, uint8_t command, uint8_t ch_sel, uint16_t data_in );
    err_t dac17_send_command(dac17_t *ctx, uint8_t command, uint8_t ch_sel, uint16_t data_in)
    DAC 17 send command function.
  • dac17_set_dac_output This function is used to set output level of the sellected channel of the DAC 17 click board.
    err_t dac17_set_dac_output ( dac17_t *ctx, uint8_t ch_sel, uint16_t dac_data );
    err_t dac17_set_dac_output(dac17_t *ctx, uint8_t ch_sel, uint16_t dac_data)
    DAC 17 set output level the selected channel function.
  • dac17_set_all_dac_output This function is used to set output level of the DAC 17 click board.
    err_t dac17_set_all_dac_output ( dac17_t *ctx, uint16_t dac_data );
    err_t dac17_set_all_dac_output(dac17_t *ctx, uint16_t dac_data)
    DAC 17 set output level of all channels function.

Example Description

This example demonstrates the use of DAC 17 Click board by changing the voltage level on the output channels.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
dac17_cfg_t dac17_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
dac17_cfg_setup( &dac17_cfg );
DAC17_MAP_MIKROBUS( dac17_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == dac17_init( &dac17, &dac17_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( DAC17_ERROR == dac17_default_cfg ( &dac17 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ DAC17_ERROR
Definition: dac17.h:216
#define DAC17_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: dac17.h:158
void application_init(void)
Definition: main.c:29

Application Task

Changes the output channels voltage level starting from full scale ( REF voltage ),

to the mid-scale ( half of the REF voltage ), and then to zero every two seconds.

void application_task ( void )
{
#define DAC17_OUTPUT_ZERO 0x0000u
#define DAC17_OUTPUT_MID_SCALE 0x0800u
#define DAC17_OUTPUT_FULL_SCALE 0x0FFFu
log_printf( &logger, " Setting all channels to full scale output \r\n" );
Delay_ms( 2000 );
log_printf( &logger, " Setting all channels outputs to zero \r\n" );
Delay_ms( 2000 );
log_printf( &logger, " Setting all channels outputs to mid scale \r\n" );
Delay_ms( 2000 );
}
#define DAC17_OUTPUT_MID_SCALE
void application_task(void)
Definition: main.c:65
#define DAC17_OUTPUT_FULL_SCALE
#define DAC17_OUTPUT_ZERO

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

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.