Intermediate
30 min

Discover the art of data conversion with AD5624R and PIC32MZ2048EFH100

Unveil the analog essence of digital signals

DAC 7 Click with Flip&Click PIC32MZ

Published Aug 18, 2023

Click board™

DAC 7 Click

Dev Board

Flip&Click PIC32MZ

Compiler

NECTO Studio

MCU

PIC32MZ2048EFH100

Engineered to deliver accurate and reliable analog outputs, our solution enables you to harness the potential of your digital signals in applications spanning from control systems to instrumentation.

A

A

Hardware Overview

How does it work?

DAC 7 Click board is based on the AD5624R, a low-power, four-channel, 12-bit voltage output digital-to-analog converter (DAC) from Analog Devices. It is specified monotonic by design across a wide power supply range from 2.7V to 5.5V. Using an external reference, the AD5624R provides a full-scale output voltage from 0V to Vref while consuming 0.1 mA quiescent current per channel. The AD5624R also includes, per channel, user-programmable power-down registers that facilitate the DAC output buffers to start in power down to 10K and remain in this state until a power-up command is issued to these output buffers. The DAC 7 Click has a high-precision voltage

reference included onboard. For that purpose, we have used 4.096V precision voltage reference MCP1541 from Microchip. This little SOT23 device is stable with capacitive loads. It has regulations for both sink and source and is very accurate. This gives DAC 7 Click good flexibility for use in various applications. Low quiescent current, wide power supply range, and per channel power down option make AD5624R ideal for low power, battery-operated system. The device communicates through the SPI interface. Besides the standard SPI, QSPI™, MICROWIRE™, and DSP interface standards are also supported. However, this click board™ uses standard SPI communication with

the main MCU. The reference voltage level can be selected via the VREF SEL jumper, between 4.096V and 5V. This allows for both 4.096V and 5V Voltage outputs from DAC 7 Click can be connected through a 9-terminal block where the first is common GND and the last eight are VOUTA to VOUTH. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used, as a reference, for further development.

DAC 7 Click top side image
DAC 7 Click bottom side image

Features overview

Development board

Flip&Click PIC32MZ is a compact development board designed as a complete solution 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 PIC32MZ microcontroller, the PIC32MZ2048EFH100 from Microchip, four mikroBUS™ sockets for Click board™ connectivity, two USB connectors, LED indicators, buttons, debugger/programmer connectors, and two headers compatible with Arduino-UNO pinout. Thanks to innovative manufacturing technology,

it allows you to build gadgets with unique functionalities and features quickly. Each part of the Flip&Click PIC32MZ development kit contains the components necessary for the most efficient operation of the same board. In addition, there is the possibility of choosing the Flip&Click PIC32MZ programming method, using the chipKIT bootloader (Arduino-style development environment) or our USB HID bootloader using mikroC, mikroBasic, and mikroPascal for PIC32. This kit includes a clean and regulated power supply block through the USB Type-C (USB-C) connector. All communication

methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, user-configurable buttons, and LED indicators. Flip&Click PIC32MZ development kit allows 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.

Flip&Click PIC32MZ double image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
RA0
CS
SPI Clock
RG6
SCK
NC
NC
MISO
SPI Data IN
RB5
MOSI
NC
NC
3.3V
Ground
GND
GND
NC
NC
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 7 Click Schematic schematic

Step by step

Project assembly

Flip&Click PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Flip&Click PIC32MZ as your development board.

Flip&Click PIC32MZ front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Flip&Click PIC32MZ MB1 Access - 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
Flip&Click PIC32MZ MCU 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 via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

Software Support

Library Description

This library contains API for DAC 7 Click driver.

Key functions:

  • dac7_sw_reset - This function set software reset of selected channel of AD5624R Quad, 12-bit nanoDACs on DAC 7 Click

  • dac7_set_power - This function set power mode of selected channel of AD5624R Quad, 12-bit nanoDACs on DAC 7 Click

  • dac7_set_ch_voltage - This function set 12-bit value of 3-bit command definition to the target 3-bit address command of AD5624R Quad, 12-bit nanoDACs on DAC 7 Click

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 
 * \brief Dac7 Click example
 * 
 * # Description
 * DAC 7 click carries the AD5624R 12-bit buffered Digital-to-Analog Converter 
 * that converts digital value to the corresponding voltage level 
 * using external voltage reference.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Application Init performs Logger and Click initialization.
 * 
 * ## Application Task  
 * In this example, we adjust the DAC output voltage from 1000 mV to 4000 mV 
 * for the channels, starting from channel A to channel D 
 * and then set the DAC output voltage to 5000 mV for all channels.
 * Results are being sent to UART Terminal where you can track their changes.
 * All data logs write on USB UART changes every 5 sec.
 *  
 * \author Mihajlo Djordjevic
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "dac7.h"


