Hi Jeremyzhou,
In "fsl_edma_driver.c", there is :
/*!
* @brief Macro for size of memory need for software TCD.
*
* Software TCD is aligned to 32 bytes. To make sure the software TCD can meet the
* eDMA module's requirement, allocate memory with extra 32 bytes.
*/
#define STCD_SIZE(number) ((number + 1) * 32)
#define STCD_ADDR(address) (edma_software_tcd_t *)(((uint32_t)address + 32) & ~0x1FU)
With the following code :
tcd = malloc(STCD_SIZE(number_of_TCDs))
memory allocation is not garanteed to be 32 bytes aligned, and the use of STCD_ADDR(address) is necessary and is working as it is.
But, using for instance :
tcd[number_of_TCDs] __attribute__ ((aligned (32)));
makes address aligned on 32 bytes boundary, and call to STCD_ADDR(address) drops to address TCD+1 as I have experienced.
It seems that I am not the only one experiencing such a problem :
Re: KSDK eDMA edma_software_tcd_t allocation needs to be 'number plus 1'
I might say that using " __attribute__ ((aligned (32)))" in the TCDs memory allocation should be sufficient and keep off the trouble of allocating "+1 " TCD...
Hope this helps,
Maurice