cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing smt32H7 to Ksz8863 using ethernet MDIO

DavidWahlberg
Associate III

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, &regValue);
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.

DavidWahlberg_0-1724671903296.png

Any help is much appreciated!

Friendly regards, David

1 REPLY 1
SofLit
ST Employee

See also these threads:

https://community.st.com/t5/stm32-mcus-embedded-software/custom-pcb-stm32h7-and-ksz8863rll-rmii/td-p/682289

https://community.st.com/t5/stm32-mcus-products/eth-anybody-used-ksz8863rll/td-p/645122

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.