Md Abul Fazal

Can SDAC work in wraparound mode with DMA in MPC5777C??

Discussion created by Md Abul Fazal on Mar 10, 2020
Latest reply on Mar 25, 2020 by Nam Nguyen Viet

Below code snippets is for sdadc in wraparound mode (taking data from channel 0->1->2->3)

and then storing in an array with four elements. I'm facing synchronization issue, since here we don't have much control over FIFO which triggers DMA when it is full. How will we transfer the data from CDR register to different elements of array(0th element for channel 0,1st element for channel 1,2nd element for channel 2,3rd element for channel 3)??


since the source is CDR reg with 0 offset then how the data after FIFO gets full will get transferred to the respective elements of an array?? 


static uint32 s32Sdadc_0_Channels_inmv[4] = {0,};

static uint32 s32Sdadc_0_Channels[4] ={0,};


#define SDADC_0_RQUEUE0_ADDRESS (uint32)(&s32Sdadc_0_Channels)
Mcl_DmaTcdAttributesType SdadcDMAChannel36Config = {/** SDADC1 CDR to SDADC RQUEUE0 DMA_A Channel 36 */
(uint32)(&SDADC_1.CDR.R), /** Source Address */
(uint32)SDADC_0_RQUEUE0_ADDRESS, /** Destination Address */
(uint32)2U, /** Source Size */
(uint32)2U, /** Destination Size */
(uint32)0U, /** Source Address Offset */
(uint32)4U, /** Destination Address Offset */
(uint32)0U, /** SMOD */
(uint32)0U, /** DMOD */
(uint32)4U, /** number of bytes to be transferred */
(uint32)4U, /** number of iterations */



Mcl_DmaTcdType * pTcdAddress;
pTcdAddress = (Mcl_DmaTcdType *)Mcl_DmaGetChannelTcdAddress((Mcl_ChannelType)MCL_DMA_LOGICAL_CHANNEL_12);
Mcl_DmaConfigTcd(pTcdAddress, &SdadcDMAChannel36Config);
Mcl_DmaTcdSetFlags(pTcdAddress, (uint8)(0x0 | DMA_TCD_INT_MAJOR_U32));
Mcl_DmaTcdSetDlast(pTcdAddress, -(sint32)16);


following function is being called in 10 msec task-


uint32 tempitr=0;
for(tempitr=0; tempitr<SDADC0_CHANNELS_CONFIGURED; tempitr++)
s32Sdadc_0_Channels_inmv[tempitr] = ((5000*s32Sdadc_0_Channels[tempitr])/(0x7FFFU));




Thank you in advance.

Hoping to get reply soon