Intermediate
30 min

Enhance your project with custom ADC solution based on the MCP3564 and STM32F030R8

Revolutionize your data acquisition

ADC 9 Click with Nucleo-64 with STM32F030R8 MCU

Published Feb 26, 2024

Click board™

ADC 9 Click

Dev Board

Nucleo-64 with STM32F030R8 MCU

Compiler

NECTO Studio

MCU

STM32F030R8

Experience the power of our ADC and discover what you've been missing

A

A

Hardware Overview

How does it work?

ADC 9 Click is based on MCP3564, a 24-bit Delta-Sigma Analog-to-Digital Converter with a programmable data rate of up to 153.6ksps from Microchip. The MCP3564 is fully configurable with Oversampling Ratio (OSR) from 32 to 98304 and gain from 1/3x to 64x. It includes an internal sequencer (SCAN mode) with multiple monitor channels and a 24-bit timer to automatically create conversion loop sequences without needing MCU communications. Advanced security features, such as CRC and register map lock, can ensure configuration locking and integrity and communication data integrity for secure environments. ADC 9 Click comes with a 20 MHz SPI-compatible serial interface. Communication is simplified with 8-bit commands, including various Continuous Read/Write modes and 24/32-bit multiple data formats that can be accessed by the Direct Memory Access (DMA) of an 8-bit, 16-bit, or 32-bit MCU.

The noise value generally increases when the temperature increases, as thermal noise is dominant for all OSRs larger than 32. For high OSR settings (>512), the thermal noise is dominant and increases proportionally to the square root of the absolute temperature. The noise performance is also a function of the measurement duration. The peak-to-peak noise is usually reduced for short-duration measurements (low number of consecutive samples) because the crest factor (ratio between the RMS noise and peak-to-peak noise) is reduced. This feature is only a consequence of the noise distribution being Gaussian by nature. ADC 9 Click use MCP3564 IC with a fully configurable analog input dual multiplexer that can select which input is connected to each of the two differential input pins (VIN+/VIN-) of the Delta-Sigma ADC. Each of these multiplexers includes the same possibilities for the input selection so that the ADC can convert any

required combination of input voltages. The analog multiplexer comprises parallel low-resistance input switches turned on or off depending on the input channel selection. Their resistance is negligible compared to the input impedance of the ADC (caused by the charge and discharge of the input sampling capacitors on the VIN+/VIN- ADC inputs). ADC 9 Click also features MCP1501, a low drift bandgap-based voltage reference from Microchip for precision data acquisition systems. The bandgap uses chopper-based amplifiers, effectively reducing the drift to zero. This Click board™ can only be operated with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used as a reference for further development.

ADC 9 Click top side image
ADC 9 Click lateral side image
ADC 9 Click bottom side image

Features overview

Development board

Nucleo-64 with STM32F030R8 MCU offers a cost-effective and adaptable platform for developers to explore new ideas and prototype their designs. This board harnesses the versatility of the STM32 microcontroller, enabling users to select the optimal balance of performance and power consumption for their projects. It accommodates the STM32 microcontroller in the LQFP64 package and includes essential components such as a user LED, which doubles as an ARDUINO® signal, alongside user and reset push-buttons, and a 32.768kHz crystal oscillator for precise timing operations. Designed with expansion and flexibility in mind, the Nucleo-64 board features an ARDUINO® Uno V3 expansion connector and ST morpho extension pin

headers, granting complete access to the STM32's I/Os for comprehensive project integration. Power supply options are adaptable, supporting ST-LINK USB VBUS or external power sources, ensuring adaptability in various development environments. The board also has an on-board ST-LINK debugger/programmer with USB re-enumeration capability, simplifying the programming and debugging process. Moreover, the board is designed to simplify advanced development with its external SMPS for efficient Vcore logic supply, support for USB Device full speed or USB SNK/UFP full speed, and built-in cryptographic features, enhancing both the power efficiency and security of projects. Additional connectivity is

provided through dedicated connectors for external SMPS experimentation, a USB connector for the ST-LINK, and a MIPI® debug connector, expanding the possibilities for hardware interfacing and experimentation. Developers will find extensive support through comprehensive free software libraries and examples, courtesy of the STM32Cube MCU Package. This, combined with compatibility with a wide array of Integrated Development Environments (IDEs), including IAR Embedded Workbench®, MDK-ARM, and STM32CubeIDE, ensures a smooth and efficient development experience, allowing users to fully leverage the capabilities of the Nucleo-64 board in their projects.

