Using Ethernet LAN8720 and I2S Audio at same time
Posted: Wed May 22, 2019 4:41 pm
Hello together,
perhaps you can help me with this:
I am trying to get I2S and Ethernet (over LAN8720) working at the same time, but I think this is not possible if MCLK and 50MHz Ethernet Clock via APLL is needed for both modules.
Am I right and does someone know a workaround to force the ethernet driver to not change my APLL that I need for the I2S Master Clock?
As far as I can see this code is called in esp_eth_init() to set 50MHz no matter what eth_clock_mode_t type I have selected.
perhaps you can help me with this:
I am trying to get I2S and Ethernet (over LAN8720) working at the same time, but I think this is not possible if MCLK and 50MHz Ethernet Clock via APLL is needed for both modules.
Am I right and does someone know a workaround to force the ethernet driver to not change my APLL that I need for the I2S Master Clock?
As far as I can see this code is called in esp_eth_init() to set 50MHz no matter what eth_clock_mode_t type I have selected.
Code: Select all
//emac_main.c
esp_err_t esp_eth_init_internal(eth_config_t *config)
{
....
// 50 MHz = 40MHz * (6 + 4) / (2 * (2 + 2) = 400MHz / 8
rtc_clk_apll_enable(1, 0, 0, 6, 2);
REG_SET_FIELD(EMAC_EX_CLKOUT_CONF_REG, EMAC_EX_CLK_OUT_H_DIV_NUM, 0);
REG_SET_FIELD(EMAC_EX_CLKOUT_CONF_REG, EMAC_EX_CLK_OUT_DIV_NUM, 0);
if (emac_config.clock_mode == ETH_CLOCK_GPIO0_OUT) {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
REG_WRITE(PIN_CTRL, 6);
ESP_LOGD(TAG, "EMAC 50MHz clock output on GPIO0");
} else if (emac_config.clock_mode == ETH_CLOCK_GPIO16_OUT) {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO16_U, FUNC_GPIO16_EMAC_CLK_OUT);
ESP_LOGD(TAG, "EMAC 50MHz clock output on GPIO16");
} else if (emac_config.clock_mode == ETH_CLOCK_GPIO17_OUT) {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO17_U, FUNC_GPIO17_EMAC_CLK_OUT_180);
ESP_LOGD(TAG, "EMAC 50MHz inverted clock output on GPIO17");
}
}
....
}