Hi Team,
We have an adc interfaced at main SPI2, which provides data in time-synchronous manner. So, we have to perform 14 frames read operation(Each frame is 32 bit data) within 200us. Below is the code snippet used to perform frame read operation
memset(st->frame_data, 0x00, st->frame_size);
memset(&xfer, 0, sizeof(xfer));
xfer.tx_buf = st->frame_data;
xfer.rx_buf = st->frame_data;
xfer.len = st->frame_size;
xfer.bits_per_word = 8;
// xfer.len = (st->frame_size)/4;
// xfer.bits_per_word = 32;
// mutex_lock(&st->lock);
spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->spi, &msg);
When we probe the signals we see that there is an inconsistent behavior in SPI inter-byte transfer. The delay sometime goes upto 90-100us, which is a problem for us. The SPI clock is chosen as 10 MHz.
Request you to look into the issue and provide us a suggestion.
Solutions Tried so far-
- We have enabled the DMA as per TI’s suggestion - https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1356551/faq-am6x-optimizing-spi-transfer-inter-byte-gaps-using-the-dma-in-linux
But, we don’t see much improvements. The inter-byte SPI transfer delay is around 2us in working case. As we keep the system for 2-3 mins the SPI transfer delay will gradually increases and thus causes the adas to go out-of sync.
- Increase the number of bits per SPI transfer – The number of bits per word were increased to 32 instead of 8 to improve the SPI inter-byte latency. We see some improvement. However, again after sometime of SPI data capture, the system will starts introducing delay starting from executing the IIO ISR handler, SPI CS to SPI CLk delay, SPI frame to frame read delay.
Working Scenario | |
---|---|
Operation | Delay |
IIO ISR handler | 16us |
SPI CS to SPI CLK | 5us |
SPI frame to SPI frame read | 9us |
Non-Working Scenario | |
---|---|
Operation | Delay |
IIO ISR handler | 80us |
SPI CS to SPI CLK | 20us |
SPI frame to SPI frame read | 100us |
We would like to know the reason for this inconsistent delay, which happens at randomly during SPI data capture.
Looking forward for your response.
Thanks and Regards,
Akshay