Hi,
1.I tired to read data via SPI from external module. My SPI clock frequency is 10MHz , and as per my requirement i need to get data with in 2msec. But when i measured the time to read data it is taking 22msec.
i used libsoc-C library.
What could be the reason for the issue? Is there any way to reduce the delay?
2 And i used "libsoc_spi_rw " function to read data , My observation is data getting stored from second element of array passed to that function. why is it so?
(thinking this function do both write and read operations simultaneously so first it writes address byte on MOSI that time No data on MISO hence i am seeing 0/junk in first element of array)
Can anyone please provide me the reasons for the issues.
Thanks & Regards,
Jhansi P
Regarding point1:
“libsoc_spi_rw” function taking 70 - 90 usec to read 6 bytes of data. So based on our requirment it is taking 22msec. But still is there any possibility to reduce the time take by "“libsoc_spi_rw” .
Regarding point2 mentioned in above,
And please find the attachment to check.
In that Blue - MISO
Red - CS
Green - MOSI
Yeloow - clk
Hi @jhansiP ,
Welcome to Toradex Community!
Could you please provide your BSP version?
and what is your hardware setup for testing the SPI? Can you provide any sample application?
Hi Deven,
Thank you for the reply,
The version No is :
Linux apalis-imx6 4.9.166-2.8.6+gd899927728be #1 SMP Wed Jun 3 15:12:18 UTC 2020 armv7l GNU/Linux
My hardware setup is simple! I just connected an external module(supports SPI) to X27 of Ixora carrier board.
And sample code I tried is:
for(int16 cnt = 0; cnt < 340; cnt++ )
{
gettimeofday(&t1, NULL);
libsoc_spi_rw(spi_dev,address,data,7);
gettimeofday(&t2, NULL);
}
The diff b/w t1 and t2 for 1 iteration is from 60 to 80usec(the iteration time is varying).Please check the duration for which CS is low.
Red - CS,
Blue - clock
Yellow - mosi
Green - miso
Is there any way to reduce the time taken by "libsoc_spi_rw " function?
If So can you please suggest us procedure.
Regards,
Jhansi P

Hi @jhansiP ,
Could you please check by increasing SPI frequency from DTS.
Also please try to access directly spidev node, without any third party LIB (which can cause more delay).
Here is one example to use the same.
Hi deven,
I have tried the code you sent(with some modifications), Please check the attachment.
But with that also we are facing same issue, still CS is low even after and before transfer
Please check it and let me know if anything is wrong in the code i tried,
and suggest me if any way is there to reduce delay.
Thanks & Regards,
Jhansi P
Hi @jhansiP ,
Can you please check which SPI mode(PIO or DMA) you are using?
You can check/share your DTS node for related SPI.