Intermediate
30 min

Sync your LEDs easily with BD18337EFV-M and ATmega3250

See the light, not the complexity!

LED Driver 14 Click with UNI-DS v8

Published Sep 09, 2023

Click board™

LED Driver 14 Click

Dev Board

UNI-DS v8

Compiler

NECTO Studio

MCU

ATmega3250

With our LED driver solution, controlling multiple LEDs becomes as easy as flicking a switch, giving you the power to create captivating lighting environments effortlessly

A

A

Hardware Overview

How does it work?

LED Driver 14 Click is based on the BD18337EFV-M, a four-channel constant current LED driver with built-in MOSFET ideal for LED rear lamps (turn/stop), fog lamps, and turn signals for automotive use from Rohm Semiconductor. The BD18337EFV-M incorporates a proprietary thermal dissipation circuit, and individual LED control function to drive LED lamps with different specifications by one driver. This allows up to 3 LEDs in series on its output OUTx pin. It also has integrated protection circuitry to guard against output-short, overvoltage, LED short-circuit protections, and overtemperature. This Click board™ provides an output current of 150mA per channel with an output current accuracy of ±5%, limited by two MCP4661 digital potentiometers from Microchip Technology, which establishes communication with the MCU via I2C serial interface. The MCP4661 also allows the choice of the least significant bit (LSB) of its I2C slave address by positioning SMD jumpers labeled as ADDR SEL to an appropriate position marked as 1 and 0. The MCP4661 also has a configurable Write Protection function labeled as WP routed on the

RST pin of the mikroBUS™ socket, which protects the entire memory and all registers from write operations and must be set to a low logic state to inhibit all the write operations. The BD18337EFV-M offers two ways to implement LED dimming: analog and PWM. Both methods control the average current flowing through the LEDs. The analog dimming can be achieved by adjusting the LED current by using an external voltage source on the VIN terminal, while the PWM dimming is implemented by direct control of the dimming control signal routed to the PWM pin on the mikroBUS™ socket. The selection can be made by positioning the SMD jumper labeled CRT SEL to an appropriate position marked as PWM or VIN. This board also has a two-channel switch labeled MSET, which allows changing output channel operation mode based on detecting an LED error. It also uses the INT pin of the mikroBUS™ socket in two ways: a 'fault' indicator, which immediately notifies the host when a fault condition occurs, or as an input that turns off the output current. The output channel operation mode is automatically selected according to a switch position. More information

about these selectable modes can be found in the attached datasheet. This Click board™ supports an external power supply for the motor, which can be connected to the input terminal labeled as VIN and should be within the range of 5.5V to 20V (typically about 12V). This wide range can lead to significant device power consumption in applications where a high input voltage is applied to the device and the output is relatively low. This amount of power can increase the BD18337EFV-M internal temperature to an unacceptable level, depending on the package's thermal resistance. The BD18337EFV-M employs an Energy Sharing Control to solve this issue, dissipating the extra power that can overheat the device in external resistors R2 and R3 (R3 is unpopulated by default configuration). This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

LED Driver 14 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

AVR

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

2048

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
DIGIPOT Write Protect
PG0
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
PWM Signal
PB4
PWM
Interrupt
PD1
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PE4
SCL
I2C Data
PE5
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

LED Driver 14 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
GNSS2 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
v8 SiBRAIN Access 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 via UART Mode

1. Once the code example is loaded, pressing the "FLASH" button initiates the build process, and programs it on the created setup.

2. After the programming is completed, click on the Tools icon in the upper-right panel, and select the UART Terminal.

3. After opening the UART Terminal tab, first check the baud rate setting in the Options menu (default is 115200). If this parameter is correct, activate the terminal by clicking the "CONNECT" button.

4. Now terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART_Application_Output

Software Support

Library Description

This library contains API for LED Driver 14 Click driver.

Key functions:

  • leddriver14_set_rset - This function sets the resistance of the selected rset channel

  • leddriver14_get_int_pin - This function returns the int pin logic state

  • leddriver14_set_duty_cycle - This function sets the PWM duty cycle in percentages ( Range[ 0..1 ] )

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 LEDDriver14 Click example
 *
 * # Description
 * This example demonstrates the use of LED Driver 14 click board by controlling
 * the brightness of LEDs by changing the PWM Duty Cycle.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration.
 *
 * ## Application Task
 * Adjusts the LEDs' brightness by changing the PWM duty cycle every 500ms.
 * A duty cycle value is being displayed on the USB UART.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "leddriver14.h"

static leddriver14_t leddriver14;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    leddriver14_cfg_t leddriver14_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.
    leddriver14_cfg_setup( &leddriver14_cfg );
    LEDDRIVER14_MAP_MIKROBUS( leddriver14_cfg, MIKROBUS_1 );
    err_t init_flag = leddriver14_init( &leddriver14, &leddriver14_cfg );
    if ( ( I2C_MASTER_ERROR == init_flag ) || ( PWM_ERROR == init_flag ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( LEDDRIVER14_ERROR == leddriver14_default_cfg ( &leddriver14 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    static int8_t duty_cnt = 1;
    static int8_t duty_inc = 1;
    float duty = duty_cnt / 10.0;
    
    leddriver14_set_duty_cycle ( &leddriver14, duty );
    log_printf( &logger, "> Duty: %d%%\r\n", ( uint16_t )( duty_cnt * 10 ) );
    
    if ( 10 == duty_cnt ) 
    {
        duty_inc = -1;
    }
    else if ( 0 == duty_cnt ) 
    {
        duty_inc = 1;
    }
    duty_cnt += duty_inc;
    
    if ( !leddriver14_get_int_pin ( &leddriver14 ) )
    {
        log_info ( &logger, " Abnormality such as LED Open or the OUTx pin short circuit occured " );
    }
    
    Delay_ms( 500 );
}

void main ( void ) 
{
    application_init( );

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

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

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.