메인 콘텐츠로 건너뛰기
Knowledgebase
Home
Renesas Korea

How do I change the default MAC Address using the MCU unique ID during run time in NetX and NetX Duo applications?

Last Updated:01/23/2018

Question:

How do I change the default MAC Address to an MCU unique address, at runtime, in NetX and NetX Duo applications?

Answer:

To set a unique MAC address during run time, you need to add a special callback function that allows this change. Simply select your ETHERNET PORT module where you define the NetX IP Instance associated with the NetX or NetX Duo application. An example is shown in the below figure.

MAC_Address_F1.png

Then select the Callback in the properties tab as shown in the following figure.

MAC_Address_F2.png

In this example, the name of the function is entered as setMacAddress.  An example definition of that function is given below and it uses the FMI unique_idGet function to generate an MCU unique MAC Address. This code would be placed in the .c file of the thread that owns the Netx IP instance.

voidsetMacAddress (nx_mac_address_t*_pMacAddress)

{

    //  REA's Vendor MAC range: 00:30:55:xx:xx:xx

    fmi_unique_id_t id;

    g_fmi.p_api->uniqueIdGet(&id);

    ULONG lowerHalfMac=((0x55000000)|(id.unique_id[0]&(0x00FFFFFF)));

 

    _pMacAddress->nx_mac_address_h=0x0030;

    _pMacAddress->nx_mac_address_l=lowerHalfMac;

}

 

Suitable Products
SSP
  • 이 기사가 도움이 되셨나요?