Use spi dma to increase w5500 transmission rate on Nucleus o stm32f401re

Source: Internet
Author: User

Wiznet w5500 supports up to 80 MHz SPI clock, so you can use MCU to provide a maximum transmission rate for high-speed Ethernet SPI communication. In this article, I will show how to use stm32 MCU to reach the maximum transmission rate of w5500.

When using a 32-bit processor from the stmicro cortex m3/M4 production line, the Ethernet transmission rate can change the maximum when using the SPI communication mode. I will compare different transmission rates using the SPI standard mode and the SPI DMA mode.

Composition

MCU: Nucleus stm32f401re

Ethernet controller: wiznet wiz550io (embedded w5500)

Pin Connection
The following table lists the pin connections between MCU and wiznet wiz550io.
First, connect the power cord.

Secondly, connect the SPI signal. Connect the SCS pin to gpioa_pin12 because I will process it with software.

Third, connect the rstn pin to gpioa_pin11 to reset the wiz550io.

Finally, use the gpioa_pin1 pin to connect to the rdy pin of w550io to complete initialization.

The connection between the rstn pin and the rdy pin is not crucial, but the connection is more stable.

How to Implement the SPI protocol

The SPI protocol controls w5500 In the same standard SPI mode and spi dma mode. However, the difference between the two modes is the idle time between the SPI bus data.

The SPI protocol for w5500 is provided in w5500.c of wiznet iolibrary and has the following functions.

  • Wizchip_read (uint32_t addrsel)
  • Wizchip_write (uint32_t addrsel, uint8_t WB)
  • Wizchip_read_buf (uint32_t addrsel, uint8_t * pbuf, uint16_t Len)
  • Wizchip_write_buf (uint32_t addrsel, uint8_t * pbuf, uint16_t Len)

When the spi dma mode is not used, internal functions call standard SPI read/write functions, such as the following wizchip_read_buf () function.

#if !defined (SPI_DMA)
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
for(i = 0; i < len; i++) pBuf[i] = WIZCHIP.IF.SPI._read_byte();

When the spi dma mode is used, the command data is prepared, which consists of the address and the operation code, called the spi_dma_read () function.

#else
spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
spi_data[2] = (AddrSel & 0x000000FF) >> 0;
SPI_DMA_READ(spi_data, pBuf, len);
#endif

As in "How to Use spi dma in stm32f2xx or stm32f4xx to complete full dual-attack communication", spi_dma_read () and spi_dma_write () are composed of code using the spi dma mode.

Performance Comparison between standard SPI mode and spi dma mode

The source code of the following data is a routine used for loopback testing. We can see the performance differences between the standard SPI mode and the spi dma mode.

Standard SPI Mode

In spi_handler.h
#ifndef SPI_DMA
//#define SPI_DMA
#endif

If you annotate the "# define spi_dma" line, You will operate in standard SPI mode.

If you have compiled a binary file on the nucleus oboard and tested the loopback on ax1.exe of wiznetbench, the transmission and receipt can reach 1.6 Mbps respectively, as shown in. We can see that the SPI transmission speed is as high as 3.2 Mbps.

Here, the SPI clock is 24 MHz, and you can clearly see the idle time between SPI data.

 

Spi dma mode

#ifndef SPI_DMA
#define SPI_DMA
#endif

As above, remove the comment in the "# define spi_dma" line.

Next, If you download the binary file to the nucleus O, then you can see the spi dma mode transmission rate. The transmission and reception loopback test performance can reach 4.3 Mbps respectively, and the SPI transmission rate exceeds 8 Mbps at full speed. If you use your own board and have a high-speed external clock to replace the nucleus board, you will get a faster transmission rate.


Here, you can see continuous SPI communication without any idle time, such.

By James ys Kim

Use spi dma to increase w5500 transmission rate on Nucleus o stm32f401re

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.