中级
30 分钟

使用24AA025E64和STM32F031K6为您的应用提供唯一的节点地址

您网络的唯一身份

MAC Address Click with Nucleo 32 with STM32F031K6 MCU

已发布 10月 01, 2024

点击板

MAC Address Click

开发板

Nucleo 32 with STM32F031K6 MCU

编译器

NECTO Studio

微控制器单元

STM32F031K6

通过我们的解决方案赋予您的应用程序一个独特的节点身份,提供一种无缝和标准化的方法来分配唯一的MAC地址,以优化网络通信和管理。

A

A

硬件概览

它是如何工作的?

MAC Address Click基于24AA025E64,这是一款来自Microchip的具有预编程IEEE EUI-64 MAC地址的2Kb串行EEPROM。该设备被组织为两个128 x 8位内存块,带有2线串行接口。低电压设计允许在最低1.7V的电压下工作,最大待机和工作电流分别只有1uA和1mA。24AA025E64还具有最多16字节数据的页写入

能力。MAC Address Click为您的应用程序提供一个独特的节点地址。它还具有1Kbit的可写EEPROM内存。MAC Address Click搭载了带有EUI-64™节点身份的24AA025E64 2K I2C串行EEPROM。点击板设计为可以在3.3V或5V电源上运行。MAC Address Click通过I2C接口与目标微控制器通信。这个Click board™可以

通过PWR SEL跳线选择使用3.3V或5V逻辑电压级别,这样,3.3V和5V能力的MCU都可以正确使用通信线。此外,这个Click board™还配备了一个包含易于使用的功能和示例代码的库,可用作进一步开发的参考。

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

功能概述

开发板

Nucleo 32开发板搭载STM32F031K6 MCU,提供了一种经济且灵活的平台,适用于使用32引脚封装的STM32微控制器进行实验。该开发板具有Arduino™ Nano连接性,便于通过专用扩展板进行功能扩展,并且支持mbed,使其能够无缝集成在线资源。板载集成

ST-LINK/V2-1调试器/编程器,支持通过USB重新枚举,提供三种接口:虚拟串口(Virtual Com port)、大容量存储和调试端口。该开发板的电源供应灵活,可通过USB VBUS或外部电源供电。此外,还配备了三个LED指示灯(LD1用于USB通信,LD2用于电源

指示,LD3为用户可控LED)和一个复位按钮。STM32 Nucleo-32开发板支持多种集成开发环境(IDEs),如IAR™、Keil®和基于GCC的IDE(如AC6 SW4STM32),使其成为开发人员的多功能工具。

Nucleo 32 with STM32F031K6 MCU double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

ARM Cortex-M0

MCU 内存 (KB)

32

硅供应商

STMicroelectronics

引脚数

32

RAM (字节)

4096

你完善了我!

配件

Click Shield for Nucleo-32是扩展您的开发板功能的理想选择,专为STM32 Nucleo-32引脚布局设计。Click Shield for Nucleo-32提供了两个mikroBUS™插座,可以添加来自我们不断增长的Click板™系列中的任何功能。从传感器和WiFi收发器到电机控制和音频放大器,我们应有尽有。Click Shield for Nucleo-32与STM32 Nucleo-32开发板兼容,为用户提供了一种经济且灵活的方式,使用任何STM32微控制器快速创建原型,并尝试各种性能、功耗和功能的组合。STM32 Nucleo-32开发板无需任何独立的探针,因为它集成了ST-LINK/V2-1调试器/编程器,并随附STM32全面的软件HAL库和各种打包的软件示例。这个开发平台为用户提供了一种简便且通用的方式,将STM32 Nucleo-32兼容开发板与他们喜欢的Click板™结合,应用于即将开展的项目中。

Click Shield for Nucleo-32 accessories 1 image

使用的MCU引脚

mikroBUS™映射器

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

“仔细看看!”

Click board™ 原理图

MAC Address Click Schematic schematic

一步一步来

项目组装

Click Shield for Nucleo-144 front image hardware assembly

从选择您的开发板和Click板™开始。以Nucleo 32 with STM32F031K6 MCU作为您的开发板开始。

Click Shield for Nucleo-144 front image hardware assembly
Nucleo 144 with STM32L4A6ZG MCU front image hardware assembly
Stepper 22 Click front image hardware assembly
Prog-cut hardware assembly
Nucleo-32 with STM32 MCU 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 image step 5 hardware assembly
Necto image step 6 hardware assembly
STM32 M4 Clicker HA MCU/Select 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

实时跟踪您的结果

应用程序输出

此款Click板可通过两种方式进行接口连接和监控:

  • Application Output - 在调试模式下,使用“Application Output”窗口进行实时数据监控。按照本教程正确设置它。

软件支持

库描述

这个库包含了MAC Address Click驱动的API。

关键功能:

  • macaddress_get_mac - 通用读取MAC地址功能

  • macaddress_read_byte - 通用读取数据字节功能

开源

代码示例

完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio 应用程序代码也可以在MIKROE的GitHub账户中找到。

/*!
 * \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

额外支持

资源

喜欢这个项目吗?

'购买此套件' 按钮会直接带您进入购物车,您可以在购物车中轻松添加或移除产品。