2021-02-22 1:42 AM
Hello,
I've been trying to transfer some data from AXI-SRAM to DTCM via MDMA but it seems not functional.
The transfer occurs the flag of end of transfer is set yet the data that I have in my DTCM isn't the orignal one contained in the AXI-SRAM.
Also important point to note is that I don't have an error flag.
I have reduced everything to a minimum but yet it doesn't seems functional.
Here is some bits of my code:
#define ADC_IN_BUFFER_SIZE 10
__attribute__ ((section(".axi"), used)) uint16_t RandomBuffer[ADC_IN_BUFFER_SIZE]={0x0000};
__attribute__ ((section(".dtcm"), used)) uint16_t samplingBuffer[ADC_IN_BUFFER_SIZE]={0x0000};
void MX_MDMA_Init(void)
{
//switching on the clock for MDMA
LL_AHB3_GRP1_EnableClock(LL_AHB3_GRP1_PERIPH_MDMA);
NVIC_SetPriority(MDMA_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
NVIC_EnableIRQ(MDMA_IRQn);
LL_MDMA_SetTriggerMode(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_BLOCK_TRANSFER);
LL_MDMA_SetRequestMode(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_REQUEST_MODE_SW);
LL_MDMA_SetDestinationDataSize(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_DEST_DATA_SIZE_HALFWORD);
LL_MDMA_SetSourceDataSize(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_SRC_DATA_SIZE_HALFWORD);
LL_MDMA_SetDestinationIncMode(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_DEST_INCREMENT);
LL_MDMA_SetSourceIncMode(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_SRC_INCREMENT);
LL_MDMA_SetDestinationIncSize(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_DEST_INC_OFFSET_HALFWORD);
LL_MDMA_SetSourceIncSize(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_SRC_INC_OFFSET_HALFWORD);
LL_MDMA_SetBufferTransferLength(MDMA, LL_MDMA_CHANNEL_0, 1);
LL_MDMA_SetChannelPriorityLevel(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_PRIORITY_VERYHIGH);
LL_MDMA_SetDestinationAddress(MDMA, LL_MDMA_CHANNEL_0, (uint32_t) samplingBuffer);
LL_MDMA_SetSourceAddress(MDMA, LL_MDMA_CHANNEL_0, (uint32_t) RandomBuffer);
LL_MDMA_SetDestBusSelection(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_DEST_BUS_AHB_TCM);
LL_MDMA_SetSrcBusSelection(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_SRC_BUS_SYSTEM_AXI);
LL_MDMA_SetBlkRepeatCount(MDMA, LL_MDMA_CHANNEL_0, 0);
LL_MDMA_SetBlkRepeatDestAddrUpdate(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_BLK_RPT_DEST_ADDR_DECREMENT);
LL_MDMA_SetBlkRepeatSrcAddrUpdate(MDMA, LL_MDMA_CHANNEL_0, LL_MDMA_BLK_RPT_SRC_ADDR_DECREMENT);
LL_MDMA_SetBlkRptDestAddrUpdateValue(MDMA, LL_MDMA_CHANNEL_0,ADC_IN_BUFFER_SIZE);
LL_MDMA_SetBlkRptSrcAddrUpdateValue(MDMA, LL_MDMA_CHANNEL_0,ADC_IN_BUFFER_SIZE);
LL_MDMA_EnableIT_BT(MDMA, LL_MDMA_CHANNEL_0);
LL_MDMA_EnableIT_TE(MDMA, LL_MDMA_CHANNEL_0);
LL_MDMA_EnableIT_TC(MDMA, LL_MDMA_CHANNEL_0);
}
void MDMA_Start(void)
{
LL_MDMA_SetBlkDataLength(MDMA, LL_MDMA_CHANNEL_0, ADC_IN_BUFFER_SIZE);
LL_MDMA_EnableChannel(MDMA, LL_MDMA_CHANNEL_0);
}I call the MX_MDMA_Init() function along with others standard inits and the MDMA_Start() just before the software triggering.
Any clues why things aren't working as intended?
Seb
Solved! Go to Solution.
2021-02-22 2:48 AM
Okay,
Apparently it is my bad.
It seems that if DCache is used meanwhile MDMA transfers data the transfer gets strange and full of irrelevant data.
Seb
2021-02-22 2:48 AM
Okay,
Apparently it is my bad.
It seems that if DCache is used meanwhile MDMA transfers data the transfer gets strange and full of irrelevant data.
Seb
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.