MII instead of RMII: receiving is not possible
Posted: Thu May 03, 2018 6:02 pm
Hello,
my collegues and me have made a PCB that connects ESP32 with an ethernet switch. The interface is MII and it uses no PHY.
I'm using an ESP32 from Pycom (W01). I made some small modifications to the esp_idf so that the ESP32 is configured to mii instead of rmii.
The sending direction is OK. I see DHCP packets at the other end of the ethernet switch. But the receiving direction does not work.
For mii, RXD0..3 are needed. MAC_RXD2 and UART0_TX are on the same pin though. That is why I set the loglevel to None and set CONFIG_CONSOLE_UART to CONFIG_CONSOLE_UART_NONE.
I measure at the pin MAC_RXD2 a constant voltage level of 2.2V.
Here are the functions I use for pin configuration:
Is there a mistake in the pin configuration for mii?
my collegues and me have made a PCB that connects ESP32 with an ethernet switch. The interface is MII and it uses no PHY.
I'm using an ESP32 from Pycom (W01). I made some small modifications to the esp_idf so that the ESP32 is configured to mii instead of rmii.
The sending direction is OK. I see DHCP packets at the other end of the ethernet switch. But the receiving direction does not work.
For mii, RXD0..3 are needed. MAC_RXD2 and UART0_TX are on the same pin though. That is why I set the loglevel to None and set CONFIG_CONSOLE_UART to CONFIG_CONSOLE_UART_NONE.
I measure at the pin MAC_RXD2 a constant voltage level of 2.2V.
Here are the functions I use for pin configuration:
Code: Select all
void phy_mii_configure_data_interface_pins(void)
{
// RXDV to GPIO27
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO27_U, FUNC_GPIO27_EMAC_RX_DV);
// TXD0 to GPIO19
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO19_U, FUNC_GPIO19_EMAC_TXD0);
// TX_EN to GPIO21
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO21_U, FUNC_GPIO21_EMAC_TX_EN);
// TXD1 to GPIO22
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO22_U, FUNC_GPIO22_EMAC_TXD1);
// TXD2 to GPIO14
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_MTMS_EMAC_TXD2);
// TXD3 to GPIO12
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_MTDI_EMAC_TXD3);
// TXER to GPIO04
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4_EMAC_TX_ER);
// RXD0 to GPIO25
gpio_set_direction(25, GPIO_MODE_INPUT);
// RXD1 to GPIO26
gpio_set_direction(26, GPIO_MODE_INPUT);
// RXD2 to GPIO01
gpio_set_direction(1, GPIO_MODE_INPUT);
// RXD3 to GPIO15
gpio_set_direction(15, GPIO_MODE_INPUT);
// RMII TXCLK to GPIO0
gpio_set_direction(0, GPIO_MODE_INPUT);
// RMII RXCLK to GPIO5
gpio_set_direction(5, GPIO_MODE_INPUT);
// RXER to GPIO13
gpio_set_direction(13, GPIO_MODE_INPUT);
}
void phy_rmii_smi_configure_pins(uint8_t mdc_gpio, uint8_t mdio_gpio)
{
// setup SMI MDC pin
gpio_set_direction(mdc_gpio, GPIO_MODE_OUTPUT);
gpio_matrix_out(mdc_gpio, EMAC_MDC_O_IDX, 0, 0);
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[mdc_gpio], PIN_FUNC_GPIO);
// setup SMI MDIO pin
gpio_set_direction(mdio_gpio, GPIO_MODE_INPUT_OUTPUT);
gpio_matrix_out(mdio_gpio, EMAC_MDO_O_IDX, 0, 0);
gpio_matrix_in(mdio_gpio, EMAC_MDI_I_IDX, 0);
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[mdio_gpio], PIN_FUNC_GPIO);
}