STM32F4DIS-BB STM32Cube Ethernet

Gast #4082629
Lesenswert?

Hallo,

ich verwendet ein STM32F4Discovery mit Bais-Board und möchte eine 
Ethernet Anwendung mit LwIP realisieren.
Der Source-Code von Element14 funktioniert gut:
http://www.element14.com/community/docs/DOC-51670/l/stm32f4dis-bb-discover-more-software-examples
Ich würde jedoch lieber mit der STM32CubeF4 Bibliothek von ST arbeiten 
um die vielen anderen Beispiele nutzen zu können:
http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/LN1897/PF259243?s_searchtype=partnumber

Mein Problem:
Ich bekomme die SW (z.B. Http-Server Beispiel) nicht mit dem Phy LAN8720 
des STM32F4DIS-BB zum laufen.
Ich sehe zwei Möglichkeiten:
1) SW mit Stm32CubeMX erzeugen lassen und dann den Phy einzubinden. Oder
2) Das Beispiel des STM324xG-Eval auf meinen Phy LAN8720 abzuändern.

Kann mir jemand Tips bezüglich der Initialisierung und Konfiguration des 
LAN8720 geben.

Vielen Dank

P.S.
Ich verwendet Keil uVision 5
Gast #4083684
Lesenswert?

Hallo,

ich kann bei mir keine Phy-ID finden. Meintest du vielleicht die 
PhyAddress? Die habe ich schon mit 1 und 0 ausprobiert.


Ich habe mir noch mal mit Stm32CubeMX (siehe Anhang) Code erstellt mit 
FreeRTOS, LwIP, Debug-UART und ETH(RMII).

Muss man noch etwas an der Configuration ändern?
PHY_SR und diverse andere habe ich schon mal mit anderem Beispiel-Code 
vergleichen.
1
/* ################## Ethernet peripheral configuration ##################### */
2

3
/* Section 1 : Ethernet peripheral configuration */
4

5
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
6
#define MAC_ADDR0   2
7
#define MAC_ADDR1   0
8
#define MAC_ADDR2   0
9
#define MAC_ADDR3   0
10
#define MAC_ADDR4   0
11
#define MAC_ADDR5   0
12

13
/* Definition of the Ethernet driver buffers size and count */   
14
#define ETH_RX_BUF_SIZE                ETH_MAX_PACKET_SIZE /* buffer size for receive               */
15
#define ETH_TX_BUF_SIZE                ETH_MAX_PACKET_SIZE /* buffer size for transmit              */
16
#define ETH_RXBUFNB                    ((uint32_t)4)       /* 4 Rx buffers of size ETH_RX_BUF_SIZE  */
17
#define ETH_TXBUFNB                    ((uint32_t)4)       /* 4 Tx buffers of size ETH_TX_BUF_SIZE  */
18

19
/* Section 2: PHY configuration section */
20

21
/* DP83848 PHY Address*/ 
22
#define DP83848_PHY_ADDRESS             0x01
23
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ 
24
#define PHY_RESET_DELAY                 ((uint32_t)0x000000FF)
25
/* PHY Configuration delay */
26
#define PHY_CONFIG_DELAY                ((uint32_t)0x00000FFF)
27

28
#define PHY_READ_TO                     ((uint32_t)0x0000FFFF)
29
#define PHY_WRITE_TO                    ((uint32_t)0x0000FFFF)
30

31
/* Section 3: Common PHY Registers */
32

33
#define PHY_BCR                         ((uint16_t)0x00)    /*!< Transceiver Basic Control Register   */
34
#define PHY_BSR                         ((uint16_t)0x01)    /*!< Transceiver Basic Status Register    */
35
 
36
#define PHY_RESET                       ((uint16_t)0x8000)  /*!< PHY Reset */
37
#define PHY_LOOPBACK                    ((uint16_t)0x4000)  /*!< Select loop-back mode */
38
#define PHY_FULLDUPLEX_100M             ((uint16_t)0x2100)  /*!< Set the full-duplex mode at 100 Mb/s */
39
#define PHY_HALFDUPLEX_100M             ((uint16_t)0x2000)  /*!< Set the half-duplex mode at 100 Mb/s */
40
#define PHY_FULLDUPLEX_10M              ((uint16_t)0x0100)  /*!< Set the full-duplex mode at 10 Mb/s  */
41
#define PHY_HALFDUPLEX_10M              ((uint16_t)0x0000)  /*!< Set the half-duplex mode at 10 Mb/s  */
42
#define PHY_AUTONEGOTIATION             ((uint16_t)0x1000)  /*!< Enable auto-negotiation function     */
43
#define PHY_RESTART_AUTONEGOTIATION     ((uint16_t)0x0200)  /*!< Restart auto-negotiation function    */
44
#define PHY_POWERDOWN                   ((uint16_t)0x0800)  /*!< Select the power down mode           */
45
#define PHY_ISOLATE                     ((uint16_t)0x0400)  /*!< Isolate PHY from MII                 */
46

