Hello,
I am working with an external SPI peripheral to send and retrieve data from. The code is written in On Semi’s IDE and with the RSL10 drivers used (version 3.5.285) and the ARM CMSIS Drivers (5.8.0).
The SPI module used is SPI0 and the default pins are used for data transfer :
.default_cfg = { /* spi0 default configuration */
.sclk_pin = RTE_SPI0_SCLK_PIN_DEFAULT, /* spi0 default sclk pin */
.ssel_pin = RTE_SPI0_SSEL_PIN_DEFAULT, /* spi0 default ssel pin */
.miso_pin = RTE_SPI0_MISO_PIN_DEFAULT, /* spi0 default miso pin */
.mosi_pin = RTE_SPI0_MOSI_PIN_DEFAULT, /* spi0 default mosi pin */
And the SPI0 module is set as MASTER with a clock set to 6MHz :
spi0->Control(ARM_SPI_MODE_MASTER,6000000);
spi0->Control(ARM_SPI_SS_MASTER_HW_OUTPUT,0);
spi0->PowerControl(ARM_POWER_FULL);
The CS Pin is set to low when a data transfer is requested.
I am sending 16-bit words over SPI and these words are stocked into a buffer that I am sending all at once, the function used :
void drv_spi_send_table(uint16_t *tabSPIBuffer, uint16_t BufferSize)
{
for (int bufferIndex =0; bufferIndex<BufferSize; bufferIndex++)
{
spi0->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE);
spi0->Transfer(tabSPIBuffer + bufferIndex,NULL,NUMBER_OF_DATA_BYTES);
spi0->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
}
}
(NUMBER_OF_DATA_BYTES is equal to 2 since i am sending 16-bit words)
But when I am sending Data over SPI to the external peripheral, i am noticing a substancial delay between the driving of the CS to the Low Logic Level and the actual data transfer (On a Logic Analyzer).
There is also a delay after the end of the data transfer to the driving of the CS to the High logic level ( peripiheral needs this to accept the following 16-bit word in the buffer) :
I tried minimizing callback overheads by directly accessing the ARM_DRIVER_SPI Driver_SPI0 structure used in the SPI_RSLxx.c file.
Does anyone have a recommandation to reduce this delay ?
Thanks in advance.