WIZnet Developer Forum

SPI dummy character

Hello

I’m working around communication between microprocessor (as SPI Master) and WizFi250 (as SPI slave). So far I’m not able to make it work in a reasonable way so I need your help. I have connected these signals:
MISO
MOSI
SCK
NSS - pulling down before each characterand pushing up after each character transfered
SPI_DATA_READY - as flow control from slave

What is the correct “dummy” character (or ASCII code) to send to WizFi250 to force master to generate clock signal on SCK pin and to be able to read data from WizFi250 ?

I tried the following characters:
’\0’ - this makes it possible to read data from slave but the transfer from device never ends with SPI_DATA_READY=0
’\r’ - this makes device allways reply with “\r\n” (echo on) and transfer never ends and SPI_DATA_READY=1 set permanently
’q’ - this character makes the transfer finish with SPI_DATA_READY=0 but just once and next time the dummy character ‘q’ is read from the device multiple times and the next transfer never ends (SPI_DATA_READY=1)

What is the workaround for this issue? Or do I think about it bad way?

Hi oyoyoy

Maybe waht you want to know is below.
#define SPI_NULL (uint8_t) 0xF0

Please refer to the below link.
https://github.com/Wiznet/Arduino_WizFi250/tree/master/Software/WizFi250

Thank you

Just to simplify it to followers here’s the corresponding code (functions to read character from SPI) from your example that actually sends SPI_NULL.

uint8_t WizFi250SpiDrv::read(void) {
uint8_t spi_recv_byte;
spi_recv_byte = wizspi_byte((uint8_t)SPI_NULL, 1, 1, 1, m_spi_debug_level);
return spi_recv_byte;
}

uint8_t WizFi250SpiDrv::wizspi_byte(uint8_t byte, uint8_t issue_cs, uint16_t delay1, uint16_t delay2, uint8_t print) {
uint8_t spi_data;

if ( issue_cs != 0 )	digitalWrite(m_WizFi250_CS, LOW);
if ( delay1 > 0 )		delayMicroseconds(delay1 * 10);
spi_data = SPI.transfer(byte);
if ( delay2 > 0 )		delayMicroseconds(delay2 * 10);
if ( issue_cs != 0 )	digitalWrite(m_WizFi250_CS, HIGH);

return spi_data;

}

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.