Home Dev-board Bootloader TFTP DMX512 RDM Pixel LTC SMPTE Ethernet Memory GitHub Contact PayPal.Me Donate

Ethernet

Supported RMII PHY's: Features: Applications: Example building the firmware for RTL8201F:
make -f Makefile.GD32 clean && make -f Makefile.GD32 ENET_PHY=RTL8201F

RTL8201F RMSR Timing Configuration (GD32F4xx only)

Purpose

The RTL8201F PHY contains an RMII Mode Setting Register (RMSR) located at page 7, register 16. This register controls several RMII interface options, including the PHY’s programmable RMII transmit timing offset and RMII receive timing offset.

In the RTL8201F datasheet these fields are defined as:

The default value for both fields is 1111b .

The datasheet states that RMII TX and RX timing are adjustable with a minimum resolution of approximately 2 ns. However, it also notes that modifying these values is generally not recommended, since the default configuration is intended to provide the optimum timing for most platforms.

RMSR Register Function

In RMII mode, the PHY and MAC exchange data relative to the shared 50 MHz REFCLK. The interface timing margin therefore depends on:

The RTL8201F exposes programmable delay/offset fields in RMSR so that the effective RMII timing can be adjusted if the default timing does not meet the platform’s timing requirements.

Functionally:

The register also contains additional RMII configuration controls such as:

Code Implementation

			
			#define RMSR_RX_TIMING_SHIFT 4
			#define RMSR_RX_TIMING_MASK  0xF0
			#define RMSR_TX_TIMING_SHIFT 8
			#define RMSR_TX_TIMING_MASK  0xF00
		
		

These constants match the RTL8201F bit allocation:

The function constructs a value containing only these two fields and writes it using:

WritePaged(0x7, PHY_REG_RMSR, phy_value, mask)

The WritePaged() helper performs the following operations:

  1. Select PHY page 7
  2. Read the current register value
  3. Clear only the bits defined by the mask
  4. Insert the new field values
  5. Write the modified value back
  6. Restore page 0

This is important because RMSR contains additional configuration bits beyond the timing offsets. The implementation modifies only the TX/RX offset fields while preserving the remaining register state.

This is the correct approach when applying timing compensation to RMSR.

Values Written by CustomizedTiming()

For GD32F4xx targets the following timing values are used:

The resulting RMSR values written to the PHY are therefore:

Because the datasheet specifies only the minimum adjustment resolution (2 ns) and does not provide a full transfer function for these codes, the values should be interpreted as timing tap selections rather than precise absolute delay values.