cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Discovery Ethernet

najeeeb
Associate
Posted on November 17, 2011 at 13:13

hello friends

Can any body guide me on how can i use the ethernet module of stm32f407 on discovery kit? do i need something extra?

#stm32f4-discovery #ethernet #lwip
20 REPLIES 20
Posted on November 17, 2011 at 15:46

Well I suspect it's non-trivial, perhaps reviewing some F4 development board schematics will be enlightening.

http://www.st.com/internet/evalboard/product/252216.jsp

http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/USER_MANUAL/DM00036746.pdf

http://www.keil.com/mcbstm32f400/

http://www.keil.com/mcbstm32f400/mcbstm32f400-schematics.pdf

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andrej2
Associate
Posted on January 12, 2012 at 16:58

Hello,

I am also trying to connect stm32f4 discovery board with an ethernet phy. I am using DP83848 conected on a separate board using RMII interface. For physical connection I refered to description of ''STM3240G-EVAL evaluation board'', that can be found under link:

http://www.ebv.com/fileadmin/products/Products/STM/STM32F4_Series/User_Manual_STM3240G-EVAL.pdf

Still there is a conflict using pin PA7, which is used as SDA/SDI/SDO for LIS302DL on discovery board and is also part of RMII interface as RMII_CRS_DV signal. My assumption is that if I do not use accelerometer and do not configure microcontroller interface for it, then I can configure PA7 signal for RMII function.

As base I am using code downloaded from:

http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/stm32f4x7_eth_lwip.zip

I modified the GPIO initialization part in order to match discovery board and RMII interface.

This results in following code:

  /* Configure PA1, PA2 and PA7 */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_7;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_ETH);

 

  /* Configure PB11, PB12 and PB13 */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;

  GPIO_Init(GPIOB, &GPIO_InitStructure);

  GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_ETH);    

  GPIO_PinAFConfig(GPIOB, GPIO_PinSource12, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOB, GPIO_PinSource13, GPIO_AF_ETH);      

 

  /* Configure PC1, PC4 and PC5 */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5;

  GPIO_Init(GPIOC, &GPIO_InitStructure);

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource1, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource4, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_ETH);

Following instructions on some other posts I moved ehternet clock enabling after ethernet reset:

  /* Software reset */

  ETH_SoftwareReset();

  /* Wait for software reset */

  while (ETH_GetSoftwareResetStatus() == SET);

  /* Enable ETHERNET clock  */

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_ETH_MAC |  RCC_AHB1Periph_ETH_MAC_Tx |

                         RCC_AHB1Periph_ETH_MAC_Rx, ENABLE);

I configured the code such that CPU runs on 168 MHz. According to this, inside

ETH_Init()

the ETHERNET CSR Clock Range should be adapted. Here I run into problem not knowing what prescaler to use:

- inside the source code ETH_MACMIIAR_CR_Div102 is indicated as proper for 168 MHz clock

- in st32f4 user manual prescalers 62 is stated for HCLK 100-168 MHz! Is there a mistake in user manual document?

http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/REFERENCE_MANUAL/DM00031020.pdf

Comming to conclusion, my code now stucks inside

ETH_Init()

, when trying to get the link status:

   /* We wait for linked status... */

    do

    {

      timeout++;

    } while (!(ETH_ReadPHYRegister(PHYAddress, PHY_BSR) & PHY_Linked_Status) && (timeout < PHY_READ_TO));

MACMIIDR never gets value other than 0.

Has anybody succeeded connecting stm32f4 discovery board to and ethernet phy using RMII interface?

Can anybody give a suggestion what to check?

Posted on January 12, 2012 at 17:08

Still there is a conflict using pin PA7, which is used as SDA/SDI/SDO for LIS302DL on discovery board and is also part of RMII interface as RMII_CRS_DV signal.

 

Why wouldn't you just remove the LIS302DL from the board.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andrej2
Associate
Posted on January 13, 2012 at 08:17

Hello,

I finally can confirm that there is no problem with connecting RMII ethernet PHY even if PA7 is connected to accelerometer placed on discovery board. The only thing important is that you dont actually use accelerometer, which means that PA7 is configured for ethernet function not SPI. You dont have to unsolder accelerometer from the board.

