Hello @YongxiangLi ,
A few areas look worth checking first. Since TX works but both the RX packet counters and RX error counters remain at 0, I would currently suspect that the EMAC does not recognize valid RMII receive activity at all, rather than receiving frames and dropping them later.
The most important checks would be:
1) RMII reference clock timing during initialization
Please verify that the external 50 MHz RMII reference clock from the switch is already present and stable at the S32K322 pin before the EMAC/pin/clock initialization is executed. Very likely, you will need to add small delay, as it is recommended on S32K3-T-BOX. Please notice also the very first row in code snippet below:
2) RMII clock configuration inside the MCU
For S32K3 RMII, the MAC uses the 50 MHz RMII reference clock on EMAC_MII_RMII_TX_CLK, while the external RX_CLK pin is not used in RMII mode. However, the internal EMAC RX/TX clocks still need to be configured correctly (typically 25 MHz for 100 Mbps, derived from the 50 MHz RMII reference clock). Please double-check the EMAC clock mux/divider settings.
3) RMII mode selection
Please confirm that the gmac driver (for EMAC peripheral) is really configured for RMII mode (not MII) and that this selection is done early enough during initialization.
4) Switch-side RMII mode
Because your MAC is connected directly to a switch port rather than to a discrete PHY, please also verify that the switch port is truly configured for RMII/rev-RMII operation and is driving the correct 50 MHz reference clock toward the MCU.
5) Alternatively, you may compare your project with one of my S32K344 EMAC lwIP projects
S32K Examples
To help narrow this down, could you please share:
- What version of S32K3 RTD driver do you use?
- Could you share your project in minimalistic version or mex file at least?
Best regards,
Pavel