Configuration of SPI with minimal delay between words

Hi Everyone,

I’m currently working on a project with the RSL10, and I’ve come to an impasse.

I’m trying to establish an SPI communication with an FRAM, it supports up-to 25Mhz READ/WRITE operations, using the SPI CMSIS Driver. The communication is successful meaning I can write and read data, however there is a delay of approximately 80µs, with 8Mhz system clock, between each 8bits word I write/read. I’m using the base SPI transfer function. This accumulative delay can amount to a significant delay while trying to write multiple words.

I looked in both the hardware and software references and found no variable responsible for minimizing or hopefully eliminating this delay. The only reference I found was SPI*_CTRL0_MODE_SELECT bit that should be set to Auto to limit the overhead thus minimizing the time between words, but in my trials, I noticed no difference.

The part of the hardware reference where the bit is referenced (page 335):

If the SPI*_CTRL0_MODE_SELECT bit in the SPI*_CTRL0 register is set, the SPI interface operates in auto mode to limit the overhead between SPI transfers

The part of the code where I set the Bit to Auto:

static int32_t SPI_Control(uint32_t control, uint32_t arg,
const SPI_RESOURCES_t spi)
{
uint32_t mode, ctrl0, ctrl1, spi_prescale;
mode = 0U;
#if (SPI_DMA_CODE_EN)
DMA_CFG_t dmaCfgR, dmaCfgT;
#endif /
if (SPI_DMA_CODE_EN) */

/* Prepare ctrl0 configuration */
ctrl0 = (SPI0_OVERRUN_INT_DISABLE  |
         SPI0_UNDERRUN_INT_DISABLE |
  	 SPI0_CONTROLLER_CM3       |
  	 SPI0_SELECT_MASTER|
  	 SPI0_CLK_POLARITY_NORMAL|
  	 SPI0_MODE_SELECT_AUTO   | /*MODE_SELECT set to AUTO*/
         SPI0_ENABLE|
  	 SPI0_PRESCALE_2);

I was wondering if there a way to customize/configure the current driver.

Thanks.

@SHADOWI1

Our SPI_CMSIS_DRIVER sample code useing SPI cmsis-driver.
SPI Interface.

  1. You can see there is no auto and manual mode. But it can use two ways to monitor SPI master.

a. Status of the transmitter can also be monitored by calling the ARM_SPI_GetStatus and checking the busy data field, which indicates if transmission is still in progress or pending.
Note: this seems like the manual mode.
b. callback function we sample code do to register it in initialize stage.
Note: this seems like the auto mode. Event trigger… This is fast and has the minimum delay between words transmitting.

 /* Initialize spi0, register callback function */
    spi0->Initialize(SPI0_Master_CallBack);

Question: Why do you see no difference by using auto and manual in SPI_Control()?

Answer:
Since this project use call back method, changing mode in SPI_Control function does not impact. I have explained this before.
If you need to verify manual mode, you need to change the code and monitor by calling the ARM_SPI_GetStatus and checking the busy data field, which indicates if transmission is still in progress or pending.

/* ----------------------------------------------------------------------------
 * Function      : void SPI_GetStatus(const SPI_RESOURCES_t *spi)
 * ----------------------------------------------------------------------------
 * Description   : Get SPIx status
 * Inputs        : spi    - Pointer to SPI resources
 * Outputs       : Return SPIx status as an ARM_SPI_STATUS structure
 * Assumptions   : None
 * ------------------------------------------------------------------------- */
static ARM_SPI_STATUS SPI_GetStatus(const SPI_RESOURCES_t *spi)
{
    ARM_SPI_STATUS status;

    /* Prepare spi status */
    status.busy       = spi->info->status.busy?1U:0U;
    status.data_lost  = spi->info->status.data_lost;
    status.mode_fault = 0U;

    /* Return spi status */
    return status;
}

Thank you for using our community forum!

1 Like