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.

Reading MAC address using FlashUserGet() function



Hi Everyone !

I am referring to the part of example code taken from Tiva C Series software examples for TM4C1294XL lanuchpad, here i am unable to understand how
the following function gets the MAC address, is it necessary to retrieve it this way ? Secondly, Why we are doing this thing
" pui8MACAddr[0] = ((ui32User0 >> 0) & 0xff); "


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. // while(1) { } } / address into the Ethernet Controller registers. // pui8MACAddr[0] = ((ui32User0 >> 0) & 0xff); pui8MACAddr[1] = ((ui32User0 >> 8) & 0xff); pui8MACAddr[2] = ((ui32User0 >> 16) & 0xff); pui8MACAddr[3] = ((ui32User1 >> 0) & 0xff); pui8MACAddr[4] = ((ui32User1 >> 8) & 0xff); pui8MACAddr[5] = ((ui32User1 >> 16) & 0xff);
  • Hello,

    The FlashUserGet() function is to read the contents of user registers 0 and 1, and stores them in the specified locations (&ui32User0, &ui32User0). The MAC addresses are stored in the user register 0 and register 1. You don't have to use this function to read MAC address. For example, you can use this way:

      user0= *((volatile uint32_t *)(0x400FE1E0));

      user1= *((volatile uint32_t *)(0x400FE1E4));

     

    Regards,

    QJ

  • Thanks for replying. I got it.

    But you did not answer my second Question i.e.  Why we need conversion as done in the following code taken from enet_io example of Tiva C series ,

    //
        // 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.
        //
        pui8MACArray[0] = ((ui32User0 >>  0) & 0xff);
        pui8MACArray[1] = ((ui32User0 >>  8) & 0xff);
        pui8MACArray[2] = ((ui32User0 >> 16) & 0xff);
        pui8MACArray[3] = ((ui32User1 >>  0) & 0xff);
        pui8MACArray[4] = ((ui32User1 >>  8) & 0xff);
        pui8MACArray[5] = ((ui32User1 >> 16) & 0xff);

    Regards

    Haroon

  • Hi Haroon,

    The MAC address are 6-byte (40 bits) in length. Bit[23:0] are stored in user register0, and Bit[47:24] are stored in user register1. pui8MACAddr is the pointer to the array of MAC-48 address octets. The address passed to pui8MACAddr array is ordered with the first byte to be transmitted in the first array entry. Using pui8MACAddr makes it convenient to pass the address into MAC address regsiters.

    There are 4 sets of MAC address registers to hold the MAC address for TX and RX (EMACADDRxH, EMACADDRxL). Index 0 is used to hold the local node's MAC address which is inserted for all transmitted packet. Other slots may be programmed independently and used to filter the incoming packets.

    Please refer to the user guide !

    Regards,

    QJ