SPI+DMA using Tresos on S32K344
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I would like to know how can I configure the DMA with SPI using Tresos for S32K344.
SW. Version: 4.0.0 HF02_D2407.
I'm trying to configure but I cannot see signal on bus looking the logic analyzer.
Should I configure the channel as IB or EB?
When I remove the DMA, it works properly.
Piece of code that I try to send message:
spi_err_t Spi2_Transfer(const uint8_t *data_out, uint8_t *data_in, uint16_t len){
spi_err_t spi_status = SPI_ERR_SUCCESS;
Spi_StatusType spiHwStatus = Spi_GetHWUnitStatus(Lpspi_Ip_PhyUnitConfig_SpiPhyUnit_2_VS_0.Instance);
if(spiHwStatus != SPI_IDLE)
{
spi_status = SPI_ERR_FAILURE;
}
if(spi_status == SPI_ERR_SUCCESS)
{
if (Spi_WriteIB(SpiConf_SpiChannel_SpiChannel_2, data_out) != E_OK)
{
spi_status = SPI_ERR_FAILURE;
}
if (Spi_AsyncTransmit(SpiConf_SpiSequence_SpiSequence_2) != E_OK)
{
spi_status = SPI_ERR_FAILURE;
}
if (Spi_ReadIB(SpiConf_SpiChannel_SpiChannel_2, data_in) != E_OK)
{
spi_status = SPI_ERR_FAILURE;
}
}
return spi_status;
}
When I remove the DMA and use the channel as EB, this is the code:
spi_err_t Spi2_Transfer(const uint8_t *data_out, uint8_t *data_in, uint16_t len){
spi_err_t spi_status = SPI_ERR_SUCCESS;
Spi_StatusType Spi_HwStatus = Spi_GetHWUnitStatus(Lpspi_Ip_PhyUnitConfig_SpiPhyUnit_2_VS_0.Instance);
if(Spi_HwStatus != SPI_IDLE)
{
spi_status = SPI_ERR_FAILURE;
}
if(spi_status == SPI_ERR_SUCCESS)
{
if(Spi_SetupEB(SpiConf_SpiChannel_SpiChannel_2, data_out, data_in, len) == E_OK)
{
if(Spi_AsyncTransmit(SpiConf_SpiSequence_SpiSequence_2) != E_OK)
{
spi_status = SPI_ERR_FAILURE;
}
}
}
return spi_status;
}
Note: With DMA, I can see that the interrupt is working with breakpoints, Dma0_Ch4_IRQHandler, Dma0_Ch3_IRQHandler, Lpspi_Ip_LPSPI_2_IrqTxDmaHandler and Lpspi_Ip_LPSPI_2_IrqRxDmaHandler callbacks, but I can't see signal on the bus as I can see without DMA configuration.
Thanks,
MVR

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @MVR
I have reviewed your configurations, and they seem correct. I just want to confirm something: I assume you also configured the PhyRxDmaChannel, is that right? Did you use a different channel?
To ensure that no configurations are missing, I suggest reviewing the Spi_Transfer_S32K344 example provided with the RTDs. This application demonstrates how to configure the MCL, MCU, Platform, Port, RM, and SPI drivers, and it would serve as a good reference for you.
Additionally, I recommend reviewing the S32K3_S32M27x SPI Driver Integration Manual and the User Manual included with the RTDs. These documents provide detailed information about the driver, including its limitations, hardware and software requirements, usage instructions, and configuration guidelines. They will be very helpful for gaining a deeper understanding of the driver's functionality. You can find these resources at the following location:
C:\NXP\SW32K3_S32M27x_RTD_R21-11_5.0.0\eclipse\plugins\Spi_TS_T40D34M50I0R0\doc
Please note that the path may vary depending on the software version and your installation directory.
BR, VaneB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @VaneB ,
I found the issue,
In my code I was sending 256 bytes, not 1024. When I changed it to 256 it worked. Do you know if it is possible for this value to be adaptable at runtime like in the EB type?
When we select the EB type, we can choose the maximum number of bytes to be sent.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @MVR
I am afraid that there is no function available to change the SpiIbNBuffers at runtime.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @VaneB ,
I assume you also configured the PhyRxDmaChannel, is that right? Did you use a different channel?
Yes, I have configured the RX channel, I didn't send because it is the same configuration as the TX channel, only changing to RX, I used a different channel as well.
I will check the documentation that you recommended. The example I already took a look...
Two questions:
1- Should I use IB or EB in the SPI channel configuration (SpiChannelType) when use DMA? If it is IB, my code is correct?
2- I ended up thinking now about it, the CS pin behavior change between SPI with DMA and without DMA? It is important to know because my logic analyzer is tied to after isoSPI conversion, and the CS pin is the responsible to wake up the isoSPI chip converter.
Thanks,
MVR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Some pictures of DMA configuration:
Platform module:
SPI module:
