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.
参考如下代码:
//
// Read the MAC address from the user registers.
//
MAP_FlashUserGet(&ui32User0, &ui32User1);
if((ui32User0 == 0xffffffff) || (ui32User1 == 0xffffffff))
{
//
// We should never get here. This is an error if the MAC address has
// not been programmed into the device. Exit the program.
//
UpdateStatus("MAC Address Not Programmed!");
while(1)
{
}
}
//
// Convert the 24/24 split MAC address from NV ram into a 32/16 split MAC
// address needed to program the hardware registers, then program the MAC
// address into the Ethernet Controller registers.
//
sTempAddr.addr[0] = ((ui32User0 >> 0) & 0xff);
sTempAddr.addr[1] = ((ui32User0 >> 8) & 0xff);
sTempAddr.addr[2] = ((ui32User0 >> 16) & 0xff);
sTempAddr.addr[3] = ((ui32User1 >> 0) & 0xff);
sTempAddr.addr[4] = ((ui32User1 >> 8) & 0xff);
sTempAddr.addr[5] = ((ui32User1 >> 16) & 0xff);
看楼上贴出的代码,是通过设置ui32User0,ui32User0的值来来吧设置的值给sTempAddr.addr这个数组的。
然后再把sTempAddr.addr的值写进相应的寄存器中。用的是EMACAddrSet这个函数应该是。
如果读回来是0XFF,那说明你的MAC地址没有设置。只能重新设置了,但是确实出厂的时候应该有默认MAC地址的。应该是你擦除的时候连flash中的数据也擦除了。用户寄存器中的数据清空了。