Hello,
Currently using asynchronous DMA-SPI. I need to make synchronous transfer for the same unit. How can I make both synchronous and asynchronous transfer for the same unit?
Thank you.
Hello Julian,
Thank you for the valuable information you've provided.
Currently, I am using the AUTOSAR SPI example, so changing the driver is not an option for me at the moment. What I want to achieve is using an IC with asynchronous DMA. I can use the IC with asynchronous DMA, but I initialize the IC by sending multiple SPI transfers. I want the initialization process to be completed before the system fully boots up. Afterward, I want it to run asynchronously at runtime. Therefore, what I aim to do is as follows:
Spi_Init(&SyncConfig);
IC_Init();
Spi_Init(&AsyncConfig);
Could you assist me with how to implement this?
Thank you.
Best regards,
ONUR
Hi @ONUR,
Yes, sure. You can simply configure the SPI instance for either sync or async dma:
And create two functional groups (in my case, VS_0 & VS_1):
You can see that each functional group has its own modules and configurations:
After updating code, you will find both configs as such:
You can simply use Spi_Init(&Spi_Config_VS_0) or Spi_Init(&Spi_Config_VS_1). It is also needed to configure the module as as variant post build and check "Post Build Variant Used"
Best regards,
Julián
Hello Julian,
As you mentioned, I would like to add two SPI configurations, run synchronously at the start, and then switch to asynchronous during runtime. Should I configure this through post-build? Should I create two configurations for SPI, initialize synchronously first, then deinitialize, and switch to the asynchronous configuration? If so, could you assist me with how to implement this?
Thank you.
Best regards,
ONUR
Hi @ONUR,
The general behavior of the SPI Handler and Driver could be asynchronous or synchronous according to the level of functionality selected. After Lpspi_Ip_Init function is called, LPSPI_IP_POLLING mode is set as default to change the default mode Lpspi_Ip_UpdateTransferMode should be called.
You can select between Flexio_Spi_Ip_Async/SyncTransmit:
Best regards,
Julián
Hi @ONUR,
You can refer to both S32K358 SPI examples from the RTD 4.0.0 package.
Lpspi_Ip_DmaRepeatedTransfer demonstrates how to configure the DMA + SPI, and uses Lpspi_Ip_AsyncTransmit, and Lpspi_Ip_HalfDuplexTransfer uses both Sync and Async methods for transfer.
Best regards,
Julián
Hello,
Actually, I would like to perform asynchronous transfers on CS0 for LPSPI0, while executing synchronous transfers on CS1.Can you help me this problem ?
Thank you.
Hi @ONUR,
Are you trying to configure two instances for SPI? You can use the existing example as reference or base and add the extra configuration for the second instance. If you have any issues when configuring or with the communication, please let me know.
Best regards,
Julián