Transform capacitance into digital data for enhanced accuracy and control in your projects
A
A
Hardware Overview
How does it work?
CDC Click is based on the PCAP04, a capacitance-to-digital converter from ScioSense. It covers a wide capacitance input range from a few femtofarads to several hundreds of nanofarads. Configuring the PCAP04 for different capacitance measurement tasks, such as single and differential sensors in grounded or floating connections, is easy. The CDC Click is pre-assembled with 10pF capacitors on the PC0 – PC5 header to emulate capacitive sensors. They are connected as single sensors in floating mode. There is a GND connector for connecting the capacitive sensors in grounded mode. The typical value of the capacitive sensors that can be connected is in the range of 30pF to 3.5nF. The PCAP04 has four general
purpose input/output pins (PG prefix) and can be used as pulse-density/pulse-width modulation outputs. The PCAP04 features the RDC (resistance-to-digital converter) as well. The RDC unit is mainly intended for measuring temperature, using an internal sensor and reference, or using external resistors like the PT1000 onboard. You can, however, connect an external sensor over the PT1 and PTO connectors or any other resistance element. The DSP takes information from both the CDC and RDC processes, making it available to the host MCU. You can also add another temperature sensor or temperature reference on RT2. The auxiliary port (PCAUX – PCA on CDC Click) can be used for external compensation
capacitance or external discharge resistor and guarding port. You can make a selection by soldering an R7 jumper. CDC Click can communicate with the host MCU using a standard I2C or 4-wire SPI serial interface. The selection can be made over the COMM SEL jumpers. The I2C is set by default and supports up to 100kHz of the bus frequency clock. The SPI clock frequency is up to 20MHz. 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.
Features overview
Development board
Discovery kit with STM32L4R9AI MCU is a complete demonstration and development platform for the STMicroelectronics Arm® Cortex®-M4 core-based STM32L4R9AI microcontroller. Leveraging the innovative ultra-low-power oriented features, 640 Kbytes of embedded RAM, graphics performance (Chrom-ART Accelerator™), and DSISM controller offered by the STM32L4R9AI, the 32L4R9IDISCOVERY kit enables users to easily prototype applications with state-of-the-art energy efficiency, as well as providing stunning audio and graphics rendering with direct support for an AMOLED DSI round display. For even more user friendliness, the on-board ST-LINK/V2-1 debugger provides out-of-the-box programming and
debugging capabilities. The STM32L4R9AI microcontroller features four I2Cs, five USARTs, one ULP UART, three SPIs, two SAIs, one SDIO, one USB 2.0 full-speed OTG, two CANs, one FMC parallel synchronous interface, one 12 bit ADC, one 12-bit DAC, two ULP analog comparators, two op-amps, one two data-lane DSI display, one digital filter for sigma-delta modulation and SWP interface, two Octo-SPI interfaces, an 8- to 14-bit camera interface, one touch-sensing controller interface, JTAG, and SWD debugging support. This Discovery board offers everything users need to get started quickly and develop applications easily. The hardware features on the board help to evaluate the following peripherals: USB OTG FS, microSD™
card, 8-bit camera interface, 16-Mbit PSRAM, PMOD, and STMod+ connectors, IDD measurement, full-duplex I2S with an audio codec and stereo headset jack including an analog microphone, DFSDM with a pair of MEMS digital microphones on board, 512-Mbit Octo-SPI Flash memory device, I2C extension connector, 1.2" AMOLED display using a one data-lane DSI interface with a capacitive touch panel. The ARDUINO® compatible connectors expand the functionality with a wide choice of specialized shields. The integrated ST-LINK/V2-1 provides an embedded in-circuit debugger and programmer for the STM32 MCU.
Microcontroller Overview
MCU Card / MCU

Architecture
ARM Cortex-M4
MCU Memory (KB)
2048
Silicon Vendor
STMicroelectronics
Pin count
169
RAM (Bytes)
655360
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for CDC Click driver.
Key functions:
cdc_write_config
- This function writes configuration data starting from the selected config addresscdc_send_opcode
- This function sends a desired opcode command bytecdc_read_results
- This function reads all results and status registers
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* @file main.c
* @brief CDC Click example
*
* # Description
* This example demonstrates the use of CDC Click board by reading capacitance
* measurements from C3/C2 and C5/C4 ports calculated from pure capacitance ratio
* between those ports and port C1/C0 which is used as external C reference.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and performs the Click default configuration.
*
* ## Application Task
* Starts measurement and reads the results. The results data is displayed on the USB UART.
*
* @note
* For better accuracy and higher measurement range, add 200pF external
* capacitor between C1/C0 ports and set it below as CDC_EXT_CAP_C1_C0_PF macro
* before running the application. This way you will be able to measure capacitance
* in range from 1 to 2000pF.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "cdc.h"
// Settings for reference capacitors
#define CDC_EXT_CAP_C1_C0_PF 0.0f
#define CDC_INT_CAP_PF 10.0f
#define CDC_REF ( CDC_EXT_CAP_C1_C0_PF + CDC_INT_CAP_PF )
static cdc_t cdc;
static log_t logger;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
cdc_cfg_t cdc_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.
cdc_cfg_setup( &cdc_cfg );
CDC_MAP_MIKROBUS( cdc_cfg, MIKROBUS_1 );
err_t init_flag = cdc_init( &cdc, &cdc_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( CDC_ERROR == cdc_default_cfg ( &cdc ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
cdc_results_t results;
cdc_send_opcode ( &cdc, CDC_OPCODE_CDC_START );
Delay_ms ( 200 );
if ( CDC_OK == cdc_read_results ( &cdc, &results ) )
{
log_printf ( &logger, " C1/C0: %.1f pF\r\n",
results.res_0 * CDC_REF - CDC_INT_CAP_PF );
log_printf ( &logger, " C3/C2: %.1f pF\r\n",
results.res_1 * CDC_REF - CDC_INT_CAP_PF );
log_printf ( &logger, " C5/C4: %.1f pF\r\n\n",
results.res_2 * CDC_REF - CDC_INT_CAP_PF );
Delay_ms ( 1000 );
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END