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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

1,186 次查看
abul_fazal
Contributor II

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)??

Doubt:

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);
Mcl_DmaEnableHwRequest(MCL_DMA_LOGICAL_CHANNEL_12);

following function is being called in 10 msec task-

SDADC_1.STKR.R = 0xFFFF;
uint32 tempitr=0;
for(tempitr=0; tempitr<SDADC0_CHANNELS_CONFIGURED; tempitr++)
{
s32Sdadc_0_Channels_inmv[tempitr] = ((5000*s32Sdadc_0_Channels[tempitr])/(0x7FFFU));
SDADC_1.SFR.B.DFORF =1U;
}
Mcl_DmaEnableHwRequest(MCL_DMA_LOGICAL_CHANNEL_12);

Thank you in advance.

Hoping to get reply soon

0 项奖励
4 回复数

989 次查看
namnguyenviet
NXP Employee
NXP Employee

Hi,

So far as I have checked, DMA for SDADC couldn't work as your expectation, as SDADC doesn't automatically switch the measured channel during a conversion (taking data from channel 0->1->2->3), it need a trigger to do that, by software or hardware, otherwise SDADC will keep the channel for measurement.

With software, it can be done by writing to STKR.ST_KEY at any time during the wraparound mode, or writing to CSR.ANCHSEL at anytime during the wraparound mode also. I have given a shot, by trying to setting up each of these two way before a DMA request occurred, but unfortunately, neither of them are worked, might be the total time of conversion before a DMA request is too fast that not enough for some settings to be changed.

I will try with hardware trigger to see if it can be worked.

0 项奖励

989 次查看
abul_fazal
Contributor II

Hi, The DMA is getting triggered for the respective sdadc dma channels after FIFO gets full. The problem lies in the movement of data by dma from the CDR register to an array. As the sdadc runs in wraparound mode, so during channel change the DMA doesn't pick the consistent data of each sdadc channels to the respective elements of array.

0 项奖励

989 次查看
namnguyenviet
NXP Employee
NXP Employee

Hello,

I haven't deeply checked, but as far as I concerned, you might have an incorrect usage of MCL functionality, particularly with Mcl_DmaGetChannelTcdAddress() and Mcl_DmaEnableHwRequest(). Both of these two functions' parameters is the DMA channel ID which you've been configured in EB, not the DMA logical channel. 

DMA_Channel_SDADC.JPG

The DMA channel used for SDADC is eDMA_36 in DMA_B, which is eDMA_100 in DmaHwChannel. In order to use that DMA channel, DMA channel ID shall be added to Mcl_DmaGetChannelTcdAddress() and Mcl_DmaEnableHwRequest(), e.g.:

pTcdAddress = (Mcl_DmaTcdType *)Mcl_DmaGetChannelTcdAddress((Mcl_ChannelType)6);

Mcl_DmaEnableHwRequest(6);

But maybe your purposes are different.

0 项奖励

989 次查看
namnguyenviet
NXP Employee
NXP Employee

Hi,

Could you tell me which MCAL version are you using? Also please share with us MCL configuration (better in xdm or epc) to get better analyzed.

0 项奖励