Hi
I am using IOCTL to write and store into the buffer using CSPI @ 20MHz, it seems to work in the sense the values read are coming out OK., but using the scope I notice a 20us delay between each read. I dont know how to get rid of it. The program is just running in an infinite loop with the spi read.
while(1) ioctl(fd,SPI_MESSAGE(1)....);
I am not sure if its to be with the ioctl function or related to the SPI dev. The SPI dev is 3.0. Any help will be appreciated.
You can add some debug information into driver and check the time cost in each function calling.
I have isolated the function that is taking the most amount of time...
ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
Is there any other way to do SPI read without having to invoke this function or write(fd,...)? I believe that would do the trick.
From code level, write seems to be supported.
write() has the same problem as with ioctl(), the delay is too long.
I don't have much idea now. Will check whether others have more ideas about it.
Some develop in this problem.
Now when I increase the buffer for writing & reading it doesnt have the delay until it exits the routine. Search thru the driver code cspi_mx.c I found that there is a start and stop function. I believe this is what is causeing the delay where start + stop function takes a total of 10us. I might have to recompile the kernel with the "modified" driver where stop is comments and will occur in the main routine itself after all my read is done. Do you see another way?
Samuel, if your issue has been resolved by yourself, please click Correct Aswer/Helpful Answer, so that we can close the discussion
Thanks,
Yixing
Is there a way to do SPI without the use of the Kernel in embedded Linux? Perhaps by calling the registers directly? Is that possible?
I know that the Kernel is taking about 18us to release the device, the problem is i want to do sampling at 200kHz and 18us delay between each read is something that will not allow me to reach that rate. I know that having a large buffer...meaning that that device doesnt get released from the Kernel will allow me to read continuously. but a toggle to the ADC ic is required so.........that is not possible I need to toggle the IO and read the SPI. total time of process should take only 5us....any advice?