Nucleo 64 with STM32F030R8 MCU double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M0

MCU Memory (KB)

64

Silicon Vendor

STMicroelectronics

Pin count

64

RAM (Bytes)

8192

You complete me!

Accessories

Click Shield for Nucleo-64 comes equipped with two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the STM32 Nucleo-64 board with no effort. This way, Mikroe allows its users to add any functionality from our ever-growing range of Click boards™, such as WiFi, GSM, GPS, Bluetooth, ZigBee, environmental sensors, LEDs, speech recognition, motor control, movement sensors, and many more. More than 1537 Click boards™, which can be stacked and integrated, are at your disposal. The STM32 Nucleo-64 boards are based on the microcontrollers in 64-pin packages, a 32-bit MCU with an ARM Cortex M4 processor operating at 84MHz, 512Kb Flash, and 96KB SRAM, divided into two regions where the top section represents the ST-Link/V2 debugger and programmer while the bottom section of the board is an actual development board. These boards are controlled and powered conveniently through a USB connection to program and efficiently debug the Nucleo-64 board out of the box, with an additional USB cable connected to the USB mini port on the board. Most of the STM32 microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the STM32 Nucleo-64 board with our Click Shield for Nucleo-64, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.

Click Shield for Nucleo-64 accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
PB12
CS
SPI Clock
PB3
SCK
SPI Data OUT
PB4
MISO
SPI Data IN
PB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Master Clock
PC8
PWM
Interrupt/Modulator Data
PC14
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

ADC 9 Click Schematic schematic

Step by step

Project assembly

Click Shield for Nucleo-64 accessories 1 image hardware assembly

Start by selecting your development board and Click board™. Begin with the Nucleo-64 with STM32F030R8 MCU as your development board.

Click Shield for Nucleo-64 accessories 1 image hardware assembly
Nucleo 64 with STM32F401RE MCU front image hardware assembly
LTE IoT 5 Click front image hardware assembly
Prog-cut hardware assembly
LTE IoT 5 Click complete accessories setup image hardware assembly
Nucleo-64 with STM32XXX MCU Access MB 1 Mini B Conn - 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
Clicker 4 for STM32F4 HA 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 ADC 9 Click driver.

Key functions:

  • uint8_t adc9_write_fast_cmd ( uint8_t dev_adr, uint8_t cmd ); - Function is used to execute fast command.
  • uint8_t adc9_read_def_adc ( uint8_t dev_adr, int32_t *rd_data ); - Function is used to read ADC value when the default fata format is applied.
  • float adc9_volt_calc ( int32_t adc_val, uint16_t v_ref, uint8_t gain ); - Function is used to calculate voltage based on ADC values.

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 Adc9 Click example
 * 
 * # Description
 * This click is 8th channel analog to digital converter expansion board, usefull for projects 
 * where we have demand for multi channel ADC conversion such as microcontrollers with small 
 * number or none analog inputs. It offers integrated features, such as internal oscillator, 
 * temperature sensor and burnout sensor detection, in order to reduce system component count 
 * and total solution cost. 
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initalizes SPI driver, resets and starts the device, and makes an initial log.
 * 
 * ## Application Task  
 * This is an example that shows the capabilities of the ADC 9 click by calculating voltage level 
 * based on ADC from channels 0(positive) and 1(negative), and logs the result.
 * 
 * ## Additional Function
 * - void measurement_init ( adc9_t *ctx, adc9_rw_t *rw ) - Measurement Initialization function 
 * is used to easily apply desired settings, in this case device is set to read ADC value 
 * from channels 0 (positive) and 1 (negative) with default data format, gain, boost and internal clock.
 * 
 * ## NOTE
 * Depending on the VOLT SEL jumper position on the click board the user needs to set VREF 
 * macro value (mV) in the code.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "adc9.h"

#define VREF  2048

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

static adc9_t adc9;
static adc9_rw_t adc9_rw;
static log_t logger;

int32_t adc_value;
float m_volts;

// ------------------------------------------------------- ADDITIONAL FUNCTIONS

