SPI - delay after transfer() function

Hi everybody,

I am working on my first Arduino project but I have some experience with other MCUs.
The project I am working on requires me to rewrite a driver so it can be used inside the Arduino environment.

The driver communicates over the SPI protocol but there seems to be a huge delay after the spi.transfer() function. I need to write 32-bits so I figured that I could send 4 times 8-bits.

AHB_WRITE_BURST_WRITE(uint32_t data)
    EUSCI_B_SPI_transmitData(SPI_HW_ADDR, HWREG8(&data + 3));
    EUSCI_B_SPI_transmitData(SPI_HW_ADDR, HWREG8(&data + 2));
    EUSCI_B_SPI_transmitData(SPI_HW_ADDR, HWREG8(&data + 1));
    EUSCI_B_SPI_transmitData(SPI_HW_ADDR, HWREG8(&data));
	uint8_t Tempdata, Tempdata1, Tempdata2, Tempdata3;
	Tempdata   = data;
	Tempdata1 = data >> 8;
	Tempdata2 = data >> 16;
	Tempdata3 = data >> 24;

	//Send 32-bit data  - spi_readwrite is defined as spi.transfer


In the attachments, there is a picture located that shows the difference between an msp430 board(The driver was originally written by Texas Instruments so it uses driverlib) and an stm32 board which is programmed using the Arduino IDE.

The data seems to be correct but the overall transmission time takes almost 1.6ms instead of 70us.

Does anybody know how to speed up this process?

Does anybody know how to speed up this process?

Maybe, but not using the information you provided. Post complete code! For example, I have no clue what your spi_readwrite() does, it's not an Arduino standard function. If you implemented your WAIT_FOR_TRANSMIT, that's probably the reason for the slowness. What clockspeeds do you use on the two platforms?

I am sorry,

spi_readwrite() is defined as SPI.transfer(). I saw this implementation in another library and wanted to use the same idea.

#define spi_readwrite      SPI.transfer
#define spi_read()         spi_readwrite(0x00)			//Check Value 
#define spi_write(spi_val) spi_readwrite(spi_val)
#define SPI_BEGIN()        SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0))	//Check value
#define SPI_END()          SPI.endTransaction()

I tried to recreate the issue on an Arduino UNO but there the code functions properly.

Since the Arduino UNO managed to run the code without any problems i figured the problem was located in the core I used for programming my STM32.

Originally i used the STM32DUINO core

I tried compiling the exact same software with the ArduinoCore-stm32l0 of GrumpyOldPizza

The new core fixed the issue