SPI Continuous Read Write

Hi ,

I am facing an issue with spi read write operation -

Method1 : What I Want[This is how I want my flow] → CS LOW — SPI Write Data – SPI Read Data – CS HIGH.

Method2 : What is Happening[This is what I have to do to write and read properly] → CS LOW – SPI Write Data – CS HIGH – CS LOW – SPI Read Data – CS HIGH.

I have to toggle my Chip Select[CS] pin every time to do any read or write operation without that I am reading only 0xFF , Please let me how to fix this so that I can do my read write operation by using method1.

I am sharing my spi initialization , I am using “ARM_SPI_SS_MASTER_UNUSED” because my Slave device Chip Select PIN is not connected to the rsl10 directly , It is connected via I2c expander , which I can config/control from Rsl10 :

void HAL_SPI_Init(void)
{
int32_t retval;

if (ctrl.enabled)
{
	return;
}

ctrl.callback = NULL;

retval = Driver_SPI0.Initialize(&HAL_SPI_DriverCallback);
ASSERT_DEBUG(retval == ARM_DRIVER_OK);

retval = Driver_SPI0.PowerControl(ARM_POWER_FULL);
ASSERT_DEBUG(retval == ARM_DRIVER_OK);

retval = Driver_SPI0.Control(ARM_SPI_MODE_MASTER |
		ctrl.bus_mode |
		ARM_SPI_DATA_BITS(8) |
		ARM_SPI_MSB_LSB |
		ARM_SPI_SS_MASTER_UNUSED,
		ctrl.bus_speed);
ASSERT_DEBUG(retval == ARM_DRIVER_OK);

retval = Driver_SPI0.Control(ARM_SPI_SET_DEFAULT_TX_VALUE, 0);
ASSERT_DEBUG(retval == ARM_DRIVER_OK);

ctrl.enabled = true;

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

static int32_t SPI_Initialize(ARM_SPI_SignalEvent_t cb_event,
const SPI_RESOURCES_t spi)
{
/
Check if driver is already initialized /
if (spi->info->state & SPI_INITIALIZED)
{
/
Driver is already initialized */
return ARM_DRIVER_OK;
}

/* Initialize SPI Run-Time Resources */
spi->intInfo->cb             = cb_event;
spi->info->status.busy       = SPI_FREE;
spi->info->status.data_lost  = 0U;
spi->info->status.mode_fault = 0U;

/* Clear transfer information */
memset(spi->xfer, 0, sizeof(SPI_TRANSFER_INFO_t));

/* Indicate that driver is initialized */
spi->info->state = SPI_INITIALIZED;

/* Return OK */
return ARM_DRIVER_OK;

}

@shivamtyagi.im

Our RSL10 SPI can support read, write only and also support read and write at the same time.
Please run our SPI sample project “spi_cmsis_driver” . It can read/write at the same time.
Maybe our understanding is not correct. You might not want to write and read at the same time.

Your question is:

Method_1 : What I Want[This is how I want my flow] → CS LOW — SPI Write Data – SPI Read Data – CS HIGH.

Method_2 : What is Happening[This is what I have to do to write and read properly] → CS LOW – SPI Write Data – CS HIGH – CS LOW – SPI Read Data – CS HIGH.

Assuming : You just need read and write only.
You can’t do Method_1. SPI has Master and Slave.
SPI Master control the Clock for data TX/RX.
SPI Slave has to use CS signal to trigger TX and RX process.
You have to use Method_2.

Thank you for using our community forum.