打印
[应用相关]

AT32F407 以太网设计注意事项

[复制链接]
82|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
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 外接晶振。

使用特权

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

本版积分规则

认证:苏州澜宭自动化科技嵌入式工程师
简介:本人从事磁编码器研发工作,负责开发2500线增量式磁编码器以及17位、23位绝对值式磁编码器,拥有多年嵌入式开发经验,精通STM32、GD32、N32等多种品牌单片机,熟练使用单片机各种外设。

467

主题

3669

帖子

47

粉丝