// ------------------------------------------------------------------ VARIABLES

uint16_t v_ref_sel;
static dac7_t dac7;
static log_t logger;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    dac7_cfg_t cfg;

    /** 
     * 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 ----" );
    Delay_ms ( 100 );

    //  Click initialization.

    dac7_cfg_setup( &cfg );
    DAC7_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    dac7_init( &dac7, &cfg );
    
    log_printf( &logger, "--------------------------\r\n\n" );
    log_printf( &logger, " ------  DAC 7 Click  ------\r\n" );
    log_printf( &logger, "--------------------------\r\n\n" );
    Delay_ms ( 1000 );
    
    v_ref_sel = DAC7_VREF_5000mV;

    if ( dac7_sw_reset( &dac7 ) == DAC7_SUCCESS )
    {
        log_printf( &logger, "   Software reset   \r\n" );
    }
    else
    {
        log_printf( &logger, "   ERROR   \r\n" );
        for ( ; ; );
    }
    
    Delay_ms( 500 );
    log_printf( &logger, "--------------------------\r\n\n" );

    
    if ( dac7_set_power( &dac7, DAC7_PWR_ON_ENABLE, DAC7_SELECT_CHANNEL_ALL ) == DAC7_SUCCESS )
    {
        log_printf( &logger, "   All channel Power On   \r\n" );
    }
    else
    {
        log_printf( &logger, "   ERROR   \r\n" );

        for ( ; ; );
    }

    Delay_ms( 500 );
    log_printf( &logger, "--------------------------\r\n\n" );
    log_printf( &logger, " -- Initialization  done. --\r\n" );
    log_printf( &logger, "--------------------------\r\n\n" );
    Delay_ms ( 1000 );
}

void application_task ( void )
{
    if ( dac7_set_ch_voltage ( &dac7, DAC7_ADDRESS_CHANNEL_A, 1000, v_ref_sel ) == DAC7_SUCCESS )
    {
        log_printf( &logger, "  Channel A : 1000 mV  \r\n" );
    }
    else
    {
        log_printf( &logger, "   ERROR   \r\n" );
        for ( ; ; );
    }

    Delay_ms( 5000 );
    log_printf( &logger, "--------------------------\r\n\n" );
    
    if ( dac7_set_ch_voltage ( &dac7, DAC7_ADDRESS_CHANNEL_B, 2000, v_ref_sel ) == DAC7_SUCCESS )
    {
        log_printf( &logger, "  Channel B : 2000 mV  \r\n" );
    }
    else
    {
        log_printf( &logger, "   ERROR   \r\n" );
        for ( ; ; );
    }

    Delay_ms( 5000 );
    log_printf( &logger, "--------------------------\r\n\n" );
    
    if ( dac7_set_ch_voltage ( &dac7, DAC7_ADDRESS_CHANNEL_C, 3000, v_ref_sel ) == DAC7_SUCCESS )
    {
        log_printf( &logger, "  Channel C : 3000 mV  \r\n" );
    }
    else
    {
        log_printf( &logger, "   ERROR   \r\n" );
        for ( ; ; );
    }
    
    Delay_ms( 5000 );
    log_printf( &logger, "--------------------------\r\n\n" );
    
    if ( dac7_set_ch_voltage ( &dac7, DAC7_ADDRESS_CHANNEL_D, 4000, v_ref_sel ) == DAC7_SUCCESS )
    {
        log_printf( &logger, "  Channel D : 4000 mV  \r\n" );
    }
    else
    {
        log_printf( &logger, "   ERROR   \r\n" );
        for ( ; ; );
    }

    Delay_ms( 5000 );
    log_printf( &logger, "--------------------------\r\n\n" );

    if ( dac7_set_ch_voltage ( &dac7, DAC7_ADDRESS_CHANNEL_ALL, 5000, v_ref_sel ) == DAC7_SUCCESS )
    {
        log_printf( &logger, " All Channels: 5000 mV \r\n" );
    }
    else
    {
        log_printf( &logger, "   ERROR   \r\n" );
        for ( ; ; );
    }

    Delay_ms( 5000 );
    log_printf( &logger, "--------------------------\r\n\n" );
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}

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

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.