2024-08-26 04:35 AM
I am trying to interface to a 3 port switch "Micrel ksz8863" using the MDIO interface. I have setup the eth peripheral and I can measure activity on the data and clock pins on the MCU. I measure a clock speed of 1.75 Mhz. But when I try to debug, the data I get returned from the PHY is always 0xFFFF and HAL_OK.
uint32_t regValue = 0;
while(1){
HAL_StatusTypeDef status = HAL_ETH_ReadPHYRegister(&heth, 3, 0x0B, ®Value);
HAL_Delay(500);
}
CubeMX ETH generation:
static void MX_ETH_Init(void)
{
/* USER CODE BEGIN ETH_Init 0 */
/* USER CODE END ETH_Init 0 */
static uint8_t MACAddr[6];
/* USER CODE BEGIN ETH_Init 1 */
/* USER CODE END ETH_Init 1 */
heth.Instance = ETH;
MACAddr[0] = 0x00;
MACAddr[1] = 0x80;
MACAddr[2] = 0xE1;
MACAddr[3] = 0x00;
MACAddr[4] = 0x00;
MACAddr[5] = 0x00;
heth.Init.MACAddr = &MACAddr[0];
heth.Init.MediaInterface = HAL_ETH_RMII_MODE;
heth.Init.TxDesc = DMATxDscrTab;
heth.Init.RxDesc = DMARxDscrTab;
heth.Init.RxBuffLen = 1524;
/* USER CODE BEGIN MACADDRESS */
/* USER CODE END MACADDRESS */
if (HAL_ETH_Init(&heth) != HAL_OK)
{
Error_Handler();
}
memset(&TxConfig, 0 , sizeof(ETH_TxPacketConfig));
TxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CSUM | ETH_TX_PACKETS_FEATURES_CRCPAD;
TxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC;
TxConfig.CRCPadCtrl = ETH_CRC_PAD_INSERT;
/* USER CODE BEGIN ETH_Init 2 */
/* USER CODE END ETH_Init 2 */
}
Reading the datasheet, I aspect to read something else from just 0xFFFF. Se foto where register 0x0B is something else than 0xFFFF.
Any help is much appreciated!
Friendly regards, David
2024-08-26 04:38 AM
See also these threads:
https://community.st.com/t5/stm32-mcus-products/eth-anybody-used-ksz8863rll/td-p/645122