This question might be similar to this one: https://community.nxp.com/t5/S32K/S32K312-LPSPI-DMA-AsyncTransmitFast/m-p/1923811
I have to send two spi transaction to a device. I am trying to use Lpspi_Ip_AsyncTransmitFast.
const Lpspi_Ip_FastTransferType ft[] = {
{
.ExternalDevice = &Lpspi_Ip_DeviceAttributes_SpiExternalDevice_0_Instance_0,
.TxBuffer = txbuf_wren,
.RxBuffer = rxbuf_wren,
.DefaultData = 0,
.Length = 1,
.KeepCs = false,
},
{
.ExternalDevice = &Lpspi_Ip_DeviceAttributes_SpiExternalDevice_0_Instance_0,
.TxBuffer = txbuf,
.RxBuffer = rxbuf,
.DefaultData = 0,
.Length = 10,
.KeepCs = false,
}
};
void send_spi_txn(void)
{
Lpspi_Ip_StatusType status = Lpspi_Ip_AsyncTransmitFast( ft, 2, Lpspi_Ip_Callback_lpspi_0_dma );
if (status != LPSPI_IP_STATUS_SUCCESS)
{
failed_spi_dma = true;
}
}
I have already tested using Lpspi_Ip_AsyncTransmit to send a single transaction and then sending another one from the completion callback, but this is obviously not ideal so would like to be able to use the transferlist instead.
The issue is that no data is being sent. the first time Lpspi_Ip_AsyncTransmitFast is called it reports success, but every subsequent call fails. also can see that there are no spi transfers. on the logic analyzer, but when i just do Lpspi_Ip_AsyncTransmit everything works fine.
解決済! 解決策の投稿を見る。
Unfortunately I can't post the project because I am only using S32DS to configure the RTD and to generate driver config files.
But I was able to work through the issues and unsurprisingly it was a data cache issue with the DMA.
#define MCL_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
#include "Mcl_MemMap.h"
/* Pointer to the DMA Initialization Configuration. Based on this configuration pointer, the DMA Driver obtains all information for the Logic Channels and corresponding Channel Configurations. The Pointer is loaded when Dma_Ip_Init() is called. */
static const Dma_Ip_InitType * Dma_Ip_pxInit;
#define MCL_STOP_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
#include "Mcl_MemMap.h"
#ifdef MCL_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
/**
* @file Mcl_MemMap.h
*/
#undef MCL_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
#define ENTERED_MCL_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
#ifndef MEMMAP_MATCH_ERROR
#define MEMMAP_MATCH_ERROR
#else
#ifndef MCL_STOP_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
#error "MemMap.h, no valid matching start-stop section defined."
#endif
#endif
/**
* @file Mcl_MemMap.h
*/
#undef MEMMAP_ERROR
#pragma GCC section bss ".mcal_bss_no_cacheable"
#endif
__attribute__((section(".mcal_bss_no_cacheable")))
static const Dma_Ip_InitType * Dma_Ip_pxInit;Hello,
is there any further update on this topic? is there any example project available.
Unfortunately I can't post the project because I am only using S32DS to configure the RTD and to generate driver config files.
But I was able to work through the issues and unsurprisingly it was a data cache issue with the DMA.
#define MCL_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
#include "Mcl_MemMap.h"
/* Pointer to the DMA Initialization Configuration. Based on this configuration pointer, the DMA Driver obtains all information for the Logic Channels and corresponding Channel Configurations. The Pointer is loaded when Dma_Ip_Init() is called. */
static const Dma_Ip_InitType * Dma_Ip_pxInit;
#define MCL_STOP_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
#include "Mcl_MemMap.h"
#ifdef MCL_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
/**
* @file Mcl_MemMap.h
*/
#undef MCL_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
#define ENTERED_MCL_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
#ifndef MEMMAP_MATCH_ERROR
#define MEMMAP_MATCH_ERROR
#else
#ifndef MCL_STOP_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
#error "MemMap.h, no valid matching start-stop section defined."
#endif
#endif
/**
* @file Mcl_MemMap.h
*/
#undef MEMMAP_ERROR
#pragma GCC section bss ".mcal_bss_no_cacheable"
#endif
__attribute__((section(".mcal_bss_no_cacheable")))
static const Dma_Ip_InitType * Dma_Ip_pxInit;@PetrS or @davidtosenovjan do either of you have any suggestions on what i can check?
one additional thing i have noticed is that the dma interrupt for the tx channel is being called repeatedly. it is supposed to call Lpspi_Ip_LPSPI_0_IrqTxDmaHandler callback but it never does.
correction: `Lpspi_Ip_LPSPI_0_IrqTxDmaHandler` actually does get called but only once. and then never again