Beginner
10 min
0

Capture every nuance of movement with LIS2HH12TR and MK51DN512CLQ10

Turning motion into meaning!

Accel 28 Click with UNI-DS v8

Published Nov 11, 2023

Click board™

Accel 28 Click

Development board

UNI-DS v8

Compiler

NECTO Studio

MCU

MK51DN512CLQ10

Turn raw motion data into valuable insights for your applications

A

A

Hardware Overview

How does it work?

Accel 28 Click is based on the LIS2HH12TR, an ultra-low-power, high-performance three-axis accelerometer from STMicroelectronics. The sensing element is made of a suspended silicone structure anchored in a few points and free to move toward the sensed acceleration. If there is an acceleration, the proof mass is displaced from its normal position and causes an imbalance in the capacitive half-bridge, which is measured. The whole measurements are on the values of internal capacitors. The values are outputted as 16-bit data. The sensor features extreme robustness with 10000g of high shock survivability. It also has an embedded temperature sensor for temperature compensation and a self-test. The self-test capability allows the user to check the functioning of the sensor in the final application. The sensor is

already factory-calibrated. The FIFO buffer of the LIS2HH12TR sensor works in several modes. Bypass mode bypasses the FIFO and is used to reset the FIFO when in FIFO mode. In FIFO mode, the sensor stores data from all three channels in the FIFO buffer. Stream mode provides continuous FIFO updates; the older data is discarded as new data arrives. There are additional modes: Stream-to-FIFO, Bypass-to-Stream, Bypass-to-FIFO, Retrieving data from FIFO, and Burst. The Burst mode allows multiple reads to be performed. Accel 28 Click allows the use of both I2C and SPI interfaces with a maximum frequency of 400KHz for I2C and 10MHz for SPI communication. The selection can be made by positioning SMD jumpers labeled as COMM SEL in an appropriate position. Note that all the jumpers' positions must

be on the same side, or the Click board™ may become unresponsive. While the I2C interface is selected, the LIS2DTW12 allows choosing the least significant bit (LSB) of its I2C slave address using the SMD jumper labeled ADDR SEL. The Accel 28 also possesses two interrupt pins, both routed to the INT pin on the mikroBUS™ socket over the INT SEL jumper (default INT1). These interrupt pins signal MCU that the user has sensed an event entirely through the I2C/SPI interface. 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.

Accel 28 Click hardware overview image

Features overview

Development board

UNI-DS v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different STM32, Kinetis, TIVA, CEC, MSP, PIC, dsPIC, PIC32, and AVR MCUs regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, UNI-DS v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the UNI-DS v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART, USB

HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. UNI-DS v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

UNI-DS v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

ARM Cortex-M4

MCU Memory (KB)

512

Silicon Vendor

NXP

Pin count

144

RAM (Bytes)

131072

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
PE12
CS
SPI Clock
PE2
SCK
SPI Data OUT
PE3
MISO
SPI Data IN
PE1
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
PA26
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PC10
SCL
I2C Data
PC11
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Accel 28 Click Schematic schematic

Step by step

Project assembly

Fusion for PIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the UNI-DS v8 as your development board.

Fusion for PIC v8 front image hardware assembly
Buck 22 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
v8 SiBRAIN MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for Accel 28 Click driver.

Key functions:

  • accel28_get_data - Accel 28 data reading function.

  • accel28_write_reg - Accel 28 register data writing function.

  • accel28_sw_reset - Accel 28 SW reset function.

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 main.c
 * @brief Accel 28 Click example
 *
 * # Description
 * This example demonstrates the use of Accel 28 click board by reading and
 * displaying the accelerometer data (X, Y, and Z axis).
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver, performs the click default configuration.
 *
 * ## Application Task
 * Reads and displays on the USB UART the accelerometer data (X, Y, and Z axis)
 * when it is available. 
 *
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "accel28.h"

static accel28_t accel28;
static log_t logger;
accel28_data_t accel_data;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    accel28_cfg_t accel28_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.
    accel28_cfg_setup( &accel28_cfg );
    ACCEL28_MAP_MIKROBUS( accel28_cfg, MIKROBUS_1 );
    err_t init_flag = accel28_init( &accel28, &accel28_cfg );
    if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    uint8_t id_data = 0;
    
    accel28_generic_read( &accel28, ACCEL28_REG_WHO_AM_I, &id_data, 1 );
    if ( ACCEL28_WHO_AM_I_VALUE != id_data )
    {
        log_error( &logger, " Communication error." );
        for ( ; ; );
    }
    
    if ( ACCEL28_ERROR == accel28_default_cfg ( &accel28 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
        
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    err_t error_flag = ACCEL28_OK;
    if ( ACCEL28_PIN_STATE_HIGH == accel28_get_int_state( &accel28 ) )
    {
        uint8_t tmp_data;
        error_flag = accel28_read_reg( &accel28, ACCEL28_REG_STATUS, &tmp_data );
         if ( ( tmp_data & ACCEL28_STATUS_ZYX_DATA_AVL ) && ( ACCEL28_OK == error_flag ) )
        {
            error_flag = accel28_get_data( &accel28, &accel_data );
            if ( ACCEL28_OK == error_flag )
            {
                log_printf( &logger, " X-axis %.2f mg\r\n", accel_data.x_data );
                log_printf( &logger, " Y-axis %.2f mg\r\n", accel_data.y_data );
                log_printf( &logger, " Z-axis %.2f mg\r\n", accel_data.z_data );
                log_printf( &logger, " = = = = = = = = = = = = = =\r\n" );
            }
        }
    }
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources