cancel
Showing results for 
Search instead for 
Did you mean: 

stmCubeMx for STM32F7xx cpu ethernet function low_level_init not correct i think

Jos Poelmans
Associate II
Posted on March 08, 2017 at 16:22

static

void

low_level_init(

struct

netif

*netif)

{

uint32_t

regvalue = 0;

HAL_StatusTypeDef

hal_eth_init_status;

/*

Init

ETH */

uint8_t

MACAddr[6] ;

heth.

Instance

= ETH;

heth.

Init

.

AutoNegotiation

= ETH_AUTONEGOTIATION_ENABLE;

heth.

Init

.

PhyAddress

= LAN8742A_PHY_ADDRESS;

MACAddr[0] = 0x00;

MACAddr[1] = 0x80;

MACAddr[2] = 0xE1;

MACAddr[3] = 0x00;

MACAddr[4] = 0x00;

MACAddr[5] = 0x00;

heth.

Init

.

MACAddr

= &MACAddr[0];

heth.

Init

.

RxMode

= ETH_RXINTERRUPT_MODE;

heth.

Init

.

ChecksumMode

= ETH_CHECKSUM_BY_HARDWARE;

heth.

Init

.

MediaInterface

= ETH_MEDIA_INTERFACE_RMII;

heth.Init.MACAddr is a pointer to the MACAddr. but when i leave this funtion the pointer is not pointing to a defined

memory space. It is later on in the program not possible to get the MacAddr info form

heth.Init.MACAddr.  The pointer must point to a MACAddr that is available all the time the program is running.

2 REPLIES 2
Nesrine M_O
Lead II
Posted on March 09, 2017 at 17:51

Hi

Poelmans.Jos

,

  • Could you please give more explanation about your issue?

  • heth.

    Init

    .

    MACAddr

    = &MACAddr[0]; orheth.

    Init

    .

    MACAddr

    = MACAddr;point on the first address of the array.

  • Otherwise you can start from ready example under the STM32F7:

    STM32Cube_FW_F7_V1.6.0\Projects\STM32F769I_EVAL\Applications\LwIP\LwIP_IAP

-Nesrine-

Jos Poelmans
Associate II
Posted on March 10, 2017 at 07:30

the MACAddr is in local memory of the low_level_init function.

When you leave this funtion the reserved memor for MACAddr is give free for other use.

If you then want look to the info of the mac addres with heth.Init.MACAddr the data where this pointer

is pointing is not anymore valid.

I have use the code from

STM32Cube_FW_F7_V1.6.0.