Dear Sir,
您好,请问TM4C129X 系类的MCU,内部以太网控制器:
(1)每个芯片有自己的MAC出厂MAC地址么?
(2)MAC地址可以随意修改么?比如说,将我们自己的常用设备的MAC地址写进去,可以么?
(3)如何修改MAC地址?
请帮忙回答上述问题,非常感谢支持!
Leo
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Dear Sir,
您好,请问TM4C129X 系类的MCU,内部以太网控制器:
(1)每个芯片有自己的MAC出厂MAC地址么?
(2)MAC地址可以随意修改么?比如说,将我们自己的常用设备的MAC地址写进去,可以么?
(3)如何修改MAC地址?
请帮忙回答上述问题,非常感谢支持!
Leo
出厂会有默认地址
MAC当然可以随意修改
3、修改MAC
//*****************************************************************************
//
//! Sets the MAC address of the Ethernet controller.
//!
//! \param ui32Base is the base address of the Ethernet controller.
//! \param ui32Index is the zero-based index of the MAC address to set.
//! \param pui8MACAddr is the pointer to the array of MAC-48 address octets.
//!
//! This function programs the IEEE-defined MAC-48 address specified in
//! \e pui8MACAddr into the Ethernet controller. This address is used by the
//! Ethernet controller for hardware-level filtering of incoming Ethernet
//! packets (when promiscuous mode is not enabled). Index 0 is used to hold
//! the local node's MAC address which is inserted into all transmitted
//! packets.
//!
//! The controller may support several Ethernet MAC address slots, each of which
//! may be programmed independently and used to filter incoming packets. The
//! number of MAC addresses that the hardware supports may be queried using a
//! call to EMACNumAddrGet(). The value of the \e ui32Index parameter must
//! lie in the range from 0 to (number of MAC addresses - 1) inclusive.
//!
//! The MAC-48 address is defined as 6 octets, illustrated by the following
//! example address. The numbers are shown in hexadecimal format.
//!
//! AC-DE-48-00-00-80
//!
//! In this representation, the first three octets (AC-DE-48) are the
//! Organizationally Unique Identifier (OUI). This is a number assigned by
//! the IEEE to an organization that requests a block of MAC addresses. The
//! last three octets (00-00-80) are a 24-bit number managed by the OUI owner
//! to uniquely identify a piece of hardware within that organization that is
//! to be connected to the Ethernet.
//!
//! In this representation, the octets are transmitted from left to right,
//! with the ``AC'' octet being transmitted first and the ``80'' octet being
//! transmitted last. Within an octet, the bits are transmitted LSB to MSB.
//! For this address, the first bit to be transmitted would be ``0'', the LSB
//! of ``AC'', and the last bit to be transmitted would be ``1'', the MSB of
//! ``80''.
//!
//! The address passed to this function in the \e pui8MACAddr array is
//! ordered with the first byte to be transmitted in the first array entry.
//! For example, the address given above could be represented using the
//! following array:
//!
//! uint8_t g_pui8MACAddr[] = { 0xAC, 0xDE, 0x48, 0x00, 0x00, 0x80 };
//!
//! If the MAC address set by this function is currently enabled, it remains
//! enabled following this call. Similarly, any filter configured for
//! the MAC address remains unaffected by a change in the address.
//!
//! \return None.
//
//*****************************************************************************
void
EMACAddrSet(uint32_t ui32Base, uint32_t ui32Index, const uint8_t *pui8MACAddr)
{
//
// Parameter sanity check.
//
ASSERT(ui32Index < NUM_MAC_ADDR);
ASSERT(pui8MACAddr);
//
// Set the high 2 bytes of the MAC address. Note that we must set the
// registers in this order since the address is latched internally
// on the write to EMAC_O_ADDRL.
//
HWREG(ui32Base + EMAC_O_ADDRH(ui32Index)) =
((HWREG(ui32Base + EMAC_O_ADDRH(ui32Index)) & 0xFFFF0000) |
pui8MACAddr[4] | (pui8MACAddr[5] << 8));
//
// Set the first 4 bytes of the MAC address
//
HWREG(ui32Base + EMAC_O_ADDRL(ui32Index)) =
(pui8MACAddr[0] | (pui8MACAddr[1] << 8) | (pui8MACAddr[2] << 16) |
(pui8MACAddr[3] << 24));
}