Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Jocc
#73411 Hi All!

Is it possible to do 16bit transfers with the SPISlave library?
I'm using ESP8266 as SPI slave (programmed in Arduino IDE) and an FPGA as SPI master. The master sends 2048 pieces of 16bit data to the slave with 1 MHz SPI clock. After some minor problems i managed the spi slave to work in 8bit mode according to the SPISlave examples (SPISlave_Test.ino).
Is it possible to switch to 16bit mode?
User avatar
By luckystar
#83174 Hi Me-no-dev, I've been having a hell of a time with the ESP8266 SPI as slave and an ATmega328pb.
The project involves using ESP8266 as wifi module controlled via SPI from a master ATMega328pb.

I have a simple 16 bit command protocol where the slave let's the ATMega know there is data via gpio and ATMega sends a read command, give some time for the ESP send the data and then reads it with 0X03 + 0X00

There is a lot more involved and I can sure send more details if you need.

This is the master transaction
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));

Then I read slave with

SPI.transfer(0x03);
SPI.transfer(0x00);
for (uint8_t i = 0; i < 33; i++) {
message.dataBuffer[i] = SPI.transfer(0);
message.dataLen++;
}

First time I get some left shifting of bits on the data coming from slave, then this will happen on each third attempt. Two reads in the middle seem fine.

It seems you are very knowledgeable with this, would you be able to point me in a direction on where to look. I am reaching out because I am running out of ideas.

I'd be happy to send details via email or any other method, it's been beyond frustration at this point, any help would be greatly appreciated.

Thanks in advance.

Cheers.