---
title: "One byte transfer in burst mode"
url: "https://maker.wiznet.io/forum/13911"
markdown_url: "https://maker.wiznet.io/forum/13911/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "Deusex25"
created: "2020-06-28T20:43:12+09:00"
last_activity: "2020-07-13T00:34:28+09:00"
language: "en"
views: 1397
replies: 2
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# One byte transfer in burst mode

## Question

Asked by Deusex25 on 2020-06-28 in Ethernet Chips.

Hi.
I’m working on app, which utilizes SPI in DMA mode for communication between STM32F030K6 and Wiz850. I have registered the following functions:

reg_wizchip_cs_cbfunc(SPI_Soft_nSS_On, SPI_Soft_nSS_Off);
reg_wizchip_spiburst_cbfunc( SPI_DMA_Rx_Burst, SPI_DMA_Tx_Burst);

Program works fine till the moment I try to use wizchip_getnetinfo() function. For some reason it calls WIZCHIP_READ function (what I believe it shouldn’t do if I registered SPI burst functions).

uint8_t WIZCHIP_READ(uint32_t AddrSel)
{
uint8_t ret;
uint8_t spi_data[3];

WIZCHIP_CRITICAL_ENTER();
WIZCHIP.CS._select();

AddrSel |= (*W5500_SPI_READ* | *W5500_SPI_VDM_OP*);

if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation
{
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
//ret = WIZCHIP.IF.SPI._read_byte();
}
else // burst operation
{
spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
spi_data[2] = (AddrSel & 0x000000FF) >> 0;
WIZCHIP.IF.SPI._write_burst(spi_data, 3);
}
ret = WIZCHIP.IF.SPI._read_byte();
WIZCHIP.CS._deselect();
WIZCHIP_CRITICAL_EXIT();
return ret;
}

As far as I can see, it has an option for burst as well, but it does not return anything (since it reading byte to be returned) and just keep writing three bytes: 0x00 0x01 0x08

I tried to modify burst part to write/read four bytes and return one as following:

uint8_t WIZCHIP_READ(uint32_t AddrSel) //This function is altered for SPI Burst operations
{
uint8_t ret;
//uint8_t spi_data[3];
uint8_t spi_data[4];

WIZCHIP_CRITICAL_ENTER();
WIZCHIP.CS._select();

AddrSel |= (*W5500_SPI_READ* | *W5500_SPI_VDM_OP*);

if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation
{
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
ret = WIZCHIP.IF.SPI._read_byte();
}
else // burst operation
{
spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
spi_data[2] = (AddrSel & 0x000000FF) >> 0;
WIZCHIP.IF.SPI._read_burst(spi_data, 4);
ret = spi_data[3];
}
//ret = WIZCHIP.IF.SPI._read_byte();
WIZCHIP.CS._deselect();
WIZCHIP_CRITICAL_EXIT();
return ret;
}

In this case I can have two UDP sockets open, but if I try to send out some data, using sendto() in main cycle, it returns SOCKERR_TIMEOUT for first time and SOCKERR_IPINVALID for all attemts after that.

First, I wonder why WIZCHIP_READ is called if I haven’t registered reg_wizchip_spi_cbfunc(), and second if this function has burst operation section, how it is supposed to be returning value?

Any ideas?

## Replies

### Reply 1 by becky, 2020-07-09

Hello,

![](https://github.githubassets.com/favicons/favicon.svg) [GitHub](https://github.com/WIZnet-ioLibrary/W5x00_DMA_with_W5100S_EVB)

![](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/a/ac12a6e498df1681552f1103f55496e068e3ce5f.png)

### [GitHub - WIZnet-ioLibrary/W5x00_DMA_with_W5100S_EVB: This Project is base on...](https://github.com/WIZnet-ioLibrary/W5x00_DMA_with_W5100S_EVB)

This Project is base on W5100S-EVB. but If you use the SPI of Arduino interface on W5100S-EVB, you can use the W5100S/W5100/W5200/W5500 when wizchip_conf.h modify - GitHub - WIZnet-ioLibrary/W5x00_...

Please refer to the link above.
This code is to control WIZnet CHIP through DMA communication using STM32F103.
Considering that a Socket INVALID ERROR occurs, your code does not seem to send or receive data properly.

### Reply 2 by Deusex25, 2020-07-13 (in reply to reply 1)

Hi Becky.

Thanks for help.

My code modification is right in this example. There was a hardware issue. Now it is solved.
I managed to get it working with variant I have suggested:

uint8_t WIZCHIP_READ(uint32_t AddrSel) //This function is altered for SPI Burst operations
{
uint8_t ret;
uint8_t spi_data[4];

WIZCHIP_CRITICAL_ENTER();
WIZCHIP.CS._select();

AddrSel |= ( *W5500_SPI_READ* | *W5500_SPI_VDM_OP* );

if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation
{
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
ret = WIZCHIP.IF.SPI._read_byte();
}
else // burst operation
{
spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
spi_data[2] = (AddrSel & 0x000000FF) >> 0;
WIZCHIP.IF.SPI._read_burst(spi_data, 4);
ret = spi_data[3];
}
WIZCHIP.CS._deselect();
WIZCHIP_CRITICAL_EXIT();
return ret;
}

There is a little advantage in speed, as there is no gap between address + control bytes and receiving data byte.
Besides this I do not need to register reg_wizchip_spi_cbfunc. The only functions I have to register are reg_wizchip_cs_cbfunc and reg_wizchip_spiburst_cbfunc.

---

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