Intermediate
30 min

Navigate the world of data transformation using DAC53608 and PIC18F45K40

Bits to Voltage

DAC 5 Click with Curiosity HPC

Published Nov 01, 2023

Click board™

DAC 5 Click

Dev Board

Curiosity HPC

Compiler

NECTO Studio

MCU

PIC18F45K40

Elevate the value of digital signals by converting them into analog signals, opening doors to many applications and possibilities

A

A

Hardware Overview

How does it work?

DAC 5 Click is based on the DAC53608, a low-power, eight-channel, 10-bit voltage output digital-to-analog converter (DAC) from Texas Instruments. It is specified monotonic by design across a wide power supply range from 1,8 V to 5,5 V. Using an external reference, the DAC53608 provides a full-scale output voltage in the range from 0V to Vref while consuming 0,1 mA quiescent current per channel. The DAC53608 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 5 click has a high-precision voltage reference included onboard. For that purpose, MAX6106 is used, a 2.048V voltage

reference IC from Analog Devices. This little SOT23 device is stable with capacitive loads and requires no output capacitor. It has regulations for both sink and source and is very accurate. This gives DAC 5 click good flexibility for use in various applications. Low quiescent current, wide power supply range, and per channel power down option make DAC53608 ideal for low power, battery-operated system. The device communicates through the I2C interface. These devices support I2C standard mode (100 Kbps), fast mode (400 Kbps), and fast+ mode (1 Mbps). These devices also have a load DAC (LDAC) pin that allows simultaneous DAC updates. LDAC pin is tied with a mikroBUS™ PWM pin. The I2C lines (SCL and SDA) are routed to the dedicated mikroBUS™pins.

The voltage level of the logic section can be selected via VCC SEL jumper, between 3.3V and 5V. This allows both 3.3V and 5V capable MCUs to properly use the I2C communication lines. For I2C address selection, DAC 5 click has a cross-shape jumper. Four positions for I2C selection can be selected with an SMD 0 ohms resistor. DAC 5 click has a Vref SEL jumper for choosing between 2,048 V and 1,024 V, where 1,024 V is achieved using a voltage divider. Another jumper is for VrefIN, choosing between Vref (1,024 and 2,048) and VCC (3,3V and 5V). Voltage outputs from DAC 5 click can be connected through a 9-terminal block where the first is common GND, and the last eight are VOUTA to VOUTH.

DAC 5 Click hardware overview image

Features overview

Development board

Curiosity HPC, standing for Curiosity High Pin Count (HPC) development board, supports 28- and 40-pin 8-bit PIC MCUs specially designed by Microchip for the needs of rapid development of embedded applications. This board has two unique PDIP sockets, surrounded by dual-row expansion headers, allowing connectivity to all pins on the populated PIC MCUs. It also contains a powerful onboard PICkit™ (PKOB), eliminating the need for an external programming/debugging tool, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, a set of indicator LEDs, push button switches and a variable potentiometer. All

these features allow you to combine the strength of Microchip and Mikroe and create custom electronic solutions more efficiently than ever. Each part of the Curiosity HPC development board contains the components necessary for the most efficient operation of the same board. An integrated onboard PICkit™ (PKOB) allows low-voltage programming and in-circuit debugging for all supported devices. When used with the MPLAB® X Integrated Development Environment (IDE, version 3.0 or higher) or MPLAB® Xpress IDE, in-circuit debugging allows users to run, modify, and troubleshoot their custom software and hardware

quickly without the need for additional debugging tools. Besides, it includes a clean and regulated power supply block for the development board via the USB Micro-B connector, alongside all communication methods that mikroBUS™ itself supports. Curiosity HPC development board allows you to create a new application in just a few steps. Natively supported by Microchip software tools, it covers many aspects of prototyping thanks to many number of different Click boards™ (over a thousand boards), the number of which is growing daily.

Curiosity HPC double image

Microcontroller Overview

MCU Card / MCU

PIC18F45K40

Architecture

PIC

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

2048

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Asynchronous Clear
RD0
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Output Update
RC2
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RC3
SCL
I2C Data
RC4
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

DAC 5 Click Schematic schematic

Step by step

Project assembly

Curiosity HPC front no-mcu image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity HPC as your development board.

Curiosity HPC front no-mcu image hardware assembly
GNSS2 Click front image hardware assembly
MCU DIP 40 hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Curiosity HPC Access MB 1 - 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
Necto DIP image step 7 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 5 Click driver.

Key functions:

  • dac5_send_data - Function for sending data to one output

  • dac5_config - Function for configurating click

  • dac5_get_device_id - Function for reading device ID

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 Dac5 Click example
 * 
 * # Description
 *
 * This demo example sends digital signal to one of the outputs and converts it to analog
 * 
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes driver init, tests communication and configures device for measuring
 *
 * ## Application Task
 * Sets the channel H with different values and logs the expected output on USB UART
 *
 * ## NOTE
 * In order to improve the accuracy, measure the voltage on the click board VrefIN SEL jumper and set it as VREF below.
 * 
 * \author Luka Filipovic
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "dac5.h"

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

static dac5_t dac5;
static log_t logger;

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

void application_init ( void )
{
    log_cfg_t log_cfg;
    dac5_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 ----" );

    //  Click initialization.

    dac5_cfg_setup( &cfg );
    DAC5_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    dac5_init( &dac5, &cfg );

    if ( dac5_get_device_id( &dac5 ) != DAC5_DEVICE_ID )
    {
        log_printf( &logger, "ERROR - DEVICE IS NOT READY\r\n" );
        log_printf( &logger, "Please check the onboard jumpers position.\r\n" );
        for ( ; ; );
    }

    dac5_config( &dac5, DAC5_CONFIG_GLOBAL_ENABLED );
    log_printf( &logger, "The click board is configured.\r\n" );

    Delay_ms( 100 );
}

void application_task ( void )
{
    for ( uint16_t cnt = DAC5_MIN_DATA; cnt < DAC5_MAX_DATA; cnt += 500 )
    {
        if ( dac5_send_data( &dac5, DAC5_REG_DAC_H_DATA, cnt ) == DAC5_ERROR )
        {
            log_printf( &logger, "ERROR SENDING DATA\r\n" );
        }
        else
        {
            log_printf( &logger, "Expected output on channel H:\t %d mV\r\n", ( uint16_t )( ( ( float ) cnt / DAC5_MAX_DATA ) * dac5.vref ) );
        }
        log_printf( &logger,"------------------------------------\r\n" );
        Delay_ms ( 2000 );
    }
}

void main ( void )
{
    application_init( );

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

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

Additional Support

Resources