В исходном примере поменял адреса регистров:
Код
/* The PHY status register value change from a PHY to another, so the user have
to update this value depending on the used external PHY */
//#define PHY_SR ((uint16_t)16) /* Value for DP83848 PHY */
#define PHY_SR 0x1f //31 /*!< Tranceiver Status Register for LAN8700*/
/* The Speed and Duplex mask values change from a PHY to another, so the user
have to update this value depending on the used external PHY */
//#define PHY_SPEED_STATUS ((uint16_t)0x2000) /* Value for DP83848 PHY */
//#define PHY_DUPLEX_STATUS ((uint16_t)0x0100) /* Value for DP83848 PHY */
//for LAN8700
#define PHY_SPEED_STATUS ((u16)0x0004) /*!< Configured information of Speed: 10Mbps */
#define PHY_DUPLEX_STATUS ((u16)0x0010) /*!< Configured information of Duplex: Full-duplex */
to update this value depending on the used external PHY */
//#define PHY_SR ((uint16_t)16) /* Value for DP83848 PHY */
#define PHY_SR 0x1f //31 /*!< Tranceiver Status Register for LAN8700*/
/* The Speed and Duplex mask values change from a PHY to another, so the user
have to update this value depending on the used external PHY */
//#define PHY_SPEED_STATUS ((uint16_t)0x2000) /* Value for DP83848 PHY */
//#define PHY_DUPLEX_STATUS ((uint16_t)0x0100) /* Value for DP83848 PHY */
//for LAN8700
#define PHY_SPEED_STATUS ((u16)0x0004) /*!< Configured information of Speed: 10Mbps */
#define PHY_DUPLEX_STATUS ((u16)0x0010) /*!< Configured information of Duplex: Full-duplex */
Адрес PHY оставил 1, так как ножка PHYAD0 подтянута через резистор 4,7 K к 3,3в.
Тактиррвание 50 МГЦ включил.
Все зависает в этой функции:
Код
/* Configure Ethernet */
EthInitStatus = ETH_Init(Ð_InitStructure, DP83848_PHY_ADDRESS);
EthInitStatus = ETH_Init(Ð_InitStructure, DP83848_PHY_ADDRESS);
Читал значения регистров внешней PHY до ресета и сверял с значениями по умолчанию. они совпадают значит адрес должен быть правильным.
Код
/*-------------------- PHY initialization and configuration ----------------*/
temp = ETH_ReadPHYRegister(PHYAddress, 0x00); //!!!!! read bcr
temp1 = ETH_ReadPHYRegister(PHYAddress, 0x01); //!!!!! read status
temp2 = ETH_ReadPHYRegister(PHYAddress, 0x04); //!!!!! read status register
/* Put the PHY in reset mode */
if(!(ETH_WritePHYRegister(PHYAddress, PHY_BCR, PHY_Reset)))
{
/* Return ERROR in case of write timeout */
return ETH_ERROR;
}
temp = ETH_ReadPHYRegister(PHYAddress, 0x00); //!!!!! read bcr
temp1 = ETH_ReadPHYRegister(PHYAddress, 0x01); //!!!!! read status register
/* Delay to assure PHY reset */
_eth_delay_(PHY_RESET_DELAY);
temp = ETH_ReadPHYRegister(PHYAddress, 0x00); //!!!!! read bcr
temp1 = ETH_ReadPHYRegister(PHYAddress, 0x01); //!!!!! read status register
А вот после ресета PHY в регистрах bcr и bsr постоянно находится число 0х8000. То есть как поставили битик на програмный ресет так он и висит там постоянно и в статусном регистре точно такое же число находится.
И программа ждет пока установится Link Status в регистре bsr. Но этого не происходит(в этом регистре напостой 0х8000). После окончания таймаута программа попадает вот сюда:
Код
if (EthInitStatus == 0)
{
LCD_SetTextColor(Red);
LCD_DisplayStringLine(Line5, (uint8_t*)" Ethernet Init ");
LCD_DisplayStringLine(Line6, (uint8_t*)" failed ");
while(1);
}
{
LCD_SetTextColor(Red);
LCD_DisplayStringLine(Line5, (uint8_t*)" Ethernet Init ");
LCD_DisplayStringLine(Line6, (uint8_t*)" failed ");
while(1);
}
Может кто-то сталкивался с таким? Подскажите пожалуйста что можно предпринять в таком случае...