Beginner
10 min

Convert digital signals into precise analog voltage outputs using the DAC7558 and STM32F415RG

12-bit octal-channel voltage-output digital-to-analog (DAC)

DAC 17 Click with STM32 M4 clicker

Published May 23, 2024

Click board™

DAC 17 Click

Dev.Board

STM32 M4 clicker

Compiler

NECTO Studio

MCU

STM32F415RG

Precise voltage output control for applications like digital gain adjustment, programmable voltage sources, and industrial process control.

A

A

Hardware Overview

How does it work?

DAC 17 Click is based on the DAC7558, a 12-bit, octal-channel voltage output DAC from Texas Instruments, known for its exceptional linearity and monotonicity. Its proprietary architecture mitigates undesired transients, such as code-to-code glitches and channel-to-channel crosstalk. Operating within a voltage range of 2.7V to 5.5V, the DAC7558 offers versatility. The board provides the flexibility of powering the IC internally or externally by setting the VCC SEL jumper to either the VIO or VEXT position. The VIO option enables internal powering of the Click board™, providing a choice between 3.3V or 5V. On the other hand, the VEXT option allows users to externally supply power in the range of 2.7 to 5.5V (applied to VEXT pins), offering flexibility in power supply according to specific system requirements. Featuring output amplifiers capable of driving a 2Ω, 200pF load rail-to-rail with a rapid settling time of 5µs, the

DAC7558 ensures precise and efficient performance. Users can configure the output range of DAC channels (from CHA to CHH) by connecting an external voltage reference to one of the REFx terminals in a range from 0V to a value of the main IC supply, VCC. Additionally, the board offers a selection between internal and external voltage reference sources. This selection is made via the VREF SEL jumpers, allowing users to choose between internal or external voltage reference options. The DAC7558 offers versatility in operation, with the ability to update outputs simultaneously or sequentially. Its integrated Power-on-Reset circuit guarantees that DAC outputs power up to zero volts during initialization. Furthermore, a Power-Down feature, controllable via the PD pin of the mikroBUS™ socket, reduces the device's current consumption to under 2µA, enhancing efficiency and prolonging battery life.

Communication with the host MCU is achieved through the 4-wire SPI serial interface, supporting clock rates of up to 50MHz. This interface is compatible with SPI, QSPI, Microwire™, and DSP standards, ensuring easy integration into various systems. The DAC7558 also uses an active-low reset feature via the RST pin on the mikroBUS™ socket. When the RST pin is set to a LOW logic state, all DAC channels are reset to zero scale. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VIO SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

DAC 17 Click hardware overview image

Features overview

Development board

STM32 M4 Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit ARM Cortex-M4 microcontroller, the STM32F415RG from STMicroelectronics, a USB connector, LED indicators, buttons, a JTAG connector, and a header for interfacing with external electronics. Thanks to its compact design with clear and easy-recognizable silkscreen markings, it provides a fluid and immersive working experience, allowing

access anywhere and under any circumstances. Each part of the STM32 M4 Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the STM32 M4 Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for the STM32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Mini-B connection can provide up to 500mA of current, which is more than enough to operate all

onboard and additional modules. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. STM32 M4 Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

STM32 M4 Clicker double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M4

MCU Memory (KB)

1024

Silicon Vendor

STMicroelectronics

Pin count

64

RAM (Bytes)

196608

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset / ID SEL
PB5
RST
SPI Select / ID COMM
PB12
CS
SPI Clock
PB13
SCK
SPI Data OUT
PB14
MISO
SPI Data IN
PB15
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Power-Down
PB0
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

DAC 17 Click Schematic schematic

Step by step

Project assembly

STM32 M4 clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the STM32 M4 clicker as your development board.

STM32 M4 clicker front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
STM32 M4 Mini B Connector Access Clicker - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
STM32 M4 Clicker HA MCU/Select Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for DAC 17Click driver.

Key functions:

  • dac17_send_command - This function is used to send specific command of the DAC 17 click board.

  • dac17_set_dac_output - This function is used to set output level of the sellected channel of the DAC 17 click board.

  • dac17_set_all_dac_output - This function is used to set output level of the DAC 17 click board.

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief DAC 17 Click 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.
 *
 * ## 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.
 *
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "dac17.h"

static dac17_t dac17;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    dac17_cfg_t dac17_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.
    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 " );
}

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" );
    dac17_set_all_dac_output( &dac17, DAC17_OUTPUT_FULL_SCALE );
    Delay_ms( 2000 );

    log_printf( &logger, " Setting all channels outputs to zero \r\n" );
    dac17_set_all_dac_output( &dac17, DAC17_OUTPUT_ZERO );
    Delay_ms( 2000 );

    log_printf( &logger, " Setting all channels outputs to mid scale \r\n" );
    dac17_set_all_dac_output( &dac17, DAC17_OUTPUT_MID_SCALE );
    Delay_ms( 2000 );
}

int main ( void ) 
{
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

// ------------------------------------------------------------------------ END

Additional Support

Resources