Page 1 of 1
How to use the SPI and send continuous data no gaps...
Posted: Sat May 05, 2018 8:38 pm
by themindfactory
Right now it seems when I send SPI data it send in chunks of 8 with a gap in between.
I need a continuous stream of data no breaks or gaps,
Also, can the ESP32 send data in formats longer than 8 bits?
RichardS
Re: How to use the SPI and send continuous data no gaps...
Posted: Sun May 06, 2018 2:53 am
by ESP_Sprite
That's interesting; normally you'd actually have to do something special to get behaviour like that. What do you do in your code, and how did you conclude there are gaps between the eight bits?
Re: How to use the SPI and send continuous data no gaps...
Posted: Sun May 06, 2018 3:19 am
by themindfactory
Oscilloscope :=)
I did something like for testing:
uint8_t i = 0x55;
while(1) {
hspi->transfer(i);
}
there were gaps every 8 bits...
You are saying it should be fluent? If I sent say...
uint8_t array[100];
int i = 0;
while(++i != 100) {
hspi->transfer(array);
}
no gaps??
RichardS
Re: How to use the SPI and send continuous data no gaps...
Posted: Sun May 06, 2018 4:00 am
by themindfactory
BTW I have both I2S peripherals running with DMA at the time of this test.
And it is using the Arduino IDE also.
RichardS
Re: How to use the SPI and send continuous data no gaps...
Posted: Mon May 07, 2018 2:39 am
by ESP_Sprite
Ah, the Arduino SDK uses its own drivers, unfortunately I don't really know how those work. Also, moved this topic to the Arduino subforum.
Re: How to use the SPI and send continuous data no gaps...
Posted: Mon May 07, 2018 12:42 pm
by f.h-f.s.
You can send data in 8 or 16 bit chunks but also as a array.
Syntax
receivedVal = SPI.transfer(val)
receivedVal16 = SPI.transfer16(val16)
SPI.transfer(buffer, size)
https://www.arduino.cc/en/Reference/SPITransfer
Re: How to use the SPI and send continuous data no gaps...
Posted: Mon May 07, 2018 11:33 pm
by themindfactory
ESP_Sprite wrote:Ah, the Arduino SDK uses its own drivers, unfortunately I don't really know how those work. Also, moved this topic to the Arduino subforum.
No problem, I have figured it out by writing my own driver for it within the Arduino IDE, I found someone with some fairly simple code to control the SPI...
https://github.com/natanaeljr/esp32-SPIbus and I messaged it to work for me. And yes I get all the data I want out... and no gaps now!
works very nicely....
Now I just wonder how to make it send a block of data out the SPI, and interrupt me when its done
right now even though its DMA, it waits till all the data is sent....
RichardS.
Re: How to use the SPI and send continuous data no gaps...
Posted: Sun Feb 06, 2022 2:39 am
by wainbrook1740
No problem, I have figured it out by writing my own driver for it within the Arduino IDE, I found someone with some fairly simple code to control the SPI...
https://github.com/natanaeljr/esp32-SPIbus and I messaged it to work for me. And yes I get all the data I want out... and no gaps now!
works very nicely....
Now I just wonder how to make it send a block of data out the SPI, and interrupt me when its done
right now even though its DMA, it waits till all the data is sent....
Hello RichardS.,
Can you please post your code? I am trying to send rotary encoder data over esp now using interrupt and bit bang method but I'm getting guru meditation core panic after few milliseconds, so I think spi can do the job, thanks in advance.