Intermediate
30 min

Provide a unique node address for your application with 24AA025E64 and STM32F031K6

Your network's unique identity

MAC Address Click with Nucleo 32 with STM32F031K6 MCU

Published Oct 01, 2024

Click board™

MAC Address Click

Dev Board

Nucleo 32 with STM32F031K6 MCU

Compiler

NECTO Studio

MCU

STM32F031K6

Empower your application with a distinctive node identity using our solution, offering a seamless and standardized method to assign a unique MAC address for optimized network communication and management

A

A

Hardware Overview

How does it work?

MAC Address Click is based on the 24AA025E64, a 2Kb Serial EEPROM with a pre-programmed IEEE EUI-64 MAC address from Microchip. The device is organized as two blocks of 128 x 8-bit memory with a 2-wire serial interface. Low voltage design permits operation down to 1.7V, with maximum standby and active currents of only 1uA and 1mA, respectively. The 24AA025E64 also has a page write capability for up to sixteen bytes of data.

MAC Address Click provides a unique node address for your application. It also has 1Kbit of writable EEPROM memory. MAC Address click carries the 24AA025E64 2K I2C Serial EEPROM with EUI-64™ node identity. The click is designed to run on either 3.3V or 5V power supply. MAC Address click communicates with the target microcontroller over the I2C interface. This Click board™ can operate with either 3.3V or 5V logic

voltage levels selected via the PWR 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.

MAC Address Click top side image
MAC Address Click bottom side image

Features overview

Development board

Nucleo 32 with STM32F031K6 MCU board provides an affordable and flexible platform for experimenting with STM32 microcontrollers in 32-pin packages. Featuring Arduino™ Nano connectivity, it allows easy expansion with specialized shields, while being mbed-enabled for seamless integration with online resources. The

board includes an on-board ST-LINK/V2-1 debugger/programmer, supporting USB reenumeration with three interfaces: Virtual Com port, mass storage, and debug port. It offers a flexible power supply through either USB VBUS or an external source. Additionally, it includes three LEDs (LD1 for USB communication, LD2 for power,

and LD3 as a user LED) and a reset push button. The STM32 Nucleo-32 board is supported by various Integrated Development Environments (IDEs) such as IAR™, Keil®, and GCC-based IDEs like AC6 SW4STM32, making it a versatile tool for developers.

Nucleo 32 with STM32F031K6 MCU double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M0

MCU Memory (KB)

32

Silicon Vendor

STMicroelectronics

Pin count

32

RAM (Bytes)

4096

You complete me!

Accessories

Click Shield for Nucleo-32 is the perfect way to expand your development board's functionalities with STM32 Nucleo-32 pinout. The Click Shield for Nucleo-32 provides two mikroBUS™ sockets to add any functionality from our ever-growing range of Click boards™. We are fully stocked with everything, from sensors and WiFi transceivers to motor control and audio amplifiers. The Click Shield for Nucleo-32 is compatible with the STM32 Nucleo-32 board, providing an affordable and flexible way for users to try out new ideas and quickly create prototypes with any STM32 microcontrollers, choosing from the various combinations of performance, power consumption, and features. The STM32 Nucleo-32 boards do not require any separate probe as they integrate the ST-LINK/V2-1 debugger/programmer and come with the STM32 comprehensive software HAL library and various packaged software examples. This development platform provides users with an effortless and common way to combine the STM32 Nucleo-32 footprint compatible board with their favorite Click boards™ in their upcoming projects.

Click Shield for Nucleo-32 accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB6
SCL
I2C Data
PB7
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

MAC Address Click Schematic schematic

Step by step

Project assembly

Click Shield for Nucleo-144 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Nucleo 32 with STM32F031K6 MCU as your development board.

Click Shield for Nucleo-144 front image hardware assembly
Nucleo 144 with STM32L4A6ZG MCU front image hardware assembly
2x4 RGB Click front image hardware assembly
Prog-cut hardware assembly
Nucleo-32 with STM32 MCU 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 image step 5 hardware assembly
Necto image step 6 hardware assembly
Clicker 4 for STM32F4 HA MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

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.

Software Support

Library Description

This library contains API for MAC Address Click driver.

Key functions:

  • macaddress_get_mac - Generic read mac address function

  • macaddress_read_byte - Generic read the byte of data function

Open Source

Code example

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.

/*!
 * \file 
 * \brief MacAddress Click example
 * 
 * # Description
 * Provides a unique node address for your application.
 *
 * The application is composed of two sections :
 * 
 * ## Application Init 
 * Initialization driver enables - I2C, also write log.
 * 
 * ## Application Task - (code snippet) This is an example which demonstrates the use of MAC Address click board.
 * MAC Address click communicates with register via I2C protocol by the write to register and read from the register.
 * This example shows write/read single byte and sequential write/read from EEPROM.
 * Results are being sent to the Usart Terminal where you can track their changes.
 * All data logs write on USB uart changes for every 1 sec.
 * 
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "macaddress.h"


// ------------------------------------------------------------------ VARIABLES

static macaddress_t macaddress;
static log_t logger;

static uint8_t *write_data[ 3 ] = { "MikroE", "MAC Address", "MikroElektronika" };

static uint8_t data_len[ 3 ] = { 6 , 11, 16 };

static uint8_t mac_addr[ 8 ] = { 0 };

static uint8_t data_cnt;

static uint8_t read_buff[ 50 ] = { 0 };

static uint8_t address = 0x10;

// ------------------------------------------------------ APPLICATION FUNCTIONS

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

    macaddress_cfg_setup( &cfg );
    MACADDRESS_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    macaddress_init( &macaddress, &cfg );
    
    macaddress_get_mac( &macaddress, mac_addr );
    
    log_printf( &logger, " > MAC Address: 0x" );
    for ( uint8_t cnt = 0; cnt < 8; cnt++ )
    {
        log_printf( &logger, "%.02X", (uint16_t)mac_addr[ cnt ] );
    }
    log_printf( &logger, "\r\n" );

    Delay_ms( 1000 );
    log_info( &logger, "---- Application Task ----" );
    data_cnt = 0;
}

void application_task ( void )
{
    log_printf( &logger, " > Writing data to memory...\r\n" );
    Delay_ms( 100 );
    macaddress_generic_write( &macaddress, address, write_data[ data_cnt ], data_len[ data_cnt ] );
    log_printf( &logger, " > Writing done.\r\n" );
    Delay_ms( 1000 );
    
    
    log_printf( &logger, " > Reading data from memory...\r\n" );
    macaddress_generic_read( &macaddress, address, read_buff, data_len[ data_cnt ] );
    Delay_ms( 100 );
    log_printf( &logger, " > Read data: " );
    for( uint8_t cnt = 0; cnt < data_len[ data_cnt ]; cnt++ )
    {
        log_printf( &logger, "%c", read_buff[ cnt ] );
    }
    log_printf( &logger, "\r\n" );
    Delay_ms( 100 );
    log_printf( &logger, " > Reading done.\r\n" );
    log_printf( &logger, "---------------------------------\r\n" );
    data_cnt++;
    if ( data_cnt >= 3 )
        data_cnt = 0;
    
    Delay_ms( 3000 );
}

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.