---
title: "W5500 DMA with STM32 HAL"
url: "https://maker.wiznet.io/forum/14261"
markdown_url: "https://maker.wiznet.io/forum/14261/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "murseloguzandic"
created: "2021-06-14T07:01:00+09:00"
last_activity: "2021-06-21T08:35:05+09:00"
language: "en"
views: 1862
replies: 2
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5500 DMA with STM32 HAL

## Question

Asked by murseloguzandic on 2021-06-14 in Ethernet Chips.

Hello,
I need to use STM32 DMA (HAL Library) with W5500. I can’t found any example with HAL libs. I have to use HAL because our mcu hasn’t any std library. What’s problem at this code part? BR.

```
uint8_t readByte() {

	uint8_t rxBuffer;
	HAL_SPI_Receive(&hspi3, &rxBuffer, 1, 0xFFFFFFFF);
	return rxBuffer;
}

void writeByte(uint8_t txBuffer) {

	HAL_SPI_Transmit(&hspi3, &txBuffer, 1, 0xFFFFFFFF);
}

void spiReadBurst(uint8_t *pBuf, uint16_t len) {

	HAL_SPI_TransmitReceive_DMA(&hspi3, w5500.spiRXBuffer, w5500.spiTXBuffer, len);
	memcpy(pBuf, w5500.spiRXBuffer, len);
}

void spiWriteBurst(uint8_t *pBuf, uint16_t len) {

	memcpy(w5500.spiTXBuffer, pBuf, len);
	HAL_SPI_Transmit_DMA(&hspi3, w5500.spiTXBuffer, len);
}

void w5500Init() {

	reg_wizchip_cs_cbfunc(csSelect, csDeselect);
	reg_wizchip_spi_cbfunc(readByte, writeByte);
	reg_wizchip_spiburst_cbfunc(spiReadBurst, spiWriteBurst);
	wizchip_init(w5500.spiBuffer, w5500.spiBuffer);

	wizchip_setnetinfo(&w5500);
	wizchip_getnetinfo(&w5500);

	w5500.result = socket(w5500.socketNumber, Sn_MR_UDP, w5500.localPort, 0); // 0 -> No flag need at UDP
}
```

## Replies

### Reply 1 by becky, 2021-06-17

please refer to link.

[github.com](https://github.com/WIZnet-ioLibrary/W5x00_DMA_with_W5100S_EVB/blob/master/src/main.c)

#### [WIZnet-ioLibrary/W5x00_DMA_with_W5100S_EVB/blob/master/src/main.c](https://github.com/WIZnet-ioLibrary/W5x00_DMA_with_W5100S_EVB/blob/master/src/main.c)

```
#include <stdio.h>
#include <stdlib.h>
#include "HAL_Config.h"
#include "HALInit.h"
#include "wizchip_conf.h"
#include "inttypes.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_exti.h"
#include "W5x00RelFunctions.h"
#include "serialCommand.h"

wiz_NetInfo gWIZNETINFO = { .mac = {0x00,0x08,0xdc,0x78,0x91,0x71},
							.ip = {192,168,0,15},
							.sn = {255, 255, 255, 0},
							.gw = {192, 168, 0, 1},
							.dns = {168, 126, 63, 1},
							.dhcp = NETINFO_STATIC};

#define ETH_MAX_BUF_SIZE	2048
```

This file has been truncated. [show original](https://github.com/WIZnet-ioLibrary/W5x00_DMA_with_W5100S_EVB/blob/master/src/main.c)

### Reply 2 by murseloguzandic, 2021-06-21 (in reply to reply 1)

This example doesn’t support HAL library. I have to use STM32H723 and ST didn’t publish H7 std lib…

---

Source: https://maker.wiznet.io/forum/14261
