[AT32F407] AT32F407以太网设计注意事项

[复制链接]
 楼主| jf101 发表于 2023-10-17 19:07 | 显示全部楼层 |阅读模式
1、AT32F407 与 PHY 连接有两种方式:MII 模式与 RMII 模式,RMII 使用的 IO 口比 MII 少;以 DM9162 为
例,原理如下图。在 demo 程序中用宏定义 MII_MODE 和 RMII_MODE 区分。
67805652e6abdcfd73.png

2. 不同厂家的 PHY 的也略有不同,程序上需要做响应的修改,一般是 PHY 地址和 PHY 状态寄存器不一样。
DM9162 的 PHY 的地址(PHY_ADDRESS)是 0x00,状态寄存器的地址(PHY_SR)是 0x11,网速标
志位和双工标志位是 bit12-bit15。
DP83848 的 PHY 的地址(PHY_ADDRESS)是 0x01,状态寄存器的地址(PHY_SR)是 0x10,网速标
志位是 bit1,双工标志位是 bit2。

在 demo 程序中,具体的宏定义如下:
  1. #define RX_REMAP (1)
  2. #define CRYSTAL_ON_PHY (0)

  3. //#define MII_MODE
  4. #define RMII_MODE
  5. #define DM9162
  6. //#define DP83848
  7. #if defined (DM9162)
  8. #define PHY_ADDRESS (0x00) /*!< relative to at32 board */
  9. #define PHY_CONTROL_REG (0x00) /*!< basic mode control register */
  10. #define PHY_STATUS_REG (0x01) /*!< basic mode status register */
  11. #define PHY_SPECIFIED_CS_REG (0x11) /*!< specified configuration and sta tus register */
  12. /* phy control register */
  13. #define PHY_AUTO_NEGOTIATION_BIT (0x1000) /*!< enable auto negotiation */
  14. #define PHY_LOOPBACK_BIT (0x4000) /*!< enable loopback */
  15. #define PHY_RESET_BIT (0x8000) /*!< reset phy */
  16. /* phy status register */
  17. #define PHY_LINKED_STATUS_BIT (0x0004) /*!< link status */
  18. #define PHY_NEGO_COMPLETE_BIT (0x0020) /*!< auto negotiation complete */
  19. /* phy specified control/status register */
  20. #define PHY_FULL_DUPLEX_100MBPS_BIT (0x8000) /*!< full duplex 100 mbps */
  21. #define PHY_HALF_DUPLEX_100MBPS_BIT (0x4000) /*!< half duplex 100 mbps */
  22. #define PHY_FULL_DUPLEX_10MBPS_BIT (0x2000) /*!< full duplex 10 mbps */
  23. #define PHY_HALF_DUPLEX_10MBPS_BIT (0x1000) /*!< half duplex 10 mbps */
  24. #elif defined (DP83848)
  25. #define PHY_ADDRESS (0x01) /*!< relative to at32 board */
  26. #define PHY_CONTROL_REG (0x00) /*!< basic mode control register */
  27. #define PHY_STATUS_REG (0x01) /*!< basic mode status register */
  28. #define PHY_SPECIFIED_CS_REG (0x10) /*!< phy status register */
  29. /* phy control register */
  30. #define PHY_AUTO_NEGOTIATION_BIT (0x1000) /*!< enable auto negotiation */
  31. #define PHY_LOOPBACK_BIT (0x4000) /*!< enable loopback */
  32. #define PHY_RESET_BIT (0x8000) /*!< reset phy */
  33. /* phy status register */
  34. #define PHY_LINKED_STATUS_BIT (0x0004) /*!< link status */
  35. #define PHY_NEGO_COMPLETE_BIT (0x0020) /*!< auto negotiation complete */

  36. #define PHY_DUPLEX_MODE (0x0004) /*!< full duplex mode */
  37. #define PHY_SPEED_MODE (0x0002) /*!< 10 mbps */
  38. #endif
3. 在读取 PHY 寄存器时不应该采用死循环读取,如果 PHY 损坏,那么整个系统的功能将异常。在读取 PHY
寄存器时应该有超时退出机制。
4. SPIM_CS 和 CLKOUT(MCO)都在 PA8 口,并且都没其他引脚可以重映射,所以使用 SPIM 接口时,PHY
的时钟不能由 PA8 提供,需要给 PHY 外接晶振。


您需要登录后才可以回帖 登录 | 注册

本版积分规则

255

主题

1850

帖子

3

粉丝
快速回复 返回顶部 返回列表