47
#define PHY_AUTONEGO_COMPLETE           ((uint16_t)0x0020)  /*!< Auto-Negotiation process completed   */
48
#define PHY_LINKED_STATUS               ((uint16_t)0x0004)  /*!< Valid link established               */
49
#define PHY_JABBER_DETECTION            ((uint16_t)0x0002)  /*!< Jabber condition detected            */
50
  
51
/* Section 4: Extended PHY Registers */
52

53
//#define PHY_SR                          ((uint16_t)0x10)    /*!< PHY status register Offset                      */
54
#define PHY_SR                          ((uint16_t)31)    /*!< PHY status register Offset                      */        // Andre
55
#define PHY_MICR                        ((uint16_t)0x11)    /*!< MII Interrupt Control Register                  */
56
#define PHY_MISR                        ((uint16_t)0x12)    /*!< MII Interrupt Status and Misc. Control Register */
57
 
58
#define PHY_LINK_STATUS                 ((uint16_t)0x0001)  /*!< PHY Link mask                                   */
59
#define PHY_SPEED_STATUS                ((uint16_t)0x0002)  /*!< PHY Speed mask                                  */
60
#define PHY_DUPLEX_STATUS               ((uint16_t)0x0004)  /*!< PHY Duplex mask                                 */
61

62
#define PHY_MICR_INT_EN                 ((uint16_t)0x0002)  /*!< PHY Enable interrupts                           */
63
#define PHY_MICR_INT_OE                 ((uint16_t)0x0001)  /*!< PHY Enable output interrupt events              */
64

65
#define PHY_MISR_LINK_INT_EN            ((uint16_t)0x0020)  /*!< Enable Interrupt on change of link status       */
66
#define PHY_LINK_INTERRUPT              ((uint16_t)0x2000)  /*!< PHY link status interrupt mask                  */

In der folgenden Funktion habe ich die den Reset-Pin des Phy für eine 
Weile auf low gesetzt.
1
void HAL_ETH_MspInit(ETH_HandleTypeDef* heth)
2
{
3
  GPIO_InitTypeDef GPIO_InitStruct;
4
  if(heth->Instance==ETH)
5
  {
6
  /* USER CODE BEGIN ETH_MspInit 0 */
7

8
  /* USER CODE END ETH_MspInit 0 */
9
    /* Peripheral clock enable */
10
    __ETH_CLK_ENABLE();
11
  
12
    /**ETH GPIO Configuration    
13
    PC1     ------> ETH_MDC
14
    PA1     ------> ETH_REF_CLK
15
    PA2     ------> ETH_MDIO
16
    PA7     ------> ETH_CRS_DV
17
    PC4     ------> ETH_RXD0
18
    PC5     ------> ETH_RXD1
19
    PB11     ------> ETH_TX_EN
20
    PB12     ------> ETH_TXD0
21
    PB13     ------> ETH_TXD1 
22
    */
23
    GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5;
24
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
25
    GPIO_InitStruct.Pull = GPIO_NOPULL;
26
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
27
    GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
28
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
29

30
    GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7;
31
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
32
    GPIO_InitStruct.Pull = GPIO_NOPULL;
33
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
34
    GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
35
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
36

37
    GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13;
38
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
39
    GPIO_InitStruct.Pull = GPIO_NOPULL;
40
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
41
    GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
42
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
43

44
    HAL_NVIC_SetPriority(ETH_IRQn, 5, 0);
45
    HAL_NVIC_EnableIRQ(ETH_IRQn);
46
  /* USER CODE BEGIN ETH_MspInit 1 */
47
  
48
    /* Configure the PHY RST  pin */                // Andre
49
    GPIO_InitStruct.Pin = GPIO_PIN_2;
50
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
51
    GPIO_InitStruct.Pull = GPIO_PULLUP;
52
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
53
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
54
    
55
    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_RESET);
56
    for (volatile uint32_t i = 0; i < 20000; i++);
57
    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_SET);
58
    for (volatile uint32_t i = 0; i < 20000; i++);
59

60
  /* USER CODE END ETH_MspInit 1 */
61
  }
62
}

Hat jemand noch ne Idee welche Einstellung man für den LAN8720 machen 
muss?

Viele Grüße

P.S.
Das Projekt ist knapp 30MB groß darf man das anhängen?
Angehängte Dateien:
Gast #4090803
Lesenswert?

Hallo Zusammen,

ich habe es leider nicht geschafft ein eigenes Projekt mit stm32cubeMX 
für das STM32F4DIS-BB und den LAN8720 zu erstellen. Aber auch die 
Beispiel-SW
http://www.element14.com/community/docs/DOC-51670/l/stm32f4dis-bb-discover-more-software-examples
scheint mir nach näheren Untersuchungen nicht einwandfrei zu 
funktionieren. Bei mir werden die Register des LAN8720 immer mit 0xFFFF 
ausgelesen.

Ich habe mir nun folgendes Board besorgt:
http://www.ti.com/tool/dp83848i-mau-ek

Damit konnte ich ein eigenes stm32f4cubeMX (siehe Anhang) Projekt um das 
http-Server Beispiel erweitern. Dazu habe ich die MII Schnittstelle 
verwendet.

Viele Grüße
Andre
Angehängte Dateien:
Gast #4091121
Lesenswert?

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren