TOP Contributors

  1. MIKROE (2751 codes)
  2. Alcides Ramos (372 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139061 times)
  2. FAT32 Library (71592 times)
  3. Network Ethernet Library (56989 times)
  4. USB Device Library (47330 times)
  5. Network WiFi Library (43006 times)
  6. FT800 Library (42297 times)
  7. GSM click (29777 times)
  8. mikroSDK (27874 times)
  9. PID Library (26858 times)
  10. microSD click (26129 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

ADAC Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.17

mikroSDK Library: 2.0.0.0

Category: ADC-DAC

Downloaded: 261 times

Not followed.

License: MIT license  

The Click is designed to run on either 3.3V or 5V power supply. ADAC Click communicates with the target microcontroller over I2C interface, with additional functionality provided by the RST pin on the mikroBUS™ line.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "ADAC Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "ADAC Click" changes.

Do you want to report abuse regarding "ADAC Click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


ADAC Click

The Click is designed to run on either 3.3V or 5V power supply. ADAC Click communicates with the target microcontroller over I2C interface, with additional functionality provided by the RST pin on the mikroBUS™ line.

adac_click.png

Click Product page


Click library

  • Author : MikroE Team
  • Date : Jun 2020.
  • Type : I2C type

Software Support

We provide a library for the ADAC Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for ADAC Click driver.

Standard key functions :

  • Config Object Initialization function.

    void adac_cfg_setup ( adac_cfg_t *cfg );

  • Initialization function.

    ADAC_RETVAL adac_init ( adac_t ctx, adac_cfg_t cfg );

  • Click Default Configuration function.

    void adac_default_cfg ( adac_t *ctx );

Example key functions :

  • This function writes DAC using the I2C serial interface.

    void adac_write_dac ( adac_t *ctx, uint8_t chan, uint8_t msb, uint8_t lsb );

  • This function reads ADC data using the I2C serial interface.

    uint16_t adac_read_adc( adac_t ctx, uint8_t chan );

  • This function sets the configuration for the Click module.

    void adac_set_configuration ( adac_t *ctx, uint8_t ptr, uint8_t msb, uint8_t lsb );

Examples Description

This example showcases how to initialize, configure and use the ADAC Click module. The Click has an ADC and a DAC. An external power supply sets the maximum voltage of the input analog signal, which is bound to 2.5 V by default. For the input any external analog signal will suffice and a multimeter is needed to read the output on one of the channels.

The demo application is composed of two sections :

Application Init

This function initializes and configures the Click and logger modules. It does a hardware reset first and after that configures the Click module using default settings.


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

    adac_cfg_setup( &cfg );
    ADAC_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    adac_init( &adac, &cfg );
    Delay_100ms( );
    adac_hardware_reset( &adac );
    Delay_100ms( );
    adac_set_configuration( &adac, ADAC_POWER_REF_CTRL, ADAC_VREF_ON, ADAC_NO_OP );
    Delay_100ms( );
    log_printf( &logger, "\r\n Click module initialized \r\n" );
    Delay_ms ( 500 );
}

Application Task

This function first writes digital values ranging from 0 to 256 to output channel 3 with a 10 millisecond delay between iterations and after that reads analog values from channel 4 10 times and displays results in the UART console.


void application_task ( void )
{
    uint16_t adc_val;
    uint16_t cnt;
    uint8_t chan;

    log_printf( &logger, "\r\n *** DAC : write ***\r\n" );
    adac_set_configuration( &adac, ADAC_DAC_CONFIG, ADAC_NO_OP, ADAC_IO3 );
    Delay_100ms( );

    for ( cnt = 0; cnt < 0xFF; cnt +=4 )
    {
        adac_write_dac( &adac, ADAC_PB_PIN3, cnt / 0x100, cnt % 0x100 );
        Delay_ms ( 10 );
        log_printf( &logger, " > write... \r\n" );
    }

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

    log_printf( &logger, "\r\n *** ADC : read ***\r\n" );
    adac_set_configuration( &adac, ADAC_ADC_CONFIG, ADAC_NO_OP, ADAC_IO4 );
    Delay_100ms( );
    adac_set_configuration( &adac, ADAC_ADC_SEQUENCE, ADAC_SEQUENCE_ON, ADAC_IO4 );

    for( cnt = 0; cnt < 10; cnt++ )
    {
        adc_val = adac_read_adc( &adac, &chan );
        log_printf( &logger, "   channel : %d\r\n", chan );
        log_printf( &logger, "       val : %d\r\n", adc_val ); 
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
    }

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

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.ADAC

Additional notes and informations

Depending on the development board you are using, you may need USB UART Click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.


ALSO FROM THIS AUTHOR

8x8 click - Example

0

Simple example which demonstrates working with 8x8 click boards. 8x8 clicks are 8x8 LED matrix displays in form of add-on boards in mikroBUS form factor. Boards feature MAX7219 8-digit LED display driver module as well as 64 LED diodes.

[Learn More]

UV 3 Click

0

UV 3 Click is an advanced ultraviolet (UV) light sensor with I2C protocol interface. The Click carries VEML6070 UVA light sensor designed by the CMOS process. UV 3 Click runs on either 3.3V or 5V power supply.

[Learn More]

Vibro Motor 4 Click

0

Vibro Motor 4 Click is a compact add-on board that makes an ideal solution for adding simple haptic feedback in any design. This board features the G1040003D, a coin-sized linear resonant actuator (LRA) that generates vibration/haptic feedback from Jinlong Machinery & Electronics, Inc. Driven by a flexible Haptic/Vibra driver, the DRV2605, G1040003D vibrates in the Z-axis, which is perpendicular to the face of the vibration motor. It draws a maximum of 170mA while producing the highest G force/vibration energy of 2 GRMS. This Click board™ makes an excellent choice for devices with limited battery capacity and for users who require crisp haptic feedback and low power consumption.

[Learn More]