请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TMS320F28388D 您好!
在 EtherCAT 应用中、我的客户想知道是否可以使用 F28388D 软件 API 强制以太网 PHY DP83822进入断电模式?
请告知您的评论,谢谢。
此致、
卢克
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好!
在 EtherCAT 应用中、我的客户想知道是否可以使用 F28388D 软件 API 强制以太网 PHY DP83822进入断电模式?
请告知您的评论,谢谢。
此致、
卢克
讨论已离线。 提供的建议:
相信通过向 PHY 寄存器写入数据可以实现这一点、 BMCR (BMCR) 在"SAFETY_FUNC_CFG 寄存器"中、 DPDWN 如果他们想要进入深度断电模式、第2位会生效。


如果您需要使用 MII 接口的 PHY 寄存器读/写功能、可以利用以下功能。 请注意、这些函数适用于 C28内核、CM 内核需要稍作修改的函数(可按8位字节寻址)。
函数声明:
//
// Functions for reading / writing to DP838xx PHY devices
//
#define ESC_MII_CTRL_STATUS_OFFSET 0x0510 // 0x288 - Low
#define ESC_PHY_ADDRESS_OFFSET 0x0512 // 0x289 - Low
#define ESC_PHY_REG_ADDRESS_OFFSET 0x0513 // 0x289 - High
#define ESC_PHY_DATA_OFFSET 0x0514 // 0x28A - Low
#define ESC_MII_ECAT_ACCESS_OFFSET 0x0516 // 0x28B - Low
#define ESC_MII_PDI_ACCESS_OFFSET 0x0517 // 0x28B - High
//
// Function for reading from an ESC PHY register using CPU1 -
// Assumes Word and address are 16-bit values
//
uint16_t mii_readPhyRegister(uint16_t address, uint16_t target_phy_address)
{
// Set PHY address to read/write, (0x0513//0x289 HIGH byte)
ESC_writeWordISR((address<<8) | target_phy_address, ESC_PHY_ADDRESS_OFFSET);
// Write PHY reg, (0x0510//0x288 low)
ESC_writeWordISR(0x0103,ESC_MII_CTRL_STATUS_OFFSET);
while(ESC_readWordISR(ESC_MII_CTRL_STATUS_OFFSET) != 0x3); // wait till read is completed and successful
return ESC_readWordISR(ESC_PHY_DATA_OFFSET);
}
//
// Function for writing to an ESC PHY register using CPU1 -
// Assumes Word and address are 16-bit values
//
void mii_writePhyRegister(uint16_t address, uint16_t target_phy_address, uint16_t data)
{
// Set PHY address to read/write, (0x0513//0x289 HIGH byte)
ESC_writeWordISR((address<<8) | target_phy_address, ESC_PHY_ADDRESS_OFFSET);
ESC_writeWordISR(data, ESC_PHY_DATA_OFFSET);
ESC_writeWordISR(0x203, ESC_MII_CTRL_STATUS_OFFSET);
while(ESC_readWordISR(ESC_MII_CTRL_STATUS_OFFSET) != 0x3); // wait till write is completed and successful
}
//
// Function for reading from an Extended ESC PHY register using CPU1 -
// Assumes Word and address are 16-bit values
//
uint16_t mii_readPhyExtendedRegister(uint16_t address, uint16_t target_phy_address)
{
mii_writePhyRegister(0xD, target_phy_address, 0x1F); //Phy reg 0xD = 0x1F
mii_writePhyRegister(0xE, target_phy_address, address); //Phy Reg 0xE = *Address of register outside of 0-1F
mii_writePhyRegister(0xD, target_phy_address, 0x401F); //Phy reg 0xD = 0x401F
return(mii_readPhyRegister(0xE,target_phy_address)); // Extended read data
}
void enable_PDI_access_to_MII(void)
{
ESC_writeWordISR(0x0100,ESC_MII_ECAT_ACCESS_OFFSET); // Give PDI access to MII management
return;
}
uint16_t phy_regs_0[32]; // For storing first 32 PHY registers of Port0
uint16_t ext_phy_regs_0[48]; // For storing Extended PHY registers of Port0
uint16_t phy_regs_1[32]; // For storing first 32 PHY registers of Port1
uint16_t ext_phy_regs_1[48]; // For storing Extended PHY registers of Port1
函数的使用:
//
// Initialize ESCSS Memory
//
ESCSS_initMemory(ESC_SS_BASE);
//
// Wait for ESCSS memory initialization to complete
//
if(ESCSS_getMemoryInitDoneStatusBlocking(ESC_SS_BASE, memoryTimeOut) !=
ESCSS_API_SUCCESS)
{
return(ESC_HW_INIT_FAIL);
}
ESTOP0;
// Read PHY registers...
enable_PDI_access_to_MII();
DEVICE_DELAY_US(100);
uint16_t index;
//
// Read Port0 PHY Registers
//
// Read first 32 PHY registers (non-extended)
for (index = 0; index < 32; ++index)
{
phy_regs_0[index] = mii_readPhyRegister(index, 0x00);
}
DEVICE_DELAY_US(100);
// Read extended PHY registers
ext_phy_regs_0[0] = mii_readPhyRegister(0x25, 0x00);
ext_phy_regs_0[1] = mii_readPhyRegister(0x27, 0x00);
ext_phy_regs_0[2] = mii_readPhyRegister(0x2A, 0x00);
ext_phy_regs_0[3] = mii_readPhyRegister(0x117, 0x00);
ext_phy_regs_0[4] = mii_readPhyRegister(0x131, 0x00);
ext_phy_regs_0[5] = mii_readPhyRegister(0x170, 0x00);
ext_phy_regs_0[6] = mii_readPhyRegister(0x171, 0x00);
ext_phy_regs_0[7] = mii_readPhyRegister(0x173, 0x00);
ext_phy_regs_0[8] = mii_readPhyRegister(0x175, 0x00);
ext_phy_regs_0[9] = mii_readPhyRegister(0x176, 0x00);
ext_phy_regs_0[10] = mii_readPhyRegister(0x177, 0x00);
ext_phy_regs_0[11] = mii_readPhyRegister(0x178, 0x00);
ext_phy_regs_0[12] = mii_readPhyRegister(0x180, 0x00);
ext_phy_regs_0[13] = mii_readPhyRegister(0x181, 0x00);
ext_phy_regs_0[14] = mii_readPhyRegister(0x182, 0x00);
ext_phy_regs_0[15] = mii_readPhyRegister(0x183, 0x00);
ext_phy_regs_0[16] = mii_readPhyRegister(0x184, 0x00);
ext_phy_regs_0[17] = mii_readPhyRegister(0x185, 0x00);
ext_phy_regs_0[18] = mii_readPhyRegister(0x186, 0x00);
ext_phy_regs_0[19] = mii_readPhyRegister(0x187, 0x00);
ext_phy_regs_0[20] = mii_readPhyRegister(0x188, 0x00);
ext_phy_regs_0[21] = mii_readPhyRegister(0x189, 0x00);
ext_phy_regs_0[22] = mii_readPhyRegister(0x18A, 0x00);
ext_phy_regs_0[23] = mii_readPhyRegister(0x302, 0x00);
ext_phy_regs_0[24] = mii_readPhyRegister(0x303, 0x00);
ext_phy_regs_0[25] = mii_readPhyRegister(0x304, 0x00);
ext_phy_regs_0[26] = mii_readPhyRegister(0x305, 0x00);
ext_phy_regs_0[27] = mii_readPhyRegister(0x306, 0x00);
ext_phy_regs_0[28] = mii_readPhyRegister(0x308, 0x00);
ext_phy_regs_0[29] = mii_readPhyRegister(0x30B, 0x00);
ext_phy_regs_0[30] = mii_readPhyRegister(0x30C, 0x00);
ext_phy_regs_0[31] = mii_readPhyRegister(0x30E, 0x00);
ext_phy_regs_0[32] = mii_readPhyRegister(0x404, 0x00);
ext_phy_regs_0[33] = mii_readPhyRegister(0x40D, 0x00);
ext_phy_regs_0[34] = mii_readPhyRegister(0x456, 0x00);
ext_phy_regs_0[35] = mii_readPhyRegister(0x460, 0x00);
ext_phy_regs_0[36] = mii_readPhyRegister(0x461, 0x00);
ext_phy_regs_0[37] = mii_readPhyRegister(0x467, 0x00);
ext_phy_regs_0[38] = mii_readPhyRegister(0x468, 0x00);
ext_phy_regs_0[39] = mii_readPhyRegister(0x469, 0x00);
ext_phy_regs_0[40] = mii_readPhyRegister(0x4A0, 0x00);
ext_phy_regs_0[41] = mii_readPhyRegister(0x4A1, 0x00);
ext_phy_regs_0[42] = mii_readPhyRegister(0x4A2, 0x00);
ext_phy_regs_0[43] = mii_readPhyRegister(0x4A3, 0x00);
ext_phy_regs_0[44] = mii_readPhyRegister(0x4A4, 0x00);
ext_phy_regs_0[45] = mii_readPhyRegister(0x4A5, 0x00);
ext_phy_regs_0[46] = mii_readPhyRegister(0x4A6, 0x00);
ext_phy_regs_0[47] = mii_readPhyRegister(0x4A7, 0x00);
//
// Read Port1 PHY Registers
//
// Read first 32 PHY registers (non-extended)
for (index = 0; index < 32; ++index)
{
phy_regs_1[index] = mii_readPhyRegister(index, 0x01);
}
DEVICE_DELAY_US(100);
// Read extended PHY registers
ext_phy_regs_1[0] = mii_readPhyRegister(0x25, 0x01);
ext_phy_regs_1[1] = mii_readPhyRegister(0x27, 0x01);
ext_phy_regs_1[2] = mii_readPhyRegister(0x2A, 0x01);
ext_phy_regs_1[3] = mii_readPhyRegister(0x117, 0x01);
ext_phy_regs_1[4] = mii_readPhyRegister(0x131, 0x01);
ext_phy_regs_1[5] = mii_readPhyRegister(0x170, 0x01);
ext_phy_regs_1[6] = mii_readPhyRegister(0x171, 0x01);
ext_phy_regs_1[7] = mii_readPhyRegister(0x173, 0x01);
ext_phy_regs_1[8] = mii_readPhyRegister(0x175, 0x01);
ext_phy_regs_1[9] = mii_readPhyRegister(0x176, 0x01);
ext_phy_regs_1[10] = mii_readPhyRegister(0x177, 0x01);
ext_phy_regs_1[11] = mii_readPhyRegister(0x178, 0x01);
ext_phy_regs_1[12] = mii_readPhyRegister(0x180, 0x01);
ext_phy_regs_1[13] = mii_readPhyRegister(0x181, 0x01);
ext_phy_regs_1[14] = mii_readPhyRegister(0x182, 0x01);
ext_phy_regs_1[15] = mii_readPhyRegister(0x183, 0x01);
ext_phy_regs_1[16] = mii_readPhyRegister(0x184, 0x01);
ext_phy_regs_1[17] = mii_readPhyRegister(0x185, 0x01);
ext_phy_regs_1[18] = mii_readPhyRegister(0x186, 0x01);
ext_phy_regs_1[19] = mii_readPhyRegister(0x187, 0x01);
ext_phy_regs_1[20] = mii_readPhyRegister(0x188, 0x01);
ext_phy_regs_1[21] = mii_readPhyRegister(0x189, 0x01);
ext_phy_regs_1[22] = mii_readPhyRegister(0x18A, 0x01);
ext_phy_regs_1[23] = mii_readPhyRegister(0x302, 0x01);
ext_phy_regs_1[24] = mii_readPhyRegister(0x303, 0x01);
ext_phy_regs_1[25] = mii_readPhyRegister(0x304, 0x01);
ext_phy_regs_1[26] = mii_readPhyRegister(0x305, 0x01);
ext_phy_regs_1[27] = mii_readPhyRegister(0x306, 0x01);
ext_phy_regs_1[28] = mii_readPhyRegister(0x308, 0x01);
ext_phy_regs_1[29] = mii_readPhyRegister(0x30B, 0x01);
ext_phy_regs_1[30] = mii_readPhyRegister(0x30C, 0x01);
ext_phy_regs_1[31] = mii_readPhyRegister(0x30E, 0x01);
ext_phy_regs_1[32] = mii_readPhyRegister(0x404, 0x01);
ext_phy_regs_1[33] = mii_readPhyRegister(0x40D, 0x01);
ext_phy_regs_1[34] = mii_readPhyRegister(0x456, 0x01);
ext_phy_regs_1[35] = mii_readPhyRegister(0x460, 0x01);
ext_phy_regs_1[36] = mii_readPhyRegister(0x461, 0x01);
ext_phy_regs_1[37] = mii_readPhyRegister(0x467, 0x01);
ext_phy_regs_1[38] = mii_readPhyRegister(0x468, 0x01);
ext_phy_regs_1[39] = mii_readPhyRegister(0x469, 0x01);
ext_phy_regs_1[40] = mii_readPhyRegister(0x4A0, 0x01);
ext_phy_regs_1[41] = mii_readPhyRegister(0x4A1, 0x01);
ext_phy_regs_1[42] = mii_readPhyRegister(0x4A2, 0x01);
ext_phy_regs_1[43] = mii_readPhyRegister(0x4A3, 0x01);
ext_phy_regs_1[44] = mii_readPhyRegister(0x4A4, 0x01);
ext_phy_regs_1[45] = mii_readPhyRegister(0x4A5, 0x01);
ext_phy_regs_1[46] = mii_readPhyRegister(0x4A6, 0x01);
ext_phy_regs_1[47] = mii_readPhyRegister(0x4A7, 0x01);
ESTOP0;
此致!
凯文
编辑:更新函数以修复 port1访问权限