Hi Folks,
anyone knows what is the maximum word size for ESP32 possible to read over SPI communication?
I'm trying to interface the gyroscope/accelerometer with ESP32 (in Arduino IDE), which requires 32 bit SPI for reading and writing. I can split 32 bits into 4 bytes and write, but how can I read the 32 bit response?
ESP32 has 64 byte SPI FIFO size, but what is the SPI receive register size?
Regards,
Adam
Max bit size possible to read over SPI?
Re: Max bit size possible to read over SPI?
Although there is no reply to my question I would like to share my initial thought how 32 bit SPI respond frame can be captured. First the request can be send byte by byte, then the SPI buffer can be read one byte at a time sending dummy loads.
P.S. It is not an answer.
Code: Select all
uint32_t SendRequest(uint32_t Request)
{
uint32_t Response = 0x00;
digitalWrite(PIN_CSB, LOW);
// Send the request in 8-bit sections
SPI.transfer(Request >> 24);
SPI.transfer(Request >> 16);
SPI.transfer(Request >> 8);
SPI.transfer(Request);
digitalWrite(PIN_CSB, HIGH);
delay(1);
// Capture the response in 8-bit sections
digitalWrite(PIN_CSB, LOW);
Response = SPI.transfer(0x00);
Response = (Response << 8) | SPI.transfer(0x00);
Response = (Response << 8) | SPI.transfer(0x00);
Response = (Response << 8) | SPI.transfer(0x00);
digitalWrite(PIN_CSB, HIGH);
delay(1);
return (Response);
}
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Max bit size possible to read over SPI?
SPI itself doesn't have the concept of 'word size', it just reads in a stream of bits. The ESP32 hardware then reformats these bits into 32-bit words, but that's just a method of storing information. As you can store a bitstream that is as big as the ESP32's free memory, the bit size is more-or-less infinite.
Re: Max bit size possible to read over SPI?
I agree, but AFAIK there is always some frame size limitation. Frame and buffer are different things. So basically, you mean ESP32 can receive 32 bit data in one SPI cycle?ESP_Sprite wrote: ↑Fri Aug 16, 2019 10:57 amSPI itself doesn't have the concept of 'word size', it just reads in a stream of bits. The ESP32 hardware then reformats these bits into 32-bit words, but that's just a method of storing information. As you can store a bitstream that is as big as the ESP32's free memory, the bit size is more-or-less infinite.
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Max bit size possible to read over SPI?
In one transaction (I think you call that a frame; the time when CS is active), you can send/receive any amount of bits, from 1 bit all the way up to 16777215 bits (however, you don't have enough RAM to store the latter amount), and anything in between, with a granularity of 1 bit. As such, 32 bits is possible.
Re: Max bit size possible to read over SPI?
Thanks you for the answer. It is good to know that.ESP_Sprite wrote: ↑Sun Aug 18, 2019 5:46 amIn one transaction (I think you call that a frame; the time when CS is active), you can send/receive any amount of bits, from 1 bit all the way up to 16777215 bits (however, you don't have enough RAM to store the latter amount), and anything in between, with a granularity of 1 bit. As such, 32 bits is possible.
Who is online
Users browsing this forum: jjsch-dev and 105 guests