My problem was with GPIO configuration inside ETH_GPIO_Config(). Because of using RMII mode I have put MCO pin initialization under conditional compilation for MII mode. Unfortunately I also removed GPIO_InitStructure initialization. This eventually resulted in all pins used for ethernet not being properly initialized.

Now the code looks something like:

  /* MII/RMII Media interface selection --------------------------------------*/

  /* Configure MCO (PA8) */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;

#ifdef MII_MODE /* Mode MII with STM324xG-EVAL  */

 #ifdef PHY_CLOCK_MCO

  GPIO_Init(GPIOA, &GPIO_InitStructure);

  /* Output HSE clock (25MHz) on MCO pin (PA8) to clock the PHY */

  RCC_MCO1Config(RCC_MCO1Source_HSE, RCC_MCO1Div_1);

 #endif /* PHY_CLOCK_MCO */

And stm32f4 discovery board is alive on ethernet!

dispachers
Associate
Posted on January 16, 2012 at 12:35

Hi andrej, 

I'm trying to make my first steps with the Ethernet interface for the STM32F1. I have already make some projects with the stm32F1 so I know the structures of the standard Library and so. But for my Ethernet project I have some problems:

There are 3 types of free TCP/IP stacks that you can use:

  • LwIP

  • uIP

  • Nichelite

The problem is that all the examples for the F1 are based on the evalboard and work only with an OS. And I don’t want to implement an OS on my board. Since I have a STM32F4-Discovery I could do my project on it. Can you please give me some information of the ehternetboard that you are using with the DP83848? Have you buy it or did you make it your self?

Would you share your quell-code?

Regards

From: zupanc.andrej

Posted: Friday, January 13, 2012 8:17 AM

Subject: STM32F4 Discovery Ethernet

Hello,

I finally can confirm that there is no problem with connecting RMII ethernet PHY even if PA7 is connected to accelerometer placed on discovery board. The only thing important is that you dont actually use accelerometer, which means that PA7 is configured for ethernet function not SPI. You dont have to unsolder accelerometer from the board.

My problem was with GPIO configuration inside ETH_GPIO_Config(). Because of using RMII mode I have put MCO pin initialization under conditional compilation for MII mode. Unfortunately I also removed GPIO_InitStructure initialization. This eventually resulted in all pins used for ethernet not being properly initialized.

Now the code looks something like:

  /* MII/RMII Media interface selection --------------------------------------*/

  /* Configure MCO (PA8) */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;

#ifdef MII_MODE /* Mode MII with STM324xG-EVAL  */

 #ifdef PHY_CLOCK_MCO

  GPIO_Init(GPIOA, &GPIO_InitStructure);

  /* Output HSE clock (25MHz) on MCO pin (PA8) to clock the PHY */

  RCC_MCO1Config(RCC_MCO1Source_HSE, RCC_MCO1Div_1);

 #endif /* PHY_CLOCK_MCO */

And stm32f4 discovery board is alive on ethernet!

khaled3310
Associate II
Posted on February 15, 2012 at 19:42

Hi I have also the same problems can I ask you some help ??thanks 

amin23
Associate II
Posted on February 20, 2012 at 07:37

New Ethernet demonstrations on STM32F4x7

http://www.st.com/internet/mcu/product/252145.jsp

vaidas
Associate II
Posted on December 29, 2012 at 11:38

Hi,

I'm new in STM microcontrollers and I would like to ask if someone had similar problem with ethernet and LwIP stack: I simply took first example in LwIP (httpserver) and got problem->after some code corrections as mentioned above, when I compile and start debugging, everything works fine, I can open my own made page (made by using fsdata) on browser and etc., but after microcontroller reset ETH_CheckFrameReceived() never returns 1 and packets are not handled...Any ideas? Thx.

vaidas
Associate II
Posted on December 29, 2012 at 15:57

Oh, it was my mistake, I didn't imagine how long could take DP83848 startup... the main problem was that stm32f407 starts mush faster and tries to initialize  DP83848 while it's not ready...small delay helped.