// Measurement Initialization function
void measurement_init ( adc9_t *ctx, adc9_rw_t *rw )
{
    uint8_t cfg_data;
    uint32_t cfg_data_l;
    uint32_t dummy_data;

    rw->dev_adr = ADC9_DEVICE_ADR;
    rw->reg = ADC9_REG_ADC_DATA;
    rw->cmd = ADC9_CMD_INC_READ;
    adc9_read_u32( ctx, rw, &dummy_data );
    Delay_ms( 1 );

    rw->reg = ADC9_REG_CFG_0;
    cfg_data = ADC9_CFG_0_VREF_SEL_0 | ADC9_CFG_0_CLK_SEL_2 |
               ADC9_CFG_0_CS_SEL_0 | ADC9_CFG_0_MODE_CONV;
    adc9_write_u8( ctx, rw, cfg_data );
    Delay_ms( 1 );

    rw->reg = ADC9_REG_CFG_1;
    cfg_data = ADC9_CFG_1_PRE_1 | ADC9_CFG_1_OSR_32 | ADC9_CFG_1_DITHER_DEF;
    adc9_write_u8( ctx, rw, cfg_data );
    Delay_ms( 1 );

    rw->reg = ADC9_REG_CFG_2;
    cfg_data = ADC9_CFG_2_BOOST_X_1 | ADC9_CFG_2_GAIN_X_1 | ADC9_CFG_2_AZ_MUX_DIS | 
               ADC9_CFG_2_AZ_VREF_EN | ADC9_CFG_2_AZ_FREQ_HIGH;
    adc9_write_u8( ctx, rw, cfg_data );
    Delay_ms( 1 );

    rw->reg = ADC9_REG_CFG_3;
    cfg_data = ADC9_CFG_3_CONV_MODE_CONT | ADC9_CFG_3_DATA_FORMAT_DEF | 
               ADC9_CFG_3_CRC_FORMAT_16 | ADC9_CFG_3_CRC_COM_DIS | ADC9_CFG_3_CRC_OFF_CAL_EN |
               ADC9_CFG_3_CRC_GAIN_CAL_EN;
    adc9_write_u8( ctx, rw, cfg_data );
    Delay_ms( 1 );

    rw->reg = ADC9_REG_MUX;
    cfg_data = ADC9_MUX_VIN_POS_CH0 | ADC9_MUX_VIN_NEG_CH1;
    adc9_write_u8( ctx, rw, cfg_data );
    Delay_ms( 1 );

    cfg_data_l = 0;
    rw->reg = ADC9_REG_SCAN;
    adc9_write_u24( ctx, rw, cfg_data_l );
    Delay_ms( 1 );

    cfg_data_l = 0;
    rw->reg = ADC9_REG_OFFSET_CAL;
    adc9_write_u24( ctx, rw, cfg_data_l );
    Delay_ms( 1 );

    cfg_data_l = 0x00800000;
    rw->reg = ADC9_REG_GAIN_CAL;
    adc9_write_u24( ctx, rw, cfg_data_l );
    Delay_ms( 1 );

    cfg_data_l = 0x00900F00;
    rw->reg = ADC9_RSV_REG_W_A;
    adc9_write_u24( ctx, rw, cfg_data_l );
    Delay_ms( 1 );
}

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

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

    adc9_cfg_setup( &cfg );
    ADC9_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    uint8_t err_flag = adc9_init( &adc9, &cfg );
    if ( ADC9_INIT_ERROR == err_flag )
    {
        log_info( &logger, "---- Error Init ----" );
        for ( ; ; );
    }

    adc9_default_cfg( &adc9, &adc9_rw );
    
    Delay_ms( 1000 );
}

void application_task ( void )
{
    measurement_init( &adc9, &adc9_rw );
    
    while ( adc9_irq_pin_state( &adc9 ) );
    
    adc9_rw.reg = ADC9_DEVICE_ADR;
    adc9_read_def_adc ( &adc9, &adc9_rw, &adc_value );

    log_printf( &logger, "ADC Value : %ld\r\n" , adc_value );
    
    m_volts = adc9_volt_calc ( &adc9, adc_value, VREF, 1 );
    log_printf( &logger, "Voltage in milivolts : %.2f\r\n", m_volts );

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

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.