How to use the SPI and send continuous data no gaps...

themindfactory
Posts: 28
Joined: Mon Mar 26, 2018 7:57 pm

How to use the SPI and send continuous data no gaps...

Postby themindfactory » Sat May 05, 2018 8:38 pm

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

ESP_Sprite
Posts: 8926
Joined: Thu Nov 26, 2015 4:08 am

Re: How to use the SPI and send continuous data no gaps...

Postby ESP_Sprite » Sun May 06, 2018 2:53 am

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?

themindfactory
Posts: 28
Joined: Mon Mar 26, 2018 7:57 pm

Re: How to use the SPI and send continuous data no gaps...

Postby themindfactory » Sun May 06, 2018 3:19 am

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

themindfactory
Posts: 28
Joined: Mon Mar 26, 2018 7:57 pm

Re: How to use the SPI and send continuous data no gaps...

Postby themindfactory » Sun May 06, 2018 4:00 am

BTW I have both I2S peripherals running with DMA at the time of this test.

And it is using the Arduino IDE also.

RichardS

ESP_Sprite
Posts: 8926
Joined: Thu Nov 26, 2015 4:08 am

Re: How to use the SPI and send continuous data no gaps...

Postby ESP_Sprite » Mon May 07, 2018 2:39 am

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.

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Re: How to use the SPI and send continuous data no gaps...

Postby f.h-f.s. » Mon May 07, 2018 12:42 pm

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

themindfactory
Posts: 28
Joined: Mon Mar 26, 2018 7:57 pm

Re: How to use the SPI and send continuous data no gaps...

Postby themindfactory » Mon May 07, 2018 11:33 pm

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.

wainbrook1740
Posts: 1
Joined: Sun Feb 06, 2022 2:25 am

Re: How to use the SPI and send continuous data no gaps...

Postby wainbrook1740 » Sun Feb 06, 2022 2:39 am

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.

Who is online

Users browsing this forum: Baidu [Spider] and 51 guests