---
title: "Let's use SPI and DMA using STM32F103, W5100s"
url: "https://maker.wiznet.io/luca__________/projects/lets-use-spi-and-dma-using-stm32f103/"
markdown_url: "https://maker.wiznet.io/luca__________/projects/lets-use-spi-and-dma-using-stm32f103/md"
type: "UCC: User Created Content"
author: "요미라라"
author_url: "https://blog.naver.com/roruca/221437948413"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "요미라라"
original_url: "https://blog.naver.com/roruca/221437948413"
published: "2023-08-05"
language: "en"
hardware: ["WIZnet W5100S-EVB"]
likes: 0
views: 517
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Let's use SPI and DMA using STM32F103, W5100s

> Let's use SPI and DMA using STM32F103

Original author: 요미라라 (source: https://blog.naver.com/roruca/221437948413)

## Components

- **WIZnet W5100S-EVB** x 1 ([docs](https://docs.wiznet.io/Product/iEthernet/W5100S/w5100s-evb))

## Article

[test code repo is here :](https://github.com/Wiznet/W5100S-EVB)

<https://github.com/Wiznet/W5100S-EVB>

Let's look at SPI communication first and operate it. Since SPI communication uses a pin with a small number of BUS to communicate, if there is a restriction on the PIN to use, it is a commonly used peripherals. If there is something you do not understand, please point it out I have to go!

![](https://maker.wiznet.io/upload/ckeditor5/632330378%5F1691244273%2Epng)

![](https://maker.wiznet.io/upload/ckeditor5/632330378%5F1691244299%2Epng)

we should follow SPI frame.

test environment

![](https://maker.wiznet.io/upload/ckeditor5/632330378%5F1691244325%2Epng)

**SPI Initialize**

![](https://maker.wiznet.io/upload/ckeditor5/632330378%5F1691244345%2Epng)

There are precautions when using DMA! In case of DMA, RX/TX move simultaneously,

That is why,

Even if you only want DMA RX operation, you have to perform TX operation for normal operation!

=============================================================================

to understand DMA, I questioned about DMA buffer size to OpenAI ChatGPT

![](https://maker.wiznet.io/upload/ckeditor5/632330378%5F1691244505%2Epng)

DMA (Direct Memory Access) buffer size is related to FIFO depth.

DMA mainly refers to a technology in a computer system to transfer data directly to memory. This allows the CPU to move data through the DMA controller rather than directly transfer the data.

DMA controllers have first-in-first-out (FIFO) buffers for temporary storage used to move data. FIFO is a data structure that stores data in the order that they come in first, and processes the data that came in first.

The depth of a FIFO indicates the number of data that can be stored in the FIFO. That is, the greater the depth of the FIFO, the greater the amount of data the DMA can process at one time.

On the other hand, width refers to the number of bits of data the DMA is processing at one time. DMAs with larger widths can process more data at one time.

In summary, the buffer size of DMA corresponds to the depth of FIFO. If the depth of the FIFO is large, the amount of data that the DMA can process at one time increases. In contrast, the width of DMA means the number of bits of data processed at one time.

![](https://maker.wiznet.io/upload/ckeditor5/632330378%5F1691244560%2Epng)

The width of a DMA indicates the number of bits of data the DMA handles at one time.

DMA usually transfers a fixed number of bits of data at a time. This number of bits is system-dependent, with 8-bit, 16-bit, 32-bit, and 64-bit being the most common.

For example, a 16-bit DMA transfers 16 bits of data at a time, a 32-bit DMA transfers 32 bits of data at a time, and so on.

The width of DMA determines the number of bits to be transferred at one time when data is transferred to memory, so the larger the value, the more data can be processed at one time. However, this value must be compatible with the DMA controller and other elements of the system, and must match the width of the memory's data bus for maximum efficiency.

![](https://maker.wiznet.io/upload/ckeditor5/846171549%5F1691340112%2Epng)

---

Source: https://maker.wiznet.io/luca__________/projects/lets-use-spi-and-dma-using-stm32f103/
