Page 1 of 1

SPI Slave - Missing data during the first few seconds after initialization

Posted: Mon Dec 02, 2019 11:06 am
by mpulis
Hi all!

I've setup a program which reads incoming data over the SPI Slave Interface and saves all the received data to a file on a connected SD card once the buffer which is being written to is full. The received data is in the form of an incrementing counter.

The problem which I'm observing is that some data being transmitted over SPI from the host is being lost during the first 34 seconds of the program running. After those 34 seconds have elapsed, I can find no missing data in the data saved in the SD card.

I can't make sense of why this is happening. The SPI Slave task is the only task running on core 0, while the task responsible for handling the SD card is running on core 1.

Are there any background functions which are running on core 0 in those 34 seconds after the ESP32 is initialized?

Re: SPI Slave - Missing data during the first few seconds after initialization

Posted: Mon Dec 02, 2019 7:13 pm
by PeterR
Are there any background functions which are running on core 0 in those 34 seconds after the ESP32 is initialized?
Timer tasks, lwip tasks, IDLE etc.
But I suspect that the problem is closer to home. Maybe power to SD, your buffering, one of your tasks blocking?

I have done a fair amount of SD logging & no start up issues (so far)!

Re: SPI Slave - Missing data during the first few seconds after initialization

Posted: Tue Dec 03, 2019 8:56 am
by mpulis
If the problem was coming from those tasks, wouldn't the problem persist beyond those 34 seconds? I've run tests for an hour with the same results. It does seem to be something to do with initialization.

Could it be that there is some conflict initially between the SDMMC host and the VSPI peripheral I'm using for the SPI Slave?

Re: SPI Slave - Missing data during the first few seconds after initialization

Posted: Wed Dec 04, 2019 12:20 am
by PeterR
Hi,
Please show the libraries etc that you are using. Maybe some source?

I have used SPI SD (not SDMMC). I produced a SPI SD qualifcation test & that ran for ages whilst shaked n baked.
I had to write my own SD driver based on ANO library. I did look for out of box but found a lot of buggy Ardunio code. Maybe thats your issue?

I am not saying that the problem is in 'those' tasks. Rather that 'those' tasks are running.
All I can suggest is that you produce a simple worked example and post.
The WROOVER has SD and SPI (?). Maybe an example based on would allow others to repeat?