AnsweredAssumed Answered

Accesing the field of a struct when it is a pointer?

Question asked by john doe on Apr 20, 2017
Latest reply on Apr 20, 2017 by Clive One

Having trouble reading the MAC address using the HAL but mostly because of my inexperience.


 uint8_t             *MACAddr;                   /*!< MAC Address of used Hardware: must be pointer on an array of 6 bytes */


printing heth.Init.MACAddr[0] does not print the first byte. It prints something, but not what I am expecting.  if I send &heth.Init.MACAddr[0] to printf, it does print the address, but the first try without the & produces what seems to be a different address. The value does not change no matter what I set the MAC Address to.  I'm obviously missing something when it comes to reading the value of a field of a struct when its a pointer.  Can someone help me get on the right path?


      len += sprintf(etherString+len, " MAC Address      : %02X:%02X:%02X:%02X:%02X:%02X\r\n",
              heth.Init.MACAddr[0], heth.Init.MACAddr[1], heth.Init.MACAddr[2], heth.Init.MACAddr[3],
              heth.Init.MACAddr[4], heth.Init.MACAddr[5]);



 MAC Address      : 84:00:00:20:2B:39


the mac address is actually 00:80:E1:00:00:00


what am I not getting?