TOP Contributors

  1. MIKROE (2779 codes)
  2. Alcides Ramos (376 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 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 (139566 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57256 times)
  4. USB Device Library (47631 times)
  5. Network WiFi Library (43220 times)
  6. FT800 Library (42566 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26933 times)
  10. microSD click (26309 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

TDC 2 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.8

mikroSDK Library: 2.0.0.0

Category: Clock generator

Downloaded: 126 times

Not followed.

License: MIT license  

TDC 2 Click is a compact add-on board that recognizes events and provides a digital representation of the time they occurred. This board features ScioSense’s AS6500, a four-channel time-to-digital converter (TDC) frontend with high measurement performance and high data throughput. The AS6500 is characterized by simple data post-processing thanks to calibrated results (calculates calibrated stop measurements referenced to the applied reference clock).

No Abuse Reported

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

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

Do you want to report abuse regarding "TDC 2 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


TDC 2 Click

TDC 2 Click is a compact add-on board that recognizes events and provides a digital representation of the time they occurred. This board features ScioSense’s AS6500, a four-channel time-to-digital converter (TDC) frontend with high measurement performance and high data throughput. The AS6500 is characterized by simple data post-processing thanks to calibrated results (calculates calibrated stop measurements referenced to the applied reference clock).

tdc2_click.png

Click Product page


Click library

  • Author : Stefan Ilic
  • Date : Jan 2023.
  • Type : SPI type

Software Support

We provide a library for the TDC 2 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 from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for TDC 2 Click driver.

Standard key functions :

  • tdc2_cfg_setup Config Object Initialization function.

    void tdc2_cfg_setup ( tdc2_cfg_t *cfg );
  • tdc2_init Initialization function.

    err_t tdc2_init ( tdc2_t *ctx, tdc2_cfg_t *cfg );
  • tdc2_default_cfg Click Default Configuration function.

    err_t tdc2_default_cfg ( tdc2_t *ctx );

Example key functions :

  • tdc2_read_results TDC 2 results data reading function.

    err_t tdc2_read_results( tdc2_t *ctx, uint8_t reg, uint32_t *reference_index, uint32_t *stop_result );
  • tdc2_start_measuring TDC 2 start measuring function.

    err_t tdc2_start_measuring ( tdc2_t *ctx );
  • tdc2_set_resolution TDC 2 set resolution function.

    err_t tdc2_set_resolution ( tdc2_t *ctx, uint32_t resolution );

Example Description

This library contains API for TDC 2 Click driver. The library initializes and defines the SPI bus drivers to write and read data from registers, as well as the default configuration for a reading time between two STOP signals.

The demo application is composed of two sections :

Application Init

Initializes the driver after that resets the device and performs default configuration and sets the device in read mode.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    tdc2_cfg_t tdc2_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.
    tdc2_cfg_setup( &tdc2_cfg );
    TDC2_MAP_MIKROBUS( tdc2_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == tdc2_init( &tdc2, &tdc2_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( TDC2_ERROR == tdc2_default_cfg ( &tdc2 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    tdc2_start_measuring ( &tdc2 );
    log_info( &logger, " Application Task " );
}

Application Task

This example demonstrates the use of the TDC 2 Click board by measuring the time between two STOP signals. This example is set up to generate stop signals until FIFO fil's up which is indicated by interrupt pin going to low state. After that FIFO buffer is completely emptied by reading, and that data is used to calculate the time between STOP signals.

void application_task ( void )
{
    uint32_t reference_index [ 18 ] = { 0 };
    uint32_t stop_result [ 18 ] = { 0 };
    uint8_t cnt = 0;

    tdc2_reset_index( &tdc2 );
    Delay_ms ( 10 );

    while ( tdc2_get_int_state( &tdc2 ) == 1 )
    {
        dev_generate_stop( &tdc2 );
        Delay_ms ( 100 );
    }

    while ( tdc2_get_int_state( &tdc2 ) == 0 )
    {
        tdc2_read_results( &tdc2, TDC2_REG_INDEX_CH1_BYTE3, &reference_index[ cnt ], &stop_result[ cnt ] );

        log_printf( &logger, "CH1: Reference Index[%d]: %lu, Stop Result[%d]: %lu \r\n", ( uint16_t ) cnt, 
                    reference_index[ cnt ], ( uint16_t ) cnt, stop_result[ cnt ] ); 
        Delay_ms ( 10 ); 

        if ( cnt )
        {
            uint32_t time = 0;
            tdc2_get_time_between_stops ( &tdc2, stop_result[ cnt - 1 ], reference_index[ cnt - 1 ],
                                          stop_result[ cnt ], reference_index[ cnt ], &time );
            log_printf( &logger, "Time between STOP %d and STOP %d is %lu ms \r\n", 
                        ( uint16_t ) ( cnt - 1 ), ( uint16_t ) cnt, time / TDC2_uS_TO_mS ); 
            Delay_ms ( 10 );
        }
        cnt++;
    }
    log_printf( &logger, "---------------------------------------------- \r\n" ); 
}

Note

In order to test this example, you will need to connect STOP1 with the DIS pin. Disable pin is disabled by software and it isn't going to affect the working state of the TDC 2 Click Bord.

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.TDC2

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. UART terminal is available in all MikroElektronika compilers.


ALSO FROM THIS AUTHOR

DC Motor 29 Click

0

DC Motor 29 Click is a compact add-on board that contains a high-performance DC motor driver. This board features the DRV8245P, an automotive H-Bridge driver with integrated current sense and diagnostic from Texas Instruments. It can be configured as a single full-bridge driver or independent half-bridge driver. The driver offers excellent power handling and thermal capability due to a BiCMOS high power process technology mode, in which it is designed.

[Learn More]

Buck 14 Click

0

The Buck 14 Click is a Click board™ based around the BMR4613001/001, a PoL regulator from Flex. It's high-efficiency step-down converter which provides a highly regulated output voltage derived from the connected power source, rated from 4.5 to 14V.

[Learn More]

Hall Switch click

5

Hall Switch click is a magnetic field activated dual-relay Click board. Hall Switch click has two high-quality relays, which are activated by the Hall-effect sensor.

[Learn More]