29.01.2015 Views

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

RM0008<br />

Ethernet (ETH): media access control (MAC) with DMA controller<br />

Receive descriptor acquisition<br />

The receive engine always attempts to acquire an extra descriptor in anticipation of an<br />

incoming frame. Descriptor acquisition is attempted if any of the following conditions is/are<br />

satisfied:<br />

● The receive Start/Stop bit (ETH_DMAOMR register[1]) has been set immediately after<br />

the DMA has been placed in the Run state.<br />

● The data buffer of the current descriptor is full before the end of the frame currently<br />

being transferred<br />

● The controller has completed frame reception, but the current receive descriptor has<br />

not yet been closed.<br />

● The receive process has been suspended because of a CPU-owned buffer<br />

(RDES0[31] = 0) <strong>and</strong> a new frame is received.<br />

● A Receive poll dem<strong>and</strong> has been issued.<br />

Receive frame processing<br />

The MAC transfers the received frames to the STM32F107xx memory only when the frame<br />

passes the address filter <strong>and</strong> the frame size is greater than or equal to the configurable<br />

threshold bytes set for the Receive FIFO, or when the complete frame is written to the FIFO<br />

in Store-<strong>and</strong>-forward mode. If the frame fails the address filtering, it is dropped in the MAC<br />

block itself (unless Receive All ETH_MACFFR [31] bit is set). Frames that are shorter than<br />

64 bytes, because of collision or premature termination, can be purged from the Receive<br />

FIFO. After 64 (configurable threshold) bytes have been received, the DMA block begins<br />

transferring the frame data to the receive buffer pointed to by the current descriptor. The<br />

DMA sets the first descriptor (RDES0[9]) after the DMA AHB Interface becomes ready to<br />

receive a data transfer (if DMA is not fetching transmit data from the memory), to delimit the<br />

frame. The descriptors are released when the OWN (RDES0[31]) bit is reset to 0, either as<br />

the data buffer fills up or as the last segment of the frame is transferred to the receive buffer.<br />

If the frame is contained in a single descriptor, both the last descriptor (RDES0[8]) <strong>and</strong> first<br />

descriptor (RDES0[9]) bits are set. The DMA fetches the next descriptor, sets the last<br />

descriptor (RDES0[8]) bit, <strong>and</strong> releases the RDES0 status bits in the previous frame<br />

descriptor. Then the DMA sets the receive interrupt bit (ETH_DMASR register [6]). The<br />

same process repeats unless the DMA encounters a descriptor flagged as being owned by<br />

the CPU. If this occurs, the receive process sets the receive buffer unavailable bit<br />

(ETH_DMASR register[7]) <strong>and</strong> then enters the Suspend state. The position in the receive<br />

list is retained.<br />

Receive process suspended<br />

If a new receive frame arrives while the receive process is in Suspend state, the DMA refetches<br />

the current descriptor in the STM32F107xx memory. If the descriptor is now owned<br />

by the DMA, the receive process re-enters the Run state <strong>and</strong> starts frame reception. If the<br />

descriptor is still owned by the host, by default, the DMA discards the current frame at the<br />

top of the Rx FIFO <strong>and</strong> increments the missed frame counter. If more than one frame is<br />

stored in the Rx FIFO, the process repeats. The discarding or flushing of the frame at the<br />

top of the Rx FIFO can be avoided by setting the DMA Operation mode register bit 24<br />

(DFRF). In such conditions, the receive process sets the receive buffer unavailable status bit<br />

<strong>and</strong> returns to the Suspend state.<br />

Doc ID 13902 Rev 9 897/995

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!