ADAC 4 Click
ADAC 4 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : May 2025.
- Type : I2C type
Software Support
Example Description
This example demonstrates the use of the ADAC 4 Click board which features an 8-channel, 12-bit DAC and ADC. The application configures each DAC channel with incremental values and measures the corresponding output voltage using the integrated ADC, as well as logs the device die temperature.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.ADAC4
Example Key Functions
- adac4_cfg_setup This function initializes Click configuration structure to initial values.
void adac4_cfg_setup(adac4_cfg_t *cfg)
ADAC 4 configuration object setup function.
ADAC 4 Click configuration object.
Definition adac4.h:265
- adac4_init This function initializes all necessary pins and peripherals used for this Click board.
err_t adac4_init(adac4_t *ctx, adac4_cfg_t *cfg)
ADAC 4 initialization function.
ADAC 4 Click context object.
Definition adac4.h:246
- adac4_default_cfg This function executes a default configuration of ADAC 4 Click board.
err_t adac4_default_cfg(adac4_t *ctx)
ADAC 4 default configuration function.
- adac4_write_dac This function writes a value to the specified DAC channel.
err_t adac4_write_dac(adac4_t *ctx, uint8_t channel, uint16_t dac_data)
ADAC 4 write DAC channel function.
- adac4_read_adc_voltage This function reads an ADC voltage value from the specified channel.
err_t adac4_read_adc_voltage(adac4_t *ctx, uint8_t channel, float *voltage)
ADAC 4 read ADC voltage function.
- adac4_read_die_temp This function reads and calculates internal die temperature.
err_t adac4_read_die_temp(adac4_t *ctx, float *die_temp)
ADAC 4 read die temperature function.
Application Init
Initializes the logger and the Click board driver, and applies the default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
adac4_init( &adac4, &adac4_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ ADAC4_ERROR
Definition adac4.h:283
#define ADAC4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition adac4.h:233
void application_init(void)
Definition main.c:31
Application Task
Iterates through all 8 DAC/ADC channels, sets an output voltage, reads back the corresponding ADC voltage, and logs both values. Also reads and logs the die temperature.
{
float die_temp = 0;
float voltage = 0;
{
log_printf ( &logger, "\r\n CH%u -> ", ( uint16_t ) ch_sel, dac_data );
{
log_printf ( &logger, "DAC: %.4u, ", dac_data );
}
{
log_printf ( &logger, "Voltage: %.3f", voltage );
}
dac_data += 200;
{
}
}
{
log_printf ( &logger, "\r\n Die Temperature: %.2f degC\r\n", die_temp );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
@ ADAC4_OK
Definition adac4.h:282
#define ADAC4_CHANNEL_7
Definition adac4.h:207
#define ADAC4_DAC_DATA_MIN
Definition adac4.h:151
#define ADAC4_CHANNEL_0
ADAC 4 channel selection setting.
Definition adac4.h:200
#define ADAC4_DAC_DATA_MAX
Definition adac4.h:152
void application_task(void)
Definition main.c:67
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
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.