打印
[AT32F407]

AT32F407以太网设计注意事项

[复制链接]
508|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jf101|  楼主 | 2023-10-17 19:07 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
1、AT32F407 与 PHY 连接有两种方式:MII 模式与 RMII 模式,RMII 使用的 IO 口比 MII 少;以 DM9162 为
例,原理如下图。在 demo 程序中用宏定义 MII_MODE 和 RMII_MODE 区分。


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 程序中,具体的宏定义如下:
#define RX_REMAP (1)
#define CRYSTAL_ON_PHY (0)

//#define MII_MODE
#define RMII_MODE
#define DM9162
//#define DP83848
#if defined (DM9162)
#define PHY_ADDRESS (0x00) /*!< relative to at32 board */
#define PHY_CONTROL_REG (0x00) /*!< basic mode control register */
#define PHY_STATUS_REG (0x01) /*!< basic mode status register */
#define PHY_SPECIFIED_CS_REG (0x11) /*!< specified configuration and sta tus register */
/* phy control register */
#define PHY_AUTO_NEGOTIATION_BIT (0x1000) /*!< enable auto negotiation */
#define PHY_LOOPBACK_BIT (0x4000) /*!< enable loopback */
#define PHY_RESET_BIT (0x8000) /*!< reset phy */
/* phy status register */
#define PHY_LINKED_STATUS_BIT (0x0004) /*!< link status */
#define PHY_NEGO_COMPLETE_BIT (0x0020) /*!< auto negotiation complete */
/* phy specified control/status register */
#define PHY_FULL_DUPLEX_100MBPS_BIT (0x8000) /*!< full duplex 100 mbps */
#define PHY_HALF_DUPLEX_100MBPS_BIT (0x4000) /*!< half duplex 100 mbps */
#define PHY_FULL_DUPLEX_10MBPS_BIT (0x2000) /*!< full duplex 10 mbps */
#define PHY_HALF_DUPLEX_10MBPS_BIT (0x1000) /*!< half duplex 10 mbps */
#elif defined (DP83848)
#define PHY_ADDRESS (0x01) /*!< relative to at32 board */
#define PHY_CONTROL_REG (0x00) /*!< basic mode control register */
#define PHY_STATUS_REG (0x01) /*!< basic mode status register */
#define PHY_SPECIFIED_CS_REG (0x10) /*!< phy status register */
/* phy control register */
#define PHY_AUTO_NEGOTIATION_BIT (0x1000) /*!< enable auto negotiation */
#define PHY_LOOPBACK_BIT (0x4000) /*!< enable loopback */
#define PHY_RESET_BIT (0x8000) /*!< reset phy */
/* phy status register */
#define PHY_LINKED_STATUS_BIT (0x0004) /*!< link status */
#define PHY_NEGO_COMPLETE_BIT (0x0020) /*!< auto negotiation complete */

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


使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

184

主题

1220

帖子

2

粉丝