Intermediate
30 min

Ensure reliable conversion of analog signals to digital format with TLA2518 and STM32F429NI

Precision meets conversion

ADC 20 Click with Fusion for ARM v8

Published Jun 02, 2023

Click board™

ADC 20 Click

Dev Board

Fusion for ARM v8

Compiler

NECTO Studio

MCU

STM32F429NI

Upgrade your designs with our advanced Analog-To-Digital converter and achieve precision like never before

A

A

Hardware Overview

How does it work?

ADC 20 Click is based on the TLA2518, a small, eight-channel, multiplexed, 12-bit, 1-MSPS, analog-to-digital converter (ADC) from Texas Instruments. The TLA2518 has an internal oscillator for the ADC conversion process and supports averaging multiple data samples with a single conversion start. Also, the built-in programmable averaging filters, which output a 16-bit result for enhanced resolution, help reduce noise from the analog inputs and the number of data samples required to be read by the host MCU. The analog input channel selection can be auto-sequenced to simplify the digital interface with the host MCU. This Click board™ communicates with MCU through a standard SPI interface, supporting all four SPI-compatible protocols (SPI Mode 0, 1, 2, and 3) to access

the device, and operates at clock rates up to 60MHz for all configurations and information management and acquiring conversion results. As mentioned, the TLA2518 powers up in Manual mode and can be configured into either of three operational modes by writing the configuration registers for the desired mode. The Manual mode allows the host MCU to directly select the analog input channel, while in the second, the On-the-Fly mode of operation, the analog input channel is set using the first five bits on the SDI signal without waiting for the CS rising edge. This way, the ADC samples the newly selected channel on the CS edge, and there is no latency between the channel selection and the ADC output data. In the third Auto-Sequence mode, the internal channel sequencer

switches the multiplexer to the next analog input channel after every conversion. In addition to the fact that all eight channels, also including channels on the side headers, can be used as analog input pins, this board allows for some channels, in this case, channels CH0, CH1, CH6, and CH7 of the TLA2518 to be configured as digital inputs, open-drain digital outputs, and push-pull digital outputs. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. However, the 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.

ADC 20 Click hardware overview image

Features overview

Development board

Fusion for ARM v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different ARM® Cortex®-M based MCUs regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, Fusion for ARM v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the Fusion for ARM v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.

Communication options such as USB-UART, USB HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. Fusion for ARM v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Fusion for ARM v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

ARM Cortex-M4

MCU Memory (KB)

2048

Silicon Vendor

STMicroelectronics

Pin count

216

RAM (Bytes)

262144

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
PB9
CS
SPI Clock
PG13
SCK
SPI Data OUT
PG12
MISO
SPI Data IN
PG14
MOSI
Power Supply
3.3V
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

ADC 20 Click Schematic schematic

Step by step

Project assembly

Fusion for PIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Fusion for ARM v8 as your development board.

Fusion for PIC v8 front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
v8 SiBRAIN 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 Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for ADC 20 Click driver.

Key functions:

  • adc20_read_data This function reads two bytes of data by using SPI serial interface.

  • adc20_set_gpo_value This function sets the gpo value for the selected channels.

  • adc20_read_gpio_value This function reads the gpio pins value.

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 ADC 20 Click example
 *
 * # Description
 * This example demonstrates the use of ADC 20 click board by displaying the state of 8 channels
 * configured as analog inputs (CH2-CH5), digital inputs (CH0-CH1) and digital outputs (CH6-CH7).
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration.
 *
 * ## Application Task
 * Starts the auto sequence mode, reads the 12bit ADC value from analog input channels (CH2-CH5) and
 * displays the values converted to voltage on the USB UART. After that, stops auto sequence mode and
 * toggles the state of digital output pins (CH6-CH7), then reads and displays the state of all GPIO pins.
 * 
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "adc20.h"

static adc20_t adc20;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    adc20_cfg_t adc20_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.
    adc20_cfg_setup( &adc20_cfg );
    ADC20_MAP_MIKROBUS( adc20_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == adc20_init( &adc20, &adc20_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( ADC20_ERROR == adc20_default_cfg ( &adc20 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    adc20_start_auto_sequence ( &adc20 );
    for ( uint8_t ch_id = ADC20_CHANNEL_ID_2; ch_id <= ADC20_CHANNEL_ID_5; ch_id++ )
    {
        uint16_t adc_data = 0;
        if ( ADC20_OK == adc20_read_data ( &adc20, &adc_data ) )
        {
            float voltage = ( float ) ( adc_data >> ADC20_ADC_OFFSET ) / ADC20_RES_12BIT * ADC20_VREF_3V3;
            log_printf ( &logger, " AIN%u: %.2f V\r\n", ( adc_data & ADC20_CHANNEL_ID_MASK ), voltage );
        }
    }
    adc20_stop_auto_sequence ( &adc20 );
    static uint8_t out_logic_state = ADC20_GPIO_VALUE_LOW;
    if ( ADC20_OK == adc20_set_gpo_value ( &adc20, ( ADC20_CHANNEL_6 | ADC20_CHANNEL_7 ), out_logic_state ) )
    {
        uint8_t gpio_value = 0;
        if ( ADC20_OK == adc20_read_gpio_value ( &adc20, &gpio_value ) )
        {
            log_printf ( &logger, " GPIO state: 0x%.2X\r\n", gpio_value );
        }
    }
    out_logic_state = !out_logic_state;
    log_printf ( &logger, "\r\n" );
    Delay_ms ( 1000 );
}

void main ( void )
{
    application_init( );

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

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

Additional Support

Resources