AUTOSAR SPI S32K358 Sync Async Transmit

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AUTOSAR SPI S32K358 Sync Async Transmit

546 Views
ONUR
Contributor I

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.

0 Kudos
Reply
7 Replies

162 Views
ONUR
Contributor I

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

0 Kudos
Reply

145 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @ONUR,

Yes, sure. You can simply configure the SPI instance for either sync or async dma:

Julin_AragnM_0-1726770664852.png

And create two functional groups (in my case, VS_0 & VS_1):

Julin_AragnM_1-1726771039375.png

You can see that each functional group has its own modules and configurations:

1.png

After updating code, you will find both configs as such:

Julin_AragnM_4-1726771119986.png

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"

Julin_AragnM_5-1726771224669.png

Best regards,
Julián

 

0 Kudos
Reply

201 Views
ONUR
Contributor I

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

0 Kudos
Reply

187 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

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.

1.png

You can select between Flexio_Spi_Ip_Async/SyncTransmit:

Best regards,
Julián

0 Kudos
Reply

509 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

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. 

Julin_AragnM_0-1723830199510.png

Best regards,
Julián

0 Kudos
Reply

454 Views
ONUR
Contributor I

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.

0 Kudos
Reply

437 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply