Skip to main content
Mark Greally
Associate III
September 21, 2017
Question

Initialize STM32f407 Ethernet without using libraries

Posted on September 21, 2017 at 17:03

Hi.

Is there any procedure available that shows the steps involved in initializing the Ethernet. The cube code generated uses libraries like HAL. I would like to do this without using these libraries. Is there a procedure that shows which registers need to be set?

Thanks.

#stm-32
    This topic has been closed for replies.

    10 replies

    waclawek.jan
    Super User
    September 21, 2017
    Posted on September 22, 2017 at 00:09

    I know of none.

    Youmight be better of starting off the older SPL-based examples rather than Cube. I know the ETH chapter in RM is dreadful but it may pay off to put some effort into reading it, too.

    Note, that data are moved around by the built-in scatter-gather DMA, so if you are not already familiar with these the task may become harder.

    JW

    waclawek.jan
    Super User
    September 22, 2017
    Posted on September 22, 2017 at 00:22

    You may also want to partition the task.

    First, switch on clocks (they are 3 of them) and configure the pins.

    Second, learn to talk to PHY through

    https://en.wikipedia.org/wiki/Management_Data_Input/Output

    . You should be able to get link up/down status from the PHY upon cable connect/disconnect.

    Third is to configure the MAC. I don't remember if there's a simple way to see it's up without getting to the DMA, maybe not and then you need to do also the following one in one step.

    Fourth is then the DMA and moving the data around.

    JW

    Mark Greally
    Associate III
    September 27, 2017
    Posted on September 27, 2017 at 11:23

    Thanks for the reply. It is steps 3 and 4 you mention that I am most interested in. I would have thought there would be some documentation provided by STM that would outline how the ip address, mac adresss, port numbers etc are stripped and how they are read and the general workings of the mac core.

    :(

    Mark Greally
    Associate III
    September 28, 2017
    Posted on September 28, 2017 at 11:48

    Where then can I find the most up to date code that implements a webserver?

    waclawek.jan
    Super User
    September 28, 2017
    Posted on September 28, 2017 at 12:48

    In Cube, I guess...?

    Look e.g. into  [STM32Cube_FW_F4_V1.16.0]\Projects\STM324xG_EVAL\Applications\LwIP\

    JW

    Mark Greally
    Associate III
    September 28, 2017
    Posted on September 28, 2017 at 14:48

    That is a useful looking resource. However I have used the cube to initialise the MC01 (PA8) as external clock to the PHY. My clock is 150MHz and want to divide by 3 to have 50MHz on PA8. The default code is as follows:

    /*Configure GPIO pin : PA8 */

    GPIO_InitStruct.Pin = GPIO_PIN_8;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF0_MCO;

    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    This gives a frequency of 16MHz and dosn't change even if I change the clock settings. I believe it is not configured correctly so I am wondering is there anything I am missing from the above?

    Thanks.