2394435_en-US

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

2394435_en-US

2394435_en-US

I need to configure DMA for SPI

I am using S32DS IDE and RTD 3.0 can anyone tell me how to start the DMA with SPI with step by step instructions or any other example code if available

Re: I need to configure DMA for SPI

Thank you for your response

Do this work for s32k322 MCU

Re: I need to configure DMA for SPI

Hi @ershi 

Included with the RTDs are provided two example codes for SPI communication using DMA, one using Low-Level Drivers (Ip) and one using High-Level Drivers (MCAL). You can refer to the thread HOWTO: S32 Design Studio - Create a New S32DS Project from Example for guidance on how to import the examples.

Also, you can refer to the example provided in the thread Example S32K31 SPI Multiple Packet Transmit & Receive: Solution for DMA Cache Issue.


BR, VaneB

Re: I need to configure DMA for SPI

Hi @ershi 

Although the examples are not specifically designed for the S32K322, the functionality is generally the same across the S32K3 family, unless otherwise stated in the Reference Manual Therefore, you can use this project as a reference for your implementation and adapt it as needed for your specific device.

Re: I need to configure DMA for SPI

I had configurated everything but still it is not working initially it is return as LPSPI_IP_STATUS_SUCCESS  for (Lpspi_Ip_AsyncTransmit )and second time it is showing failed LPSPI_IP_STATUS_FAIL  I can able to send the data through spi using this api without the dma Lpspi_Ip_SyncTransmit() I have attached few configuration screenshot 

Re: I need to configure DMA for SPI

Hi @ershi 

Could you also share images of the RM and IntCtrl_Ip driver configurations?
Re: I need to configure DMA for SPI

Hi @VaneB 

I've attached the screenshots for the RM and IntCtrl_IP driver configurations, along with a short video clip for your detailed reference.

I noticed one difference in the LPSPI configuration page. In the SPI General tab, under Spi_Phy_TxDmaChannel, the naming is different between the TX and RX configurations.

Please let me know if you need any additional details

InterruptsInterruptsInterruptsInterruptsInterruptsInterruptsInterruptsInterruptsInterruptsInterruptsRMRMRMRMRMRMRMRMRMRM

Lpi.png

Re: I need to configure DMA for SPI

Hi @ershi 

Thank you for sharing all the information.

I just have one observation. In the Dma_Ip driver configuration, you have defined DMA_SPI_CALLBACK_0 as the Interrupt Callback. However, the LPSPI DMA callbacks are already provided by the driver and can be found in the Lpspi_Ip_Irq.c file.

For LPSPI2, the configured callbacks should be:

  • Lpspi_Ip_LPSPI_2_IrqTxDmaHandler for the TX DMA channel
  • Lpspi_Ip_LPSPI_2_IrqRxDmaHandler for the RX DMA channel
Re: I need to configure DMA for SPI

Hi @VaneB 

Thank you for the clarification.

I updated the Dma_Ip configuration so that, for LPSPI2, the TX and RX DMA channels now use the callbacks from Lpspi_Ip_Irq.c:

  • Lpspi_Ip_LPSPI_2_IrqTxDmaHandler for the TX DMA channel

  • Lpspi_Ip_LPSPI_2_IrqRxDmaHandler for the RX DMA channel nxp

However, the DMA-based LPSPI transfer is still not working as expected on my side. I have attached a screenshot of the current configuration for your reference. If there are any additional settings, I should adjust please let me know

Re: I need to configure DMA for SPI

Hi @ershi 

Could you please let me know how you are implementing the SPI communication? Also, have you test the code from the example I shared previously?

Re: I need to configure DMA for SPI

Hi @ershi 

Are you connecting the LPSPI2 SOUT signal directly to SIN, or are you using a logic analyzer to verify the transmitted and received data?

Re: I need to configure DMA for SPI

Hi @VaneB 

     I have deleted the previous configuration and now the SPI data is transmitting through DMA, but the problem is that the data is not matching 

#define RX_MSG_SIZE (15U)
#define TX_MSG_SIZE (15U)

uint8_t txBuffer_check[TX_MSG_SIZE] = {0x48,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,0x11,0x12,0x13,0x14,0x15};

uint8_t rxBuffer_check[]={0}; 

if(Lpspi_Ip_AsyncTransmit(&Lpspi_Ip_DeviceAttributes_SpiExternalDevice_1_Instance_2_BOARD_InitPeripherals,txBuffer_check,rxBuffer_check,TX_MSG_SIZE,spi_DMA_Function) == LPSPI_IP_STATUS_SUCCESS)

{

Dma_Ip_ReturnType status = {0},status1 = {0};
Dma_Ip_LogicChannelStatusType channelStatus ={0},channelStatus1 ={0};
status = Dma_Ip_GetLogicChannelStatus(DMA_LOGIC_CH_0,&channelStatus);
status1 = Dma_Ip_GetLogicChannelStatus(DMA_LOGIC_CH_1,&channelStatus1); 
 
return SYS_SUCCESS;

}  


Re: I need to configure DMA for SPI

Hi @VaneB,

I have rewritten the code and it is working perfectly now. The data is coming in correctly.

Thank you for your assistance.

Re: I need to configure DMA for SPI

Hi @VaneB 

In our previous discussion about configuring DMA for SPI. I have noticed the RX buffer data is not matching with the logic analyser data Tx buffer is working perfectly working well. I have added detailed information in the dropbox.

タグ(1)
評価なし
バージョン履歴
最終更新日:
19 時間前